Skip to content

Authorization defect patterns

This page lists authorization defects that have recurred in ConnectSoft services. Each pattern names the symptom you see, the cause, what to look for in a review, and the test that catches it. The rules these patterns break are on the authorization standard and the security and compliance standard.

Most of these defects fail open: the screens look right, administrators see nothing wrong, and only a caller with fewer rights, a direct call to the service, or a missing optional value shows the problem. Test as the least-privileged caller, and call the service directly as well as through the gateway.

Gates and refusals

CS-DP-AUZ-001: API ships with no authorization at all

Severity: blocker · Applies to: service, template · Enforced by: manual (target: ENF-038) · Status: active

Symptom

Every service generated from a template exposes an administration API that any caller can use.

Cause

The host registers no authentication or authorization, the controllers have no authorize attributes, and no test checks for either.

Check

  • Controllers or actions without a named policy.
  • A host without a deny-by-default fallback policy.

Test

An architecture or acceptance test asserts that every routed action has a policy or an explicit [AllowAnonymous], and that an anonymous call to a protected action is refused.

CS-AUZ-001, CS-SEC-002

CS-DP-AUZ-002: Permission gate exists only at the gateway

Severity: blocker · Applies to: service, template · Enforced by: manual (target: ENF-038) · Status: active

Symptom

The gateway answers 403 to a low-privilege user, while the service answers 200 to the same token on its own address.

Cause

The service relies on a global "authenticated user" fallback, so an action without a named policy accepts any valid token. A probe that shows every route answers 401 to an anonymous call looks safe and proves nothing about capabilities.

Check

  • Service actions without a policy where the matching gateway route has one.
  • Writes gated while reads on the same controller are not.
  • Actions missing from the policy-map test.

Test

  • A probe calls every read route as the lowest-privilege role, once through the gateway and once directly against the service, and compares the status codes.
  • A policy-map test lists every action of every controller with its expected policy.

CS-AUZ-001, CS-SEC-002, CS-SEC-003

CS-DP-AUZ-003: Action-level authorize cannot loosen a class-level policy

Severity: major · Applies to: service, template · Enforced by: manual · Status: active

Symptom

A route meant to open to one more role still answers 403, while a unit test that reads the attributes passes.

Cause

ASP.NET Core requires every [Authorize] on the endpoint. An action-level [Authorize] adds a requirement to the class-level one; only [AllowAnonymous] overrides, and it drops authentication as well. A test that reads attributes cannot see the effective policy.

Check

  • A class-level policy combined with an action-level attribute that is meant to widen access.
  • Tests that read one attribute with GetCustomAttribute<AuthorizeAttribute>() instead of all of them.

Test

Call the route with real tokens for the newly allowed role and for a refused role, and assert 200 and 403.

CS-AUZ-002, CS-AUZ-001

CS-DP-AUZ-004: No challenge scheme turns a 401 into a 500

Severity: major · Applies to: service, template · Enforced by: manual (target: ENF-040) · Status: active

Symptom

An anonymous call to a protected endpoint answers 500 instead of 401.

Cause

JWT bearer authentication is switched off when no authority is configured, while authorization stays on. A failed authenticated-user requirement has no scheme to challenge with, and the framework throws.

Check

Authentication schemes that configuration can switch off while authorization policies stay registered.

Test

With the default configuration, an anonymous request to a protected endpoint asserts 401.

CS-AUZ-004

Tokens, claims and secrets

CS-DP-AUZ-005: Claim added without a token destination never reaches the token

Severity: major · Applies to: service · Enforced by: manual · Status: active

Symptom

The authorization server adds roles or custom claims, but the APIs never see them.

Cause

Each claim needs a destination (access token, identity token or both). Without one it is dropped when the token is issued. AddClaim(type, value, issuer) takes an issuer as its third argument, so passing a destination there compiles and does nothing.

Check

  • New claims in the authorization server are listed in the destinations map.
  • No positional argument is mistaken for a destination.

Test

An acceptance test requests a real token, decodes it and asserts each expected claim in the access token and the identity token.

CS-AUZ-010, CS-SEC-004

