api-rbac-test
Skill329 starsChanged 6 days agoMIT-0View on GitHub
Use when verifying API authorization (Cognito groups and configuration-version scope) with make api-test or make api-test-static, or when adding a new API operation.
In this repository42 other files it gives its agents.
- .claude/rules/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-modelSkill
- agent-capability-reviewSkill
- backend-lambdaSkill
- code-reviewSkill
- create-hf-dataset-prSkill
- curate-security-resultsSkill
- cut-release-changelogSkill
- dependabot-prsSkill
- documentationSkill
- extraction-pipelineSkill
- fix-single-issueSkill
- frontend-uiSkill
- full-test-batterySkill
- infrastructureSkill
- live-auth-checksSkill
- live-eval-and-costSkill
- prepare-changelogSkill
- prep-develop-for-releaseSkill
- product-demoSkill
- pr-review-ciSkill
- pr-reviewSkill
- releaseSkill
- release-validationSkill
- remove-classification-flat-keysSkill
- repo-quality-reviewSkill
- run-benchmarksSkill
- run-stack-testsSkill
- srt-security-scanSkill
- sync-pii-anonymizerSkill
- testing-qaSkill
- test-upgradeSkill
- transform-deploy-testSkill
- ui-i18nSkill
- update-solution-profileSkill
- ux-test-ciSkill
- ux-testSkill
- ux-test-stories-ciSkill
- ux-test-storiesSkill
- work-the-backlog-hazardsSkill
- work-the-backlogSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 3 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill to verify that every UI API operation is correctly protected by (a) its required Cognito group(s) and (b) config-version …
- Very specific: line 105
The response says which layer produced it: every 403 carries errors[0].authzControl — api-group-floor, resource, resolver or …
- Very specific: line 178
Use residual_gap when part of a route's authorization is genuinely impossible on the transport but the rest must still be enforced.
- Very specific: line 193
MUST add an entry to scripts/api_rbac_expectations.yaml (and the schema), then regenerate the manifest.
- Very specific: line 248
Test users get a random per-run password (printed when NO_TEARDOWN or --setup-only keeps them alive).
- Very specific: line 338
Every check records one of these.
- Very specific: line 394
Then: which control refused?: Read authzControl in the report's
- Very specific: line 400
In-band denial not recognized?: If the op denies via {success:false, error:{type:Unauthorized}} (200), confirm classify()/_denied() treat …
- Very specific: line 403
Expectation wrong?: Read the enforced_in file and confirm the actual server-side group set.
- Very specific: line 408
Allowed role denied on a NEW op?: Look for Denied <field>: no required-groups entry in the dispatcher log — the operation's groups were …
- Distinctive: line 413
Real leak / fail-open?: If a scoped/lower-privilege caller is ALLOWED, check the actual group gate.
- Distinctive: line 428
Add the resolver's server-side group/scope check.
- Very specific: line 429
Add the @aws_cognito_user_pools directive in schema.graphql.
- Very specific: line 453
If the op is also reachable off the REST route (a Function URL route, a direct lambda:InvokeFunction path), put the group check in the …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API RBAC Test — GenAI IDP Accelerator
Use this skill to verify that every UI API operation is correctly protected by (a) its required Cognito group(s) and (b) config-version scope, using two complementary layers that share one source of truth:
- Static scan (
make api-test-static) — no AWS, CI-safe. Cross-checks the op universe, the schema directives, and the expectations file for drift and missing server-side checks. - Dynamic tests (
make api-test STACK_NAME=<stack>) — spins up temporary Cognito users (one per group + a config-version-scoped Author + a second independent user for IDOR), calls every op as every role + unauthenticated + with malformed tokens against a deployed stack, PLUS the mandatory security-focused suites below, and writes an auditable report.
The dynamic harness has already caught a real, shipping vulnerability (config-version scope silently failing open because a resolver was missing a
dynamodb:QueryIAM grant). Treat a hard fail as real until proven otherwise.
⚠️ "Every operation" is true of the group check, not of the scope check. The dynamic scope suite calls, with the scoped token,
getConfigVersion,getConfigVersionsand the three discovery operations inSCOPED_DISCOVERY_CELLS(startMultiDocDiscovery,uploadMultiDocDiscoveryZip,uploadDiscoveryDocument), each naming the out-of-scope profile and each built so that no job starts whatever the stack answers. No other scope-enforcing operation is exercised live. Ops markedskip_allowed:in the expectations file are called only in their denied role, because an allowed-role call would start real work —sendChatDocumentMessagestarts a chat turn — so their scope enforcement is not reached here and is covered by that component's own unit suite instead. The static scan's S4 reads the code each operation can reach: it asserts that code refers to the caller's config-version scope, and, for ascope_filteredoperation, that it applies a per-item scope predicate bottoming out atscope_allowsto what it returns, following calls intoidp_common. It is a structural check, not dataflow: a broken scope lookup still passes it. Neither layer would have caught issue #970, where the lookup named a DynamoDB index no template declares.S10 is what makes an operation declare a scope in the first place: any operation whose arguments name a profile, a stored object or a session (read from the words of the argument name) must carry
scope_checked,scope_filtered,document_scope_checked,testset_checkedorownership(by argument kind), be callable only by Admin/IAM, or have aknown_gapor aSCOPE_KEYED_ARGUMENT_EXEMPTentry. Adding an operation that takesconfigVersion,objectKeyorsessionId? Declare its scope, or S10 fails.
Mandatory security-focused test cases (AppSec checklist)
make api-test covers the AppSec "Minimum Mandatory Security Focused Test Cases
for APIs" checklist. Mapping (suite → checklist item), implemented in
scripts/api_security_cases.py:
| # | Checklist item | Where |
| 1 | Unauthenticated access denied | run_group_matrix (unauth cell) + run_token_negatives |
| 2 / 2.2 | Authorization matrix, negative + positive; role X not authorized for API Y | run_group_matrix (every op × every role) |
| 2.1 | IDOR — User A's data unreachable by User B | run_idor_suite (chat session ownership); run_inbox_idor_suite (Inbox ownership: another user's message id is not listed, marked or deleted) |
| 2.1 | Caller-supplied resource reference bounded to the deployment and the caller's config scope | run_caller_supplied_ref_suite — getStepFunctionExecution must refuse an ARN naming another state machine, still serve this deployment's own, and refuse a config-scoped caller an out-of-scope execution. Needs a processed document, else all three SKIP (see below) |
| 2.3 | Tokens rejected after expiry | run_token_lifecycle_suite (+ token negatives); real-expiry wait via IDP_SECTEST_WAIT_EXPIRY=<seconds> |
| 2.4 | Tokens revoked after logout | run_token_lifecycle_suite — global sign-out then re-test; stateless-JWT reuse is a documented gap (GAP-SEC-LOGOUT, WARN — see AUTH.T10) |
| 2.5 | Deleted resources no longer accessible | run_deleted_resource_suite (config version create→delete→read-gone) |
| 3 | Input validation (invalid input rejected) | run_input_validation_suite — only a clean 4xx is ever a PASS. By default a 5xx or a silent 200 is recorded against GAP-SEC-INPUT, i.e. a WARN: visible, not blocking, not a pass. IDP_SECTEST_STRICT_INPUT=true drops the gap so the same result is a hard failure |
| 4 | TLS 1.0/1.1/HTTP refused, TLS 1.2+ accepted | run_tls_suite (raw-socket protocol probes) |
Notes:
- The AppSec engineer may request additional tests per use case — this is the floor, not the ceiling.
- Suites that need conditions not present are recorded as SKIP, never silent
omissions (e.g. expiry without
IDP_SECTEST_WAIT_EXPIRY). A SKIP is not a pass — see the outcome vocabulary below. - Threat-model coverage: AUTH.T09 (IDOR), AUTH.T10 (token lifecycle), AUTH.T11
(TLS), AUTH.T13 (IdP group-claim provenance) in
security/threat-modeling/feature-threats/rbac-authentication.md. - Process a document on the stack before running this, or the three
SEC-2.1-CALLER-SUPPLIED-REFchecks record SKIP. They need a real execution ARN, which the harness resolves vialistDocuments->getDocument— the list projection does not carryWorkflowExecutionArn.apply_dynamic_argsalso substitutes that ARN intogetStepFunctionExecution's matrix args, because the placeholder ARN in the expectations file is (correctly) refused now, and every one of the four roles the matrix drives is an allowed role for that op (it isANY_GROUP), so the matrix reads any refusal as a failure. - The Cognito pre-token IdP group-mapping trigger is NOT covered here — it is not
an API operation. See
.claude/skills/live-auth-checks/SKILL.md.
The architecture you are testing (read this first)
- Single route: the UI calls
POST /op/{field}on an API Gateway REST API (logical idHttpApiDispatcher). The Cognito authorizer only authenticates (401 for missing/bad token); it does no group checks. - The dispatcher denies by default (
http_api_dispatcher/authz.py): before routing, it checks the caller's groups (from the verified JWT claim, never the body) againstapi_rbac_manifest.json, and a field with no entry there is 403 — unmapped means denied. The manifest is generated fromscripts/api_rbac_expectations.yamlbyscripts/sdlc/generate_api_rbac_manifest.py; it fails closed if unreadable. So an operation whose groups were never declared is closed, not open. - Per-resolver RBAC: each resolver Lambda also reads
identity.claims['cognito:groups']and raisesPermissionError→ the dispatcher maps that to HTTP 403 witherrorType: "Unauthorized". This layer stays: the dispatcher enforces the field-level floor, the resolver enforces per-object scope (config version, test set, ownership) on top of it. The response says which layer produced it: every 403 carrieserrors[0].authzControl—api-group-floor,resource,resolverorunverified-identity. See "A 403 is two different verdicts" below; the logs (Denied <field>: ...inauthz.py, the resolver's own message) are the second stop, not the first. - Config-version scope denials are IN-BAND: the configuration & sync
resolvers return
{success:false, error:{type:"Unauthorized"}}with HTTP 200 (NOT a 403). The harness treats an in-bandUnauthorizedas a denial. - 5 groups (precedence): Admin(0) > Author(1) > Reviewer(2) > Annotator(3) >
Viewer(4), defined in
template.yaml. That template is where the group vocabulary lives —generate_api_rbac_manifest.pyreads it to resolveANY_GROUPand to reject a group name noAWS::Cognito::UserPoolGroupcreates. ⚠️make api-test's live matrix drives four of them (ROLESinscripts/test_api_rbac.py) —Annotatoris not one — and it creates no groupless user. 28 operations are declaredANY_GROUPtoday, and "denied to a caller in no group" — the whole point of that policy — is asserted offline only, intest_http_api_dispatcher_authz.py. The mechanism is live-proven: step 4 of the chain measured in #1033 saw a real groupless token get 403 with the group-floor message fromgetFileContentsandgetFilePresignedUrl. What is missing is that assertion as a repeatable gate over every operation — tracked in #1065. @aws_auth(cognito_groups)is SILENTLY IGNORED on this multi-auth API (it also allows AWS_IAM). Only@aws_cognito_user_pools(...)directives and server-side checks are real. Server-side enforcement is the source of truth; the schema directive is defense-in-depth.- IAM_ONLY ops (
updateAgentJobStatus,updateDiscoveryJobStatus) must reject every Cognito caller.
The REST route is NOT the only entry path (Function URLs — S6..S9)
Chat streaming is served by a Lambda Function URL (AuthType=AWS_IAM,
InvokeMode=RESPONSE_STREAM; ChatStreamProcessorUrl in template.yaml) whose
FastAPI app (src/lambda/chat_stream_processor/app.py) drives the chat
processors directly — no dispatcher, no resolver. Consequences:
- An op reachable both ways must enforce its group check in the component that
does the work (e.g.
src/lambda/agent_chat_processor/index.py), not only in the resolver in front of it. A resolver-only check is enforced on one path. - That transport authenticates but carries no
cognito:groups:requestContext.authorizer.iam.cognitoIdentityis documented as unused by Function URLs, and the assumed-role session name under the Identity Pool enhanced flow is a pool-wide constant. So there is nothing verified to gate on there; the residual difference is GAP-07 / AUTH.T14. - A request-body
callerSubis a fallback only — the transport-verified principal wins, and a body value that contradicts it is refused (403), not silently preferred. Both routes go through one helper so they cannot drift. It is nonetheless the effective identity on this transport, because the verified value is that pool-wide constant, so it must not be used as an authorization key. Both processors readidentityfor that instead, and this route can only report it asNone. allowedConfigVersionsis therefore not enforced onPOST /chat/document. The processor resolves the caller from verified claims and denies a turn whose scope it cannot evaluate; with no claims to resolve from, it stands the check down and logs that it did so once per turn rather than appearing to have consulted the UsersTable. The REST path through the dispatcher does enforce it. Both halves of GAP-07 close when this endpoint verifies a Cognito ID token — and the claims it then returns must includeemail, which is the only identifier that joins a Cognito principal to a UsersTable row.
Declare every Function URL and route in the function_url_endpoints: section
of scripts/api_rbac_expectations.yaml. The scanner's Function-URL checks:
| Check | Fails when |
| S6 | a AWS::Lambda::Url in template.yaml, or a route in its handler, is not declared (or a declared route no longer exists) |
| S7 | a route reads a client-supplied identity before the transport-verified one |
| S8 | no function in the handler package refuses a contradicting client identity (names the verified value, compares !=, and rejects) |
| S9 | the handler named by enforced_in has no group check for the route's groups, or its group list disagrees with the equivalent_op's |
⚠️ known_gap: downgrades a finding to WARN; residual_gap: does not — it
records the gap in the register for auditability while leaving the checks armed.
Use residual_gap when part of a route's authorization is genuinely impossible
on the transport but the rest must still be enforced. scripts/sdlc/tests/test_scan_api_rbac_function_urls.py
pins S7/S8 against snippets of both shapes, so the rules cannot go inert once the
live repo only exercises the passing side.
Three sources of truth that MUST NOT drift
| Source | Where |
| Op universe | FIELD_FUNCTION_MAP (SSM /<stack>/http-api/field-function-map) ∪ ddb_direct._HANDLED ∪ FIELD_ALIASES in the dispatcher |
| Schema groups | @aws_cognito_user_pools(cognito_groups:[...]) in nested/api-resolvers/src/api/schema.graphql |
| Expectations | scripts/api_rbac_expectations.yaml ← edit this when you add an op |
| Runtime manifest | http_api_dispatcher/api_rbac_manifest.json — generated from the expectations file; never hand-edit |
The static scan fails if these diverge. When you add an API operation you
MUST add an entry to scripts/api_rbac_expectations.yaml (and the schema), then
regenerate the manifest.
Files
scripts/api_rbac_expectations.yaml— single source of truth (189 ops + gap register). Entry schema is documented at the top of the file.scripts/sdlc/scan_api_rbac.py— static scanner (--strictfails on known gaps, use to confirm a gap was fixed;--json PATHfor machine output).scripts/sdlc/generate_api_rbac_manifest.py— writes the dispatcher's required-groups manifest from the expectations file (--check= drift guard, run bymake api-test-static).nested/api-resolvers/src/lambda/http_api_dispatcher/authz.py— the default-deny enforcement point.scripts/test_api_rbac.py— dynamic harness.inconclusive()/classify()/_record()/hard_failures()are where an outcome becomes a verdict;scripts/sdlc/tests/test_api_rbac_verdicts.pypins them offline, including a run in which every operation times out (which must not be green).scripts/api_security_cases.py— the mandatory suites._inconclusive_response()and_tls_probe()are the equivalents there;_tls_probeTCP-connects separately from the handshake so an unreachable host cannot read as "the server refused this protocol".lib/idp_common_pkg/tests/unit/test_http_api_dispatcher_authz.py— manifest parity (enumerated fromFIELD_ALIASES,ddb_direct._HANDLEDand the template's field→function map) plus the deny paths.
Environment (gotchas)
# ALL AWS calls target the deployment account — use AWS_PROFILE=default,
# NOT the sandbox's ambient creds (which may point elsewhere). Confirm first:
AWS_PROFILE=default aws sts get-caller-identity
# The harness prefers AWS CLI v2 at /usr/local/bin/aws (the conda `aws` on PATH
# is v1 and lacks some flags). It handles this internally via AWS_BIN.Workflow
# 1. Static scan — run on every change to an API op / schema / expectations.
make api-test-static # exit 0 with WARNs for known gaps
make api-test-static STRICT=1 # exit 1 on any known gap (verify a fix)
# 2. Dynamic tests against a deployed stack (needs deploy-account creds).
AWS_PROFILE=default make api-test STACK_NAME=IDP1 REGION=us-west-2
# -> writes ./api-test-results/<stack>-<ts>/{report.md,report.json,meta.json}
# REPORT_DIR=<dir> override output location
# NO_TEARDOWN=1 keep the temp Cognito users (debugging; rerun teardown
# later with: python3 scripts/test_api_rbac.py \
# --stack-name <s> --region <r> --teardown-only)The harness always tears down its temp users and restores the app client's original auth flows on exit (even NO_TEARDOWN only skips the user delete). Test users get a random per-run password (printed when NO_TEARDOWN or --setup-only keeps them alive). Exit code is non-zero only on hard fails (a real leak) — known gaps are WARNs.
A 403 is two different verdicts — read authzControl first
⚠️ 403/Unauthorized is the response shape for two controls that answer
opposite questions, and conflating them is the worst mistake available to this
layer:
| The response means | Control | authzControl |
| "this caller's groups do not admit this operation" | the field-level floor in authz.py — also an undeclared field and an IAM_ONLY op | api-group-floor |
| "this caller's groups were fine and the object they named was refused" | a per-object control in a resolver: the bucket allow-list, the write-once key rule, chat-session ownership, the test-set selection scope, the per-document config-profile scope on object bytes | resource |
| the resolver refused and did not say which control it was — every resolver's own group check is here | a resolver | resolver |
an invocation asserted its own identity | normalize_event | unverified-identity |
The matrix asserts the first and cannot avoid provoking the second, because it
drives every operation with deliberately bogus arguments. With one indistinguishable
shape for both, eight cells of one run reported three per-object controls working
correctly as group-authorization failures, and the curated snapshot published
RBAC dynamic — FAIL ❌ (8 hard failures) for a release whose authorization was fine
(#1308).
Establishing that those eight were not a regression took a by-hand comparison
against a prior run that happened to still be on disk.
How the harness scores it (classify(), pinned offline in
scripts/sdlc/tests/test_api_rbac_refusal_attribution.py):
| Cell | api-group-floor, resolver, or no label | resource |
| an allowed role was refused | FAIL — the shape a real regression takes | ERROR 🛑 — the floor admitted the caller and a per-object control refused the object, so the cell did not measure the group check. Not a pass, still blocking, and it names the control |
| a disallowed role was refused | PASS | FAIL — the floor runs before routing, so a caller it must refuse cannot reach a resolver; a resource label here means the floor did not refuse somebody it must |
⚠️ The remedy for an ERROR here is to fix the operation's ARGUMENT, not to
register a gap. Give the operation an argument the per-object control admits so
the group floor is what answers — the pattern getFileContents uses (an
in-allow-list bucket with a key that does not exist) and the one
autoDetectSections, addDocumentsToTestSetByKey and getChatMessages were given
(an empty required argument, which the resolver's own validation rejects before
it consults the control; that source ordering is pinned by
test_the_argument_guard_runs_before_the_per_object_control). Scoring it green, or
putting it in the gap register, turns a cell that measured nothing into a cell that
reports success — the worse half of the defect.
⚠️ An unlabelled refusal gets the STRICT verdict. Only an explicit resource
leaves the hard-failure branch, so a per-object control that forgets to declare
itself costs a visible failure rather than a silent pass. Declare one by raising
ResourceAccessDenied (idp_common.api_adapter; a PermissionError subclass,
recognised by class name across the invoke boundary, so a layerless resolver may
declare its own). Keep the Unauthorized message prefix.
⚠️ Declare it per BRANCH, and uniformly across the ones that decide about the
object. A control whose refusal sites split between the two labels tells the
caller which branch answered, and for an object-scoped control that is an existence
oracle: resource on "exists but out of your scope" beside resolver on "no such
object" is one bit per key, over objects entirely outside the caller's scope. So
convert every branch that decides about the object the caller named, including any
budget or cap whose refusal depends on which objects exist, and leave the branches
that are facts about the deployment or the principal unattributed — an
unevaluable scope, a throttled table, an unwired table name. resolver is the true
answer for those and the strict reading is what keeps a deployment fault in the row
an operator reads first. document_scope and key_scope in
get_file_contents_resolver are the worked example of the split (#1478), and
key_scope._assert_test_set_allowed is the counter-example: it folds the resolver's
own group check into the same exception as its per-object one, so it stays
unattributed — resource there would lose a group refusal, which is the one
misattribution direction that matters.
⚠️ object_scoped_roles: is not the way to cover a control keyed on
allowedConfigVersions. That key names a role the matrix drives, and every matrix
principal is unscoped, so a config-scope control is a no-op for all of them and the
cell fails as NOT REFUSED. Those belong in the config-version scope suite, where a
seeded scoped Author exists — run_document_bytes_scope_suite is the pattern: refuse
the scoped caller a real document's bytes, require resource on the refusal, and
assert an unrestricted Admin is not refused the same URI so the first arm cannot
pass on a deployment that refuses the object to everybody. "Not refused" rather than
"served" on purpose: a 400 File not found is the honest answer on a stack whose
input bucket has been swept, and requiring a 200 would fail there.
⚠️ An absent label is not the same as resolver. None means the deployment
did not say — a stack older than the field, the route's Cognito authorizer answering
401 ahead of the dispatcher, or an in-band {success:false,error:{type:
"Unauthorized"}} 200. Every row in report.json carries authz_control, including
passes, so a report whose column is empty throughout is one where this whole
distinction was inert and the verdicts are the pre-#1308 ones. Check that before
reading a run as having exercised it.
The five outcomes — a refusal and an inconclusive result are different
Every check records one of these. passed is True for exactly one of them.
| Outcome | Means | Exit code |
| PASS ✅ | the check ran and the API behaved as required | 0 |
| FAIL ❌ | the check ran and the API did not | non-zero |
| ERROR 🛑 | the check could not be run | non-zero |
| SKIP ⏭️ | a precondition for the check is absent | 0 |
| WARN ⚠️ | a FAIL or ERROR registered against a known_gap | 0 |
ERROR exists because this harness asserts refusals. Its positive arms can only
ask "was this NOT denied?", and a request that never completed is not denied either —
so a timeout, a dead connection, an empty body, a body that will not parse and a 5xx
all used to satisfy them. inconclusive() in scripts/test_api_rbac.py is the one
place that judgement is made; classify() consults it before any cell-specific rule,
so no cell can pass on a result that established nothing.
Two things follow that are easy to get wrong when adding a suite:
- A
known_gapdecides whether to block, not whether the check ran. A gapped ERROR is a WARN and still carriesinconclusive: true, so it appears in the report's "Could not be run" section.GAP-SEC-INCONCLUSIVE-5XXregisters the 5xx case, because a resolver refusal raised as a bareExceptionis all the dispatcher can map to 500, and this harness deliberately sends bogus arguments. Not-found refusals now answer 404 (errorType: "ResourceNotFound"); the gap entry inscripts/api_rbac_expectations.yamlis where what remains at 500 is listed. A timeout is not registered and is a hard failure. - A 5xx is inconclusive for a "was it refused?" assertion and conclusive for a
"does this body contain X?" one. The IDOR suite is the second kind — the body is
in hand and the marker is not in it — so it passes
treat_5xx=False. Everything else is the first kind.
GAP-SEC-INCONCLUSIVE-5XX is assigned from an observed response rather than declared
on an operation, so it declares assigned_by: in the register; the static scanner's
S0 orphan check then verifies the reference in that file instead of switching off.
Reading the report
meta.json— stack, account, git_sha, api_base, per-run totals (passed,failed,errored,skipped,hard_fail,gap_warn), request IDs.report.md— a Could not be run section first, then hard failures, known-gap warnings, and the full group matrix (op × role) with the marks above.- A finding is a hard fail only if it has no
known_gap; documented gaps (GAP-01..) surface as WARN so they stay visible without failing the gate. scripts/security/curate_results.pycarries the distinction into the published snapshot: a run with no hard failure but some check that could not be run is reported as PASS with reservations ⚠️, not PASS.
When a hard fail appears — triage order
Is it a failure at all, or a check that could not run? 🛑 rows are in the report's own section. A timeout or a dead connection is an environment problem; a 5xx is usually a resolver raising a bare
Exceptionfor a validation refusal (seeGAP-SEC-INCONCLUSIVE-5XX) and is fixed by giving that refusal aValueError, not by widening anything here.Then: which control refused? Read
authzControlin the report's Control column before anything else below.resourcemeans the group floor admitted the caller and a per-object control answered — not an RBAC regression, and the remedy is the operation's argument (see above).api-group-flooron an allowed role is the real thing. An empty column means this run could not attribute refusals at all, so every verdict in it is the pre-authzControlone.- In-band denial not recognized? If the op denies via
{success:false, error:{type:Unauthorized}}(200), confirmclassify()/_denied()treat in-bandUnauthorizedas denied. (Config & sync resolvers use this.) - Expectation wrong? Read the
enforced_infile and confirm the actual server-side group set. The code is the source of truth; fix the YAML. - Test input short-circuits? For mutations, auth is checked BEFORE the bogus id is used, so an allowed role legitimately gets 400 (not-found) — that's a pass, not a leak. A disallowed role must still get Unauthorized.
- Allowed role denied on a NEW op? Look for
Denied <field>: no required-groups entryin the dispatcher log — the operation's groups were never declared, so the floor denies everyone. Declare them and regenerate the manifest (see the checklist below); do not widen the manifest to make the symptom go away. - Real leak / fail-open? If a scoped/lower-privilege caller is ALLOWED, check
the actual group gate. On every REST operation the scope lookup fails closed —
resolve_allowed_config_versionsinidp_common.config_scoperaisesScopeLookupErrorfor a missing UsersTable, an absentemailclaim or any faileddynamodb:Query, and each REST consumer turns that into a refusal — so a missing IAM grant presents as a denial, not as an unrestricted caller. In the resolver's CloudWatch logs, look for "config-version scope lookup failed on EmailIndex" at ERROR. ⚠️ The chat-streaming transport is the exception and is not a REST operation: see GAP-07 and AUTH.T07's residuals. An empty page is still deliberately unrestricted (scoping is opt-in), so a caller with no UsersTable row legitimately sees everything: check the row exists before reading a broad result as a leak.
Adding a new API operation — checklist
- Add the resolver's server-side group/scope check.
- Add the
@aws_cognito_user_poolsdirective inschema.graphql. - Declare the operation's required groups in
scripts/api_rbac_expectations.yaml(mirror a similar op) — this is now the source the dispatcher enforces, not only what the tests expect. - Regenerate the dispatcher manifest:
python3 scripts/sdlc/generate_api_rbac_manifest.py, and commit the changednested/api-resolvers/src/lambda/http_api_dispatcher/api_rbac_manifest.json. - Route it. A new resolver Lambda gets one key in
HttpApiFieldFunctionMapParam(nested/api-resolvers/template.yaml); a field served by an existing Lambda goes inFIELD_ALIASES(http_api_dispatcher/index.py) instead. An unrouted field is default-denied.scripts/tests/test_http_api_field_map_size.pychecks that the map's resolved worst case still fits the 8,192-byte SSM Advanced-tier limit. - Regenerate the validation spec:
python3 scripts/sdlc/generate_api_validation_spec.py, and commit the changedhttp_api_dispatcher/api_validation_spec.json(the dispatcher's argument check). - Regenerate the UI types:
make codegenrewritessrc/ui/src/graphql/generated/; never hand-edit it. - Update the stated policy counts.
scripts/tests/test_api_policy_counts_in_docs.pyandscripts/tests/test_well_architected_doc.pycompare every page that states an operation or policy count against the expectations file; run them and fix the prose they name. make api-test-staticmust be clean (it runs the manifest drift check too), then runmake api-testlive.- If the op is also reachable off the REST route (a Function URL route, a
direct
lambda:InvokeFunctionpath), put the group check in the component that does the work and declare the route underfunction_url_endpoints:— otherwise S6 fails and the check covers only one path. The dispatcher's default deny does not help there: it gates the REST route only.
⚠️ Steps 3–4 are not optional bookkeeping. The dispatcher denies by default, so an operation with no manifest entry returns 403 for everyone — including Admin — no matter what its resolver allows. If a brand-new operation 403s, the fix is to declare its groups and regenerate (steps 3–4). Do not "fix" it by widening an existing entry, adding a bypass, or making an unmapped field fall through: unmapped-means-denied is the property this layer exists to provide, and the reason a forgotten check on a group-scoped operation is no longer an open endpoint. Declaring an operation
ANYto make a 403 go away is exactly the widening this warns against:ANYmeans the dispatcher checks authentication only, so a forgotten resolver check on anANYoperation is still reachable by any authenticated caller — including one in no group, which self-signup produces. 8 of the 189 declared operations areANY, each with a note in the expectations file saying why that is the intended answer for that operation, not for the section it sits in. In full:getMyProfile,listChatSessions,getLatestPublishedVersion,listFinetuningJobs,getFinetuningJob,listInstalledFeatures,listCatalogFeatures,checkFeatureEntitlement.
The four policies — pick the weakest one that is still correct
| Declare | Means | Use for |
[Admin, Author, ...] | one of those groups | anything only a subset of roles should do |
ANY_GROUP | any group template.yaml creates; a caller in no group is refused | operations every onboarded role legitimately needs, where "onboarded at all" is the real requirement — document content, anything that leads to it, and mutations |
ANY | authentication only | the caller's own profile or own records, public metadata, whole-deployment platform state |
IAM_ONLY | no Cognito caller at all | backend-written status updates |
⚠️ "Enumeration, so it discloses no content" is not a reason. It was the recorded
reason for listDocumentsDateHour, listDocumentsDateShard and
listDocumentVersions, and issue #1033 measured a caller in no group composing them
into a chain that ended in extracted personal data: an object key from an index
listing, then a run's section and page URIs plus a model-written description of the
contents, then the execution input. Ask what the payload leads to, not only what it
literally contains.
Three more things that pass as reasons and are not:
- A reason written for the set.
listDocumentsDateShardrecorded only "seelistDocumentsDateHour— same index-partition enumeration, same decision", andgetChatMessagesonly "seelistChatSessions— own-sessions-only ownership scope, same decision". Read for whether they hold broadly, both pass; read against the one operation carrying them, the second names a different mechanism (listChatSessionsuses a DynamoDB key condition on the caller's partition;getChatMessageslayers a separate ownership check that returns true when its table is unset). Write one member's worth of reason, every time. - A narrowing that stands down for exactly the caller in question. Two of the
three per-object narrowings are inert for a self-registered account:
resolve_allowed_config_versionsreturnsNone— deliberately unrestricted — for a caller no UsersTable row matches, and a caller in no group is not aReviewer. So "this op is scope-filtered" was never an argument about the groupless caller. - A reason about the wrong dict.
listFinetuningJobsisANYbecause its projection carries no document location, while the DynamoDB row it reads does. If the premise is computable, compute it:finetuning_jobs_resolver/test_projected_keys.pypins the key set, so adding one line cannot quietly change the policy's meaning.
⚠️ Do not spell ANY_GROUP out as the five group names. The sentinel is
resolved against the AWS::Cognito::UserPoolGroup resources in template.yaml by
generate_api_rbac_manifest.py on every build, so a sixth group is covered
automatically; five names written per operation would silently stop covering it —
the "fix applied to the instance and not the class" defect this repo keeps hitting.
The schema.graphql directive does have to name them all, because GraphQL cannot
express "any group"; check S2 fails until it does, which is the intended way to
be told a group was added. Check S0 rejects an unrecognised sentinel outright,
because the scanner alone would not notice one — S2 would compare a set of its
characters and S3 would accept a resolver with no check at all. (make
api-test-static would still fail, one command later, on the generator's --check;
S0 is what makes the scanner sound on its own and what covers a Function-URL route
policy, which the generator never reads.) authz.py never sees ANY_GROUP: it is
expanded before the manifest is written, and an unexpanded one there means a broken
build and is treated as one (deny-all).
⚠️ A group floor is not the whole control, even where it now reaches the bytes.
It gates the REST API. The Identity Pool attaches one authenticated role with no
role mappings, so whatever that role grants is held by every signed-in user, group
or no group — which is why it grants nothing on the Input and Output buckets and
no s3:GetObject or s3:ListBucket on any bucket, and why the UI asks
getFileContents / getFilePresignedUrl / getFilePresignedUrls for every document
byte. For the document read path the floor and the asset therefore coincide. What the
floor still does not supply is per-document authorization: document_scope matches
the owning document's ConfigVersion against the caller's allowedConfigVersions,
which refuses a scoped caller a document outside their profiles and refuses an
unscoped one nothing, scoping being opt-in per user. So do not describe an
ANY_GROUP operation as making document content unreachable; it makes that
operation unreachable, and on this path that is as far as the floor goes. See the
residuals in docs/rbac.md and AUTH.T03.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