CS-DP-AUZ-006: Background job's HTTP client has no request to propagate from

Severity: major · Applies to: service, template · Enforced by: manual · Status: active

Symptom

A scheduled job's call to another service throws "HeaderPropagationValues.Headers property has not been initialized" or is refused with 401. Unit tests pass because they replace the client.

Cause

The named client uses header propagation or forwards the caller's bearer token. Both need an incoming request and a user, and a job has neither.

Check

A job, timer, hosted service or grain reminder that resolves a named client configured with header propagation or a token-forwarding handler.

Test

A unit test applies the client's handler builder actions and asserts that the service-token handler is present and the propagation handler is not.

CS-AUZ-007, CS-CFG-006

CS-DP-AUZ-007: Fallback to a committed secret

Severity: blocker · Applies to: service, template · Enforced by: manual · Status: active

Symptom

A deployment that does not supply a secret starts anyway and uses a known value committed in base settings or in code.

Cause

The code reads setting ?? "literal", or the base settings file holds a real value. ?? does not catch an empty string, so a blank setting sends an empty secret.

Check

  • ?? or default-value fallbacks on secret settings.
  • Non-empty secrets in base settings files, in code or in code comments.

Test

A start-up test runs with the setting missing and with it blank, and asserts that start-up fails instead of using a default.

CS-SEC-001, CS-CFG-001, CS-CFG-005

CS-DP-AUZ-008: Governance policy names a tool by its C# method name

Severity: minor · Applies to: service · Enforced by: manual · Status: active

Symptom

An MCP tool that the policy allows is blocked by the default-deny rule.

Cause

The MCP SDK exposes a tool under a snake_case name unless a name is set explicitly, and the policy names the PascalCase C# method.

Check

Tool names in policy conditions that do not match the names the server exposes.

Test

An acceptance test calls each allowed tool through the governed server and asserts that it runs.

CS-AUZ-013

Record scope

CS-DP-AUZ-009: Record scope arrives as a request filter, and absent means unrestricted

Severity: blocker · Applies to: service, template · Enforced by: manual · Status: active

Symptom

A direct URL, an API call, or a call without an optional header reads every row. The screens look right because the client always sends the filter.

Cause

The client or the gateway computes the row scope and passes it as query fields. The service never derives it from the token, and an empty scope set or a missing header means "no restriction".

Check

  • Scope fields on request contracts.
  • Middleware that calls the next handler when a scoping header is absent.
  • Empty scope collections with no "no access" sentinel.

Test

For each list and detail route, call as a bounded user with no header, with a foreign id and with zero grants, and assert 404 or an empty result. Pair each with a positive read by an entitled user.

CS-AUZ-005, CS-AUZ-006, CS-AUZ-004

CS-DP-AUZ-010: Privilege flag in the request body is trusted downstream

Severity: blocker · Applies to: service, template · Enforced by: manual · Status: active

Symptom

Any caller that reaches the service directly can send CallerMayApprove: true and perform a privileged change.

Cause

The gateway derives the capability from the token and forwards it in the request body. The service maps the field by name and trusts it.

Check

Boolean capability fields such as CallerMay*, Is*Allowed or Can* on service request contracts that the mapping does not ignore.

Test

  • A mapping test fails when the body flag reaches the domain input.
  • A controller test asserts that the flag is set from the principal.

CS-API-009, CS-AUZ-005

CS-DP-AUZ-011: Null-tolerant scope predicate fails open

Severity: blocker · Applies to: service · Enforced by: manual · Status: active

Symptom

A user bound to one unit sees records of another unit, in lists and in exported files.

Cause

The scope predicate admits rows whose unit is null, as in unit == null || units.Contains(unit), and services differ in how they treat null.

Check

A null disjunct inside a scope or readable-by predicate.

Test

Read every list and export as two users with disjoint units at the same level, and assert that the values (not only the row counts) do not overlap.

CS-AUZ-006, CS-AUZ-009

CS-DP-AUZ-012: Missing caller id coalesced to an empty Guid matches an unowned record

Severity: blocker · Applies to: service · Enforced by: manual · Status: active

Symptom

A caller with no user id is treated as the owner of every record whose owner column is empty.

Cause

caller.UserId ?? Guid.Empty compared with an empty stored owner id is equal, so the ownership check fails open.

Check

Ownership or self-scope comparisons that coalesce a nullable id to Guid.Empty instead of calling one ownership helper that rejects empty ids on both sides.

Test

A scope test with a caller that has no user id and an order with no owner asserts a refusal.

CS-AUZ-014, CS-AUZ-006, CS-VAL-003

CS-DP-AUZ-013: Self-scope filter compares two different id spaces

Severity: major · Applies to: service · Enforced by: manual · Status: active

Symptom

A "mine" filter returns nothing, with no error, for every user who is not an administrator.

Cause

A person has a login id and a separate profile id. The records store one, and the filter passes the other. Administrators skip the filter, so tests that run only as an administrator never see it.

Check

A self-scope query that passes a profile id where the stored column holds the login id, or the reverse.

Test

Open the "mine" view as a user who is not an administrator and owns a seeded record, and assert that the record appears.

CS-AUZ-008

CS-DP-AUZ-014: Id from the wrong id space resolves a name but fails the scope

Severity: major · Applies to: service · Enforced by: manual · Status: active

Symptom

A list shows records to unrestricted roles and none to the restricted users who own them, while the owner names display correctly.

Cause

Two id spaces exist, such as user id and person id. The scope compares in one, and a seed or a write path stores the other. The name resolver accepts both, so the display looks right.

Check

Columns or seed data that store an id from a different space than the scope predicate compares, especially where the column name suggests the other space.

Test

Read the same list as an unrestricted and a restricted caller and compare the values, including every table the seed writes.

CS-AUZ-008, CS-AUZ-005

CS-DP-AUZ-015: Inner query is rebuilt without the scope field

Severity: major · Applies to: service · Enforced by: manual · Status: active

Symptom

An export returns rows that the same user cannot see on screen.

Cause

The operation builds its own copy of the query input, for the first page and again in the paging loop. It copies the older fields but not the newly added scope field.

Check

When a scope field is added to an input type, every place that constructs that type, not only the places that read it.

Test

Export as a bounded user and assert that the exported row count equals the bounded on-screen total.

CS-AUZ-009

CS-DP-AUZ-016: Parent-level scope admits out-of-scope children

Severity: major · Applies to: service · Enforced by: manual · Status: active

Symptom

A manager who filters to a unit they do not hold still sees most of its rows. Reports that walk child rows include children outside the manager's scope.

Cause

The scope keeps a parent, such as a customer, when any of its children, such as one of its orders, is in scope. The operator's filter is ANDed after the scope instead of intersected with it, and child walks do not test each child again.

Check

  • Parent-level scope predicates combined with child filters or child walks.
  • Operator filters that are not intersected with the caller's grants.

Test

Seed a customer with one order in scope and one out of scope. Assert that child reports include only the first, and that a filter to the foreign unit returns nothing.

CS-AUZ-009

Responses and degraded features

CS-DP-AUZ-017: Deliberately open read route returns the full record

Severity: major · Applies to: service, template · Enforced by: manual · Status: active

Symptom

A route left open so that pickers can resolve names returns the same personal fields as the administrator's response.

Cause

The route was opened for one purpose, and its response was never narrowed to that purpose.

Check

For each open read route, compare the returned fields with the stated reason the route is open.

Test

As a low-privilege caller, assert that the response omits sensitive fields on every row except the caller's own.

CS-AUZ-011, CS-SEC-005

CS-DP-AUZ-018: Optional enrichment swallows a downstream 403

Severity: major · Applies to: service, blazor · Enforced by: manual · Status: active

Symptom

Display names show as raw ids for every role except administrators.

Cause

The enrichment calls a permission-gated endpoint in another service. The 403 is caught as "best-effort decoration", so the feature degrades silently for exactly the roles that use it.

Check

A catch-all around an enrichment or overlay call to a permission-gated endpoint, with a fallback that is not logged.

Test

An acceptance test of the enriched view, signed in as the least-privileged role that uses it, asserts the resolved names.

CS-AUZ-012, CS-ERR-001, CS-AUZ-007