Commit Graph
145 Commits
Author SHA1 Message Date
Priamo Germosen 078931597e fix(iam): check five more services on the resources their requests name (#6927)
Under IAM enforcement, Budgets, Cost and Usage Reports, Service Quotas,
Textract and Translate requests were checked on `*`, so a grant scoped
to a budget, a report definition, a quota, an adapter or a terminology
was refused, and a deny scoped to one never applied.

The generated table of the resources requests name now reads them, 103
operations, from AWS's Service Reference and botocore as it reads the
first three batches: their namespaces move from the generator's
NOT_COVERED to NAMESPACES and the table is regenerated, nothing in it
edited by hand; 717 operations over 17 namespaces. Each resource
type's ARN format is the one Floci mints or reads: `budget/<name>` with
no Region (Budgets' tag handler parses it), `definition/<name>`, and
`<service code>/<quota code>` (Service Quotas' QuotaArn).

Three corrections, each with its reason: CreateBudget and UpdateBudget
name their budget by Budget.BudgetName and NewBudget.BudgetName, and
PutReportDefinition its report by ReportDefinition.ReportName, inside a
structure the rule does not read. Without them UpdateBudget and
PutReportDefinition were checked only on their BillingViewArn, a
billing view's ARN by botocore's pattern, so a caller allowed on one
budget or report could give its ARN there and name another.

Verified Permissions minted a policy store's ARN with a Region, where
AWS gives none: its CreatePolicyStore example answers
arn:aws:verifiedpermissions::123456789012:policy-store/PSEXAMPLEabcdefg111111,
the Service Reference's format alike. It now mints it without one, in
the Region's partition.

Not read yet, each with its reason in NOT_COVERED: Verified
Permissions, whose policyStoreId may name a store by its alias, which
AWS authorizes as the action on the store the alias points to and
GetPolicyStoreAlias on the alias, and whose aliasName carries the
`policy-store-alias/` its format already gives; Auto Scaling, whose
group and launch configuration ARNs Floci mints without AWS's id
(`autoScalingGroup:<name>` for
`autoScalingGroup:<id>:autoScalingGroupName/<name>`), which ECS reads
back; SWF, whose domain format the Service Reference gives no Region
while the SWF Developer Guide gives one; and CloudHSM, whose formats
end in names while its requests give ids.
2026-10-29 07:54:58 -05:00
TATSUNO “Taz” Yasuhiro 385ffcfdd0 feat(lambdaweb): set the WebFunctionAuthType condition keys on endpoint routes (#6893) 2026-10-29 00:54:49 -04:00
lex00 5a84d08383 fix(iam): read iam:PermissionsBoundary from the stored role or user an action names (#6897)
On the 15 actions where the Service Reference lists iam:PermissionsBoundary and the request carries no boundary, such as AttachRolePolicy, PutUserPolicy and GetRole, the key is the boundary stored on the role or user named by RoleName or UserName. The generator writes these pairs to a fromTarget section, and IamConditionContextResolver looks the boundary up through IamService. A role or user without one carries no value for the key.
2026-10-29 00:07:50 -04:00
Priamo Germosen 407ac4e210 fix(iam): check CodeBuild and Kinesis Data Analytics on the resources their requests name (#6884)
Under IAM enforcement, CodeBuild and Kinesis Data Analytics (Amazon
Managed Service for Apache Flink) requests were checked on `*`, so a
grant scoped to a project, a report group or an application was
refused, and a deny scoped to one never applied.

The generated table of the resources requests name now reads them, 92
operations, from AWS's Service Reference and botocore as it reads the
first two batches: their namespaces move from the generator's
NOT_COVERED to NAMESPACES and the table is regenerated, nothing in it
edited by hand; 614 operations over 12 namespaces. Each resource type's
ARN format is the one Floci's handler mints, which the tests check
against the ARN each create returns: `project/<name>`,
`report-group/<name>`, `build/<project>:<number>` and
`application/<name>`.

Kinesis Data Analytics v1, the KinesisAnalytics_20150814 target of SQL
applications, is not read: Floci serves v2 only, and v1's operations
share v2's names with other members. It joins EventBridge V2 in the
generator's CLIENTS_NOT_READ, with its reason.

CodeBuild authorizes a build on its project: the CodeBuild User
Guide's permissions reference gives BatchGetBuilds, StopBuild,
RetryBuild and BatchDeleteBuilds the resource project/project-name.
Their requests name builds by id, which is `<project>:<id>` (its
CODEBUILD_BUILD_ID example is codebuild-demo-project:b1e6661e-...), so
four corrections read the project from the id up to its `:`. For them
the table may read a member filling a variable up to a character
`before`, as it already read an ARN member, in the generator, the
loader and the reader. Without them a policy granting StartBuild and
BatchGetBuilds on a project, as a pipeline's CodeBuild action role
has, allowed starting a build and refused watching it.

A list filling a type's one variable may mix names and ARNs: CodeBuild's
BatchGetProjects takes either for each of `names`. Each value that is
an ARN of the type now names that resource and the others are read as
names, where the reader took ARNs as given only when every value was
one, and otherwise put an ARN inside the name's format, refusing a
caller granted both projects.

Not in this change: a build batch, whose id the documents give no
format for and which Floci does not serve, and a report, named by a
report ARN where AWS checks its report group, stay on `*`.
2026-10-28 21:59:51 -05:00
Priamo Germosen 6606657434 fix(iam): name the member without the offending value in a validation error (#6811)
IAM's constraint violations read `Value at 'roleName' failed to satisfy
constraint: Member must have length greater than or equal to 1`, with no
value beside the member, which is where the recorded messages point: the two
IAM messages in LocalStack's AWS-validated snapshot from 2025-03-06, a 2026
capture of a `UserName` over 64 characters, and the messages the Identity
Center guide lists as the ones that commonly appear in CloudTrail events.
The two captures that carry the value are from 2019 and 2024, so they read
as stale rather than as wrong when written. STS keeps the value, which its
own 2024 capture carries and which is the same split this package already
records for pattern and enum messages.

It is a reading rather than a published rule, so `docs/services/iam.md` says
so and names the captures behind it. A direct capture that shows IAM
carrying the value again moves it back in one edit.

The form is chosen in one place. `SmithyValidationErrors.Violations` writes
each sentence once and carries both forms; the statics stay the quoting one,
so every other service answers exactly what it answered before.
`IamValidationErrors` names IAM's side of the split for the handler, the
service and the service-last-accessed check, and the shared Query walk is
loaded with the form of the service reading it, IAM without the value and
STS with it.

Two messages are left alone, neither being this question: a list checked as
a whole carries the list as its value, which is what AWS does elsewhere, and
a required member the request leaves out keeps `Value null at '<member>'`,
which no capture covers in either form.

Two checks built the message by hand rather than through a helper and so are
swept here too: `GenerateOrganizationsAccessReport` and the delegation
request operations each composed the quoted value inline, which is why
neither shows up in a search for the literal form. Their entity path and
request id now assert the whole message rather than only the error code,
since asserting the code alone is what let that drift sit unnoticed.

The vendored shapes file carries 52 operations now rather than 13, so the
members the paging wave opted in answer in the shorter form as well, and the
table sweep over every paged operation asserts it that way.
2026-10-28 19:51:54 -05:00
Priamo Germosen 096d336fab fix(iam): check five more services on the resources their requests name (#6810)
Under IAM enforcement, Amazon Data Firehose, Cognito identity pools,
Cloud Map, ACM and CodePipeline requests were checked on `*`, so a
grant scoped to a delivery stream, an identity pool, a namespace or a
service, a certificate, a pipeline or a webhook was refused, and a deny
scoped to one never applied.

The generated table of the resources requests name now reads them, 149
operations, from AWS's Service Reference and botocore as it reads the
first batch: their namespaces move from the generator's NOT_COVERED to
NAMESPACES, and the table is regenerated, nothing in it edited by hand.
Each resource type's ARN format is the one Floci's handler mints, which
the tests check against the ARN each create returns:

- `deliverystream/<name>`, `identitypool/<id>`, `namespace/<id>`,
  `service/<id>`, `certificate/<id>` and a pipeline's bare name.
- A CodePipeline webhook: AWS's is `webhook:<name>` (the Service
  Reference's format, and the CodePipeline User Guide's
  "arn:aws:codepipeline:eu-central-1:ACCOUNT_ID:webhook:my-webhook"),
  where Floci minted `webhook/<name>`; it now mints AWS's.

Corrections, each with its reason:

- StartPipelineExecution and GetPipelineState name their pipeline by a
  bare `name` ("The name of the pipeline to start"), which the rule
  reads only for an operation named after the type, as Step Functions'
  StartExecution names its execution, not its state machine, by `name`.
- CreatePipeline and UpdatePipeline name it by `pipeline.name`, and
  PutWebhook the webhook by `webhook.name` and the pipeline it connects
  to by `webhook.targetPipeline`. `pipeline.roleArn` holds the role
  CodePipeline assumes, an IAM role's ARN by botocore's pattern, and
  names no pipeline: read as one, a pipeline-shaped value there was the
  only resource an UpdatePipeline was checked on, so a grant on one
  pipeline let a request change another.
- CreateCustomActionType and DeleteCustomActionType are checked on
  `actiontype:Custom/<category>/<provider>/<version>`: a custom action
  type's owner is Custom, which the request does not give, and AWS's
  CreateCustomActionType example answers "owner": "Custom".
- Cloud Map's CreateService names its namespace by NamespaceId or,
  when it gives none or a JSON null, by DnsConfig.NamespaceId, which
  botocore keeps ("Use NamespaceId in Service instead") and the handler
  reads then; read by NamespaceId alone, a deny on the namespace did
  not hold for a request giving it in DnsConfig. A member given a JSON
  null now counts as absent in a resource's `when` and `unless`, as a
  handler reading it with asText(null) takes it, unless the table reads
  it as a value through `absent` (EventBridge's bus, `default`).

For those, the table may fill a variable from a structure's field
(`pipeline.name`), and give a variable no member gives the one value
its handler uses (`fixed`), in the generator, the loader and the
reader.

A create that names another resource beside the one it makes has its
tags checked on the one it makes alone, which the table marks `made`:
the resource of the type, or with an ARN format's leading resource
word, related to the operation's name past its verb. PutWebhook's tags
go on the webhook, not the pipeline it connects to, and CreateService's
on `service/*`, not the namespace; no other operation in the table is
marked.

Application Auto Scaling stays unread, its reason in NOT_COVERED: a
scalable target's ARN ends in an id the service mints, while requests
name the target by ServiceNamespace, ResourceId and ScalableDimension,
and read as a member ResourceId would fill that id.

RequestResourceMembersTest's test of every resource in the table now
expects, with the resource a request names, the resources of its
operation that every request names: Cloud Map's CreateService names
the service it creates with every variable open.
2026-10-28 17:18:11 -05:00
lex00 52eb4b9a9c fix(iam): read condition keys a request carries in a member under another name (#6858)
BY_HAND in tools/aws/regen_iam_condition_keys.py names the member for four pairs: iam:ServiceSpecificCredentialServiceName from ServiceName and iam:ServiceSpecificCredentialAgeDays from CredentialAgeDays on CreateServiceSpecificCredential, and iam:DelegationDuration from SessionDuration and iam:TemplateArn from Permissions.PolicyTemplateArn on CreateDelegationRequest. --check fails when a BY_HAND member leaves botocore, its type no longer fits the key, or the reference stops listing the pair. The other notRead pairs now say where AWS takes the value from.
2026-10-28 16:42:22 -04:00
Allen Sanborn 3212ce3c15 fix(iam): page ListUsers, ListGroups and policy lists with MaxItems and Marker (#6267)
* fix(iam): page ListUsers, ListGroups and policy lists with MaxItems and Marker

ListUsers, ListGroups, ListAttached{User,Group,Role}Policies and
List{User,Group,Role}Policies read neither MaxItems nor Marker and always
answered IsTruncated=false with every entry. They now go through the same
paginate helper ListRoles and ListPolicies use: an omitted MaxItems returns
100 items as the API reference documents, a MaxItems outside 1 to 1000 is a
ValidationError, a Marker the handler did not issue is InvalidInput, and a
Marker appears only on a truncated page.

Users, groups and inline policy names are listed in name order and attached
policies in ARN order, so a Marker keeps pointing at the same place between
calls even when the entry it names is removed in between.

* fix(iam): resume the newly paged IAM lists only from their own markers

ListUsers, ListGroups and the attached and inline policy lists read a
Marker they could not verify as a list offset, so Marker=1 silently
skipped the first entry, and a marker issued for one role's list resumed
another role's list after the same policy. These lists have only ever
issued signed markers, so their cursor now carries the action and, for a
per-principal list, the principal, and any other marker is InvalidInput.
ListRoles, ListPolicies and the other readers keep their existing marker
handling.

Also covers the omitted-MaxItems default on ListUsers and ListGroups with
101 entries: 100 on the first page, IsTruncated and a Marker that fetches
the last one.

* fix(iam): bind the newly paged IAM lists' markers to the request account

IAM entities are stored per account, but the marker cursor named only the
action and principal, so a marker issued in one account resumed the same
listing in another account after the same name and skipped its earlier
entries. The cursor now carries the account the request reads from, and a
marker from another account is InvalidInput.

* feat(iam): generate the IAM paginator table from botocore

tools/aws/regen_iam_paginators.py writes src/main/resources/aws/iam-paginators.json
from botocore's iam/2010-05-08 model, as the other tools/aws generators do: every
operation whose request models Marker, with its input and output token, limit
key, truncation flag and result keys, the MaxItems bounds of maxItemsType
(1 to 1000), the default page size the limit's documentation states ("defaults
to 100"), and markerType's bounds.

The 34 operations botocore's paginators-1.json lists take their tokens and
result keys from it. The six that model Marker without a paginator
(GetServiceLastAccessedDetails, GetServiceLastAccessedDetailsWithEntities,
GetOrganizationsAccessReport, ListServiceSpecificCredentials,
ListDelegationRequests, ListPoliciesGrantingServiceAccess) are read from
their request and response shapes and marked paginator: false.
ListServiceSpecificCredentials documents no default and
ListPoliciesGrantingServiceAccess models no MaxItems; the table records
both as such rather than inventing a value.

make aws-data-sync regenerates it and make aws-data-check fails when it is
stale against the pinned botocore.

* fix(iam): page every IAM list through one path driven by the paginator table

IamQueryHandler paged eight lists by hand through paginateScoped, a few more
through paginate, and left the rest (the tag readers, ListAccessKeys,
ListInstanceProfiles, ListPolicyVersions, GetGroup, ListGroupsForUser,
ListEntitiesForPolicy, GetAccountAuthorizationDetails, the simulations and
others) ignoring MaxItems and Marker with IsTruncated=false. Every operation
the generated aws/iam-paginators.json lists now pages through one paginate
path that reads its entry: the limit's bounds and default, the members that
resume and continue it, and the result keys pagedList and pagedLists write
under. paginateScoped, paginateByMarker and the hardcoded 100/1000 are gone.
ListEntitiesForPolicy and GetAccountAuthorizationDetails page their several
lists as one, in the paginator's order.

Marker semantics, chosen deliberately: a Marker is opaque and resumes only the
listing that issued it, on every paged operation. AWS documents it as "the
value of the Marker element in the response that you received", so a value
Floci did not issue, a bare number included, is InvalidInput; ListRoles,
ListPolicies and the report readers no longer read one as an index. The
marker names the last item of its page, so a deletion or creation ahead of
it skips nothing and repeats nothing, and it is signed (not prefixed) over
the account, the operation and every request member except Marker and
MaxItems, so a marker from another operation, principal, filter or account
is refused while the page size may change between calls. Signing the scope
instead of carrying it keeps issued markers short. markerType's 320-character
bound is not checked separately: every other value is refused as unissued,
and a long ARN key could otherwise push an issued marker past it.

MaxItems is now checked before Marker, as a malformed request is rejected
before anything is read from it. An omitted MaxItems is the documented 100;
ListServiceSpecificCredentials, which documents no default, returns its whole
list.

IamListPaginationIntegrationTest.everyPaginatedOperationHonoursMaxItemsAndMarker
iterates the table's 34 paginated operations, each with a fixture listing two
items, and checks the MaxItems bounds, a one-item page, resumption without
loss or repetition, the default page, and refusal of an unissued, bare-index
or other operation's marker. Its fixture map must name exactly the table's
operations, so one AWS starts paging later fails until it has one.
ListAccountAliases can hold one alias, so it is checked for everything but a
cut page. The tests the table test subsumes are removed; the ordering, anchor,
cross-listing and cross-account tests stay. Two ServiceLastAccessed tests
that walked by bare index now use issued markers.

* fix(iam): hold paged requests to the model through IamRequestShapes

MaxItems and Marker are request constraints, and main now checks a
request against the model before it runs. Every operation the paginator
table pages joins that wave in regen_iam_shapes.py, and the bounds leave
iam-paginators.json (which keeps only defaultItems, the documented page
size) and limit(), which now only parses the number and applies the
default. A pytest pins that every operation the paginator table carries
is in the wave, so a list AWS starts paging later cannot slip past the
bounds.

Six paged operations join with Marker and MaxItems alone: the three
report readers, whose JobId is answered by hand as "length equal to 36"
and whose SortKey enum is checked by hand; ListPoliciesGrantingServiceAccess,
whose empty ServiceNamespaces is answered InvalidInput; and the two
Simulate operations, whose ContextEntries nest a list inside a list of
structures, which the walk refuses. Vendoring their whole request would
reword answers main already settled; vendoring nothing would leave their
paging unbounded (SimulateCustomPolicy with MaxItems=0 was a 500).

Markers fit markerType's 320 characters. A marker embeds the key of the
item its page ended on, so a policy ARN with a long path produced one
of 610 characters, which the model check would now refuse on the way
back. SignedMarkers takes a maximum length: a cursor that would exceed
it is carried as a SHA-256 digest (119 characters once signed and
encoded), and the instance keeps the digest -> key mapping. That keeps
the existing resume semantics exactly: the marker still resolves to the
full key, so a deleted anchor resumes at the first key after it, and
the signature still binds account, operation and filter. Two stateless
alternatives were rejected: a truncated key prefix plus digest cannot
order a deleted anchor against items sharing the prefix, and a position
index skips or repeats when items ahead of it are deleted. The cost is
one map entry per distinct long key a page has ended on, never evicted
(marked ponytail in the code); markers already do not survive a
restart, as the signing key is per instance. Keys short enough to embed
are carried as before.

Checkstyle (./mvnw checkstyle:check) reported six errors in files this
PR touches: javax import order and two inline org.w3c.dom.Node in the
pagination test, and an inline java.util.Base64 in SignedMarkersTest.
The test now parses through XmlParser.parseDocument instead of its own
DocumentBuilderFactory. The switch statements in ListEntitiesForPolicy
and the test's holder fixture are switch expressions.

Tests: aMarkerEndingOnALongPolicyArnFitsTheModelAndResumesPastItsDeletion
attaches three policies under a 391-character path, pages with
MaxItems=1, deletes the anchor and resumes through the model check.
Constructing SignedMarkers without the limit fails it (610 characters);
restoring the pre-wave iam-request-shapes.json fails the table-driven
test (MaxItems=0 answered 500, MaxItems=1001 answered 200).

* fix(iam): bind a caller-resolved list's marker to the resolved user

ListAccessKeys, ListMFADevices, ListSSHPublicKeys, ListSigningCertificates
and ListServiceSpecificCredentials default an omitted UserName to the
caller. The marker was signed over the raw request members, so two users
in one account who both omitted UserName shared a scope and one's marker
resumed the other's listing. These handlers now page over the request
with UserName set to the resolved user, so the marker is bound to the
user the list was read for, named or implicit.

* fix(iam): bound the SignedMarkers digest map and trim the pagination test

SignedMarkers held every long cursor it had issued a digest for, in a map
that never shrank. It is now an access-ordered LinkedHashMap capped at
10,000 entries, the idiom CloudWatch Logs uses for its Insights queries. A
marker whose digest was evicted resolves to null, the same as an unknown
digest, so callers refuse it as an invalid marker.

IamListPaginationIntegrationTest spent most of its time in RestAssured's
per-request overhead on the hundred-item fixtures. Those creates and
deletes now go concurrently through java.net.http. The users and groups
default test keeps its first-page checks of the default of 100 and drops
the second page, which the roles default test and the every-operation test
already cover. The SSH public key fixture is generated once per run.
2026-10-28 16:37:49 -04:00
galsuchetzky-act f926968167 fix(s3control): take TagResource and UntagResource tag condition keys from generated data (#6677)
The Service Authorization Reference lists aws:RequestTag/${TagKey} and
aws:TagKeys as condition keys for s3:TagResource, and aws:TagKeys for
s3:UntagResource. botocore's s3control model says where the request
carries them: TagResource's Tags list in the body, UntagResource's
TagKeys in the tagKeys query parameters.

With IAM enforcement on, Floci checked both S3 Control actions with no
request tag keys. A policy that allows TagResource only for certain tag
values, or UntagResource only for certain keys, matched no request, so
a request it allows was denied, and a ForAllValues condition on
aws:TagKeys allowed UntagResource whatever keys it named.

tools/aws/regen_s3control_tag_condition_keys.py now generates
s3control-tag-condition-keys.json from the two sources, as the DynamoDB
condition key table is generated: every s3 action the reference gives
either key, and every S3 Control operation's request members that feed
them, found as the tag-on-create table finds tag members.
IamConditionContextResolver reads it for a request on an S3 Control
route. The make targets check the members offline against the pinned
botocore in CI and the actions online against AWS in the IAM data drift
workflow. S3's own bucket and object tag keys stay as written, since
they were measured against AWS and do not all match the reference.
2026-10-28 10:14:26 -04:00
lex00 967e87d7f7 fix(iam): set iam: condition keys from a table generated from the Service Reference (#6762) 2026-10-28 07:00:43 -04:00
Andre Kurait 52c9c51a7b fix(dynamodb): enforce the default Select for IAM (#6702)
* fix(dynamodb): enforce effective read selection in IAM policies

Preserve generated action and request-member coverage, effective read projections, PartiQL attributes and independent BatchGetItem contexts. Rebase on current main and scope condition data verification to its vendored file, generator, tests and imported modules, retaining all existing IAM data gates.

Signed-off-by: Andre Kurait <akurait@amazon.com>

* fix(dynamodb): derive transaction read conditions from modeled members

Use the generated transaction Get member paths before GetItem IAM extraction, so ignored legacy projection members cannot authorize whole-item reads.

Signed-off-by: Andre Kurait <akurait@amazon.com>

---------

Signed-off-by: Andre Kurait <akurait@amazon.com>
2026-10-27 10:05:55 -04:00
TATSUNO “Taz” Yasuhiro b0cd70401b feat(iam): check lambda:PassNetworkConnector from a table generated from the Service Reference (#6699)
* feat(lambdaweb): check lambda:PassNetworkConnector as AWS does

A revision that sets egressNetworkConnectorArn needs
lambda:PassNetworkConnector on the connector version ARN as given.
Lambda checks it after the connector ARN checks and before it looks
the connector up.

A refusal names the first policy type that refuses, in the order
identity policies, permissions boundary, session policy. An explicit
deny in a managed policy or a boundary also names that policy's ARN.

* fix(lambdaweb): apply service control policies to the account root when passing a connector

* fix(lambdaweb): name the managed policy that denies a session token caller

* feat(iam): check lambda:PassNetworkConnector from a generated table

Move the check out of Lambda Web into the IAM enforcement filter, where
iam:PassRole is checked. tools/aws/regen_iam_passed_network_connectors.py
joins AWS's Service Reference and botocore's models into
src/main/resources/aws/iam-passed-network-connectors.json, and the filter
reads it for Web Functions, MicroVM images and MicroVMs.

A MicroVM request that names no egress connector, or an empty list, passes
the Lambda-managed INTERNET_EGRESS connector, and RunMicrovm with no ingress
connector passes HTTP_INGRESS, as AWS checks them. AppSync's data source
operations are listed too, but botocore's model has no member for their
connector, so they are not read.

The refusal text now comes from AccessDeniedMessages, which
LambdaTaskAuthorizer and GetStackOutputRoleAuthorizer use as well.
2026-10-26 23:26:25 -04:00
Priamo Germosen 0410a2b4ea fix(iam): check PutEvents on each entry's event bus (#6704)
PutEvents was checked on `*`: the request-resources table gave it no
resources, as its bus is a field of each entry, which no rule read. A
policy allowing or denying events:PutEvents on one event bus therefore
did not hold for publishing.

Each entry's EventBusName is "the name or ARN of the event bus to
receive the event", and "if you omit this, the default event bus is
used". Bus policies grant events:PutEvents on `event-bus/<name>`. The
EventBridge User Guide checks events:PutEvents against "the bus, once
per entry in the request", and says "Publishing is authorized against
the bus ARN for every entry in the request. If one entry fails an
authorization condition, EventBridge denies the whole request." It says
so in its section on the Custom Event Bus, which keeps the events: IAM
namespace of the Classic one; nothing in the guide says otherwise for a
Classic bus, whose API model lists AccessDeniedException among the error
codes of an entry without saying when.

The table now reads PutEvents' `Entries[].EventBusName`, a field of each
of a list's structures, one resource for each entry:

- The generator takes a correction filling a variable from such a field,
  and finds a field whose pattern takes an ARN before a name inside a
  list's structures, as it does a top-level member, so the field gets
  `arnOf` from botocore.
- The loader reads `Name[].Field` in `fill`, and in `absent` and `arnOf`
  when it fills a variable.
- The reader gives one value for each entry, the `absent` value for an
  entry that names no bus, gives a null or a blank, as the handler's
  `asText(null)` does, and none for no entries, which stay on `*`. Each
  value that is an ARN puts its own entry's bus in that ARN's account and
  Region, checked as given and as the caller's, which the handler
  publishes to; until now the first ARN a request gave set the account
  and Region of every value.

The filter checks every resource, so one entry for a bus the caller may
not publish to refuses the whole request, as the guide gives it.

Not in this change: the events:source and events:detail-type condition
keys (Floci supplies neither), EndpointId (the handler ignores it), and
PutPartnerEvents, which stays on `*`.

The upstream drift check on a pull request now verifies only the
vendored IAM files the pull request changes, each with its generator,
its tests and the modules that generator imports. It verified all six
files whichever one a pull request touched, so this change, which
touches only the table of the resources requests name, failed on the
service namespace list, which AWS's index stopped matching when it
dropped `codestar`: drift in a file the change leaves alone. The
pull request's job passes the paths its merge commit changes to
`make iam-data-verify CHANGED=...`, which names each check it skips;
the weekly and manual runs, and a diff that cannot be read, still
check every file, so the namespace list's drift is reported there.
2026-10-26 21:52:09 -05:00
Priamo Germosen 0ec28aee68 feat(iam): read a Query list's constraints from the model (#6625)
The Query walk the managed-policy family reads its constraints through read
scalars only, and refused an operation whose input carries a list when the
vendored file loaded. It reads a list now, and a structure, which is what the
rest of this track is gated on: 34 of IAM's 180 operations carry a list or a
map, and 6 of STS's 11 do.

A list arrives numbered under its own name, Audience.member.1 or the bare
Audience.1, and a member of a list of structures carries its fields under that
prefix, as Tags.member.1.Key does. Each is named in a message the way this
package already names one, filter.1.member and tags.1.member.key, under the
index the request spelled rather than the position the member sits at, which is
what #6478 settled. The count is held to the list's own bounds with the value
left out of the message, which is the form checkListLength and the audience
check both already answer: quoting it would echo every member of the list back.
A list of no members is how an absent list arrives on this protocol, so a
required one reads as null rather than as a list breaking a minimum of 1, and
only a minimum above 1 is reachable at all. A structure member arrives as
TaskPolicyArn.Arn and is named taskPolicyArn.arn, and a request naming none of
its fields is a request without the member.

GetAccountAuthorizationDetails is the operation this wave opts in, and the one
where the model adds refusals rather than rewording an answer already given:
the handler reads none of its three declared members, so a Filter outside the
model's enum, a MaxItems outside 1 to 1000 and a Marker breaking its length or
its pattern are all answered with a 200 today. They are a 400 ValidationError
now, which is the ordering #6402 settled for this package.

A map is still refused when the file loads, and so is anything nested deeper
than a list of structures. The refusal is the point rather than a gap: this
package answers a map against the whole map today, Map keys must satisfy
constraint on PutAccountProperties, where the protocol numbers a map's entries
as Properties.entry.N.key, and no source here says which of the two AWS
answers. Reading one would reword a merged answer on the strength of a guess.

The reader the walk needs went into AwsQueryLists rather than into a third
copy. That file already reads a list's values, and StsQueryHandler holds a
private copy that captures the prefix and the index for the same reason this
one does; the STS wave is where that copy goes.

A number too large for a long is a number all the same, which the range check
reads as one now. It compared through a long before, so a MaxItems of
9223372036854775808 failed to parse, read as no number at all and reached the
operation past a maximum of 1000. The bound it breaks is one that fits in a
long either way, so the comparison carries no width of its own, and the value is
written as the number reads rather than as the request spelled it, a leading
plus or zero gone, which is what a parsed value already answered.

Seven unit tests cover the new forms, two of them on the reader, which is where
one of them found that a key naming its own member read as a member numbered
after it: the index is a number or the key is not a member's. Four wire tests
cover the operation. Removing the list branch fails four of the six list and
structure tests and two of the four wire tests: the two that stay green are
MaxItems and Marker, scalars the walk already read, so they prove the operation
was opted in rather than the walk.
2026-10-26 19:17:09 -05:00
Priamo Germosen 7c0ee92480 fix(iam): refuse SNS requests with AuthorizationError (#6621)
Under IAM enforcement a refused SNS request answered `AccessDenied`, the
code Floci gives every Query service. SNS models no such error. Every
one of its 42 operations lists `AuthorizationError`, HTTP 403, a sender
fault ("Indicates that the user has been denied access to the requested
resource"), which SDKs raise as `AuthorizationErrorException`; the SNS
Developer Guide's own sample reads that code as an IAM permission
failure ("Authorization error listing topics - check IAM permissions").
An SDK caller catching `AuthorizationErrorException` therefore missed
Floci's refusal, which surfaced as a bare `SnsException`.

A Query denial now takes its code from the service that serves the
request: `AuthorizationError` for SNS, whichever action is denied (a
role it is passed as much as its own action), and `AccessDenied` for
every other Query service, as before. The status, the `Sender` type and
the message are unchanged.

Not in this change: Floci's SNS JSON surface (`SNS_20100331.*`
targets), which botocore does not model, keeps `AccessDeniedException`.
2026-10-26 19:16:56 -05:00
Priamo Germosen bb48983b9c feat(iam): read the managed-policy family's constraints from the model (#6580)
The declared constraints on IAM's managed-policy operations are read from the
pinned model rather than from a hand-written check, through the vendored data
tools/aws/regen_iam_shapes.py generates and a Query walk of it. Twelve
operations go first: GetPolicy, DeletePolicy, the four policy-version
operations, and the six attach and detach pairs. The vendored file carries that
wave rather than all 180 operations, as the ECR and Resource Groups files carry
theirs, and grows a wave at a time.

The machinery was already here for the JSON protocols. request_shapes
build_constraints vendors required members, lengths, patterns and enums;
RequestConstraintCheck walks a JSON body against them; SmithyValidationErrors
already writes the awsQuery wording. What was missing is the walk a Query
request needs, which is why QueryConstraintCheck sits beside
RequestConstraintCheck rather than inside it: a JSON body arrives as a tree,
where a Query request arrives as flat parameters named after the members that
carry them, and the violations are collected into one "N validation errors
detected" message in the model's member order instead of the first one being
thrown. A test sends two broken members in the opposite order to the model's
and gets the model's order back, so the ordering is the model's rather than the
wire's.

What changes for a caller is the status, in the direction #6402 settled for this
package: a PolicyArn under arnType's 20 characters, a VersionId outside
policyVersionIdType's pattern or an absent required member used to reach the
store and answer NoSuchEntity 404, where AWS's validation layer runs ahead of
the operation and answers ValidationError 400. AttachRolePolicy's RoleName is
the parity case for every value but one: IamService.validateRoleName already
answered it from the same bounds and the same pattern, and for a name outside
its pattern the message is unchanged by the model taking it over, which a test
pins.

An empty name is that one value, and the one place the wording moves rather
than the status. validateRoleName stops at the first constraint an empty name
breaks and reports the minimum alone, where the model also reports the pattern
it breaks, so these twelve operations answer two violations where they answered
one. That is the reading #6402 merged for a value breaking two of its
constraints, and it makes validateRoleName the drift rather than the
reference. The operations still on the hand-written check keep the single
violation until a later wave takes them over, which a test holds still on
CreateRole so that the wave which does has to settle the wording first.

Two answers are the package's own rather than new. A member breaking two
constraints is reported twice, which is what #6402 merged for a
ServiceSpecificCredentialId that breaks both its length and its pattern, so an
empty PolicyDocument reports its minimum and its pattern. The offending value
stays quoted, as SmithyValidationErrors and validateRoleName already quote it;
whether current IAM quotes it at all is an open question, and reading the
constraints in one place is what would make that one helper to change rather
than every message in the package.

Scalars only so far. An operation whose input shape carries a list or a map is
refused when the vendored file loads rather than passed over with its
constraints unread, since reading one means reading Name.member.N and
Name.entry.N.key and naming each index as the request spelled it. A boolean is
declared and holds no constraint to be read against, so a SetAsDefault that is
neither true nor false still reaches the operation, which reads anything but
true as false. A test pins that rather than changing it, since what AWS answers
for a malformed boolean is unrecorded here.
2026-10-25 22:30:35 -05:00
Priamo Germosen c5e873ff84 fix(iam): check ARNs inside structures and EventBridge's resources (#6561)
The table of request resources read only top-level members, so an
operation naming its resource inside a structure was checked on *:
SetRulePriorities' RulePriorities[].RuleArn and a state machine alias's
routingConfiguration[].stateMachineVersionArn. A member ending in Arn or
Arns one level inside a structure, or inside each of a list's
structures, now names a resource as a top-level one does, the value's
format deciding which of the action's types it is. Such a member never
fills a variable, holds a type or names a create's parent. A form's list
is read to the first element without the field, as the ELB handler
loops.

EventBridge joins the table (71 operations). Its rules are named by the
rule's name on the event bus EventBusName names, by name or by ARN, and
on the default bus when it names none ("If you omit this, the default
event bus is used"), whose rules are rule/<name>, with no bus.
Corrections give the eight rule operations the default bus's rule when
EventBusName is default or absent, and the custom bus's otherwise, with
two new keys: unless, the complement of when, and absent, the value a
missing member is read as. DescribeEventBus naming no bus is checked on
event-bus/default ("If you omit this, the default event bus is
displayed"). A member whose botocore pattern takes an ARN before a name,
(arn:...:event-bus/)?<name>, is recorded as arnOf: an ARN given for it
is read as that type's one variable, and the resource is in the ARN's
account and Region, so a bus of another account, its default bus
included, names that account's rule, as DescribeRule's CreatedBy says,
checked as given and as the caller's own, which Floci acts on. An ARN
leaving its account and Region empty, which EventBridge's handler takes
as the caller's bus of that name, names the caller's, and a JSON null
for a member read as a value when absent is absent too, as the handler's
asText(null) reads it, so a null EventBusName is the default bus.
EventBridge V2's client, AWSEventsV2 over Smithy RPC v2 CBOR, which
Floci does not serve, shares the operations' names and is left out
(clientsNotRead), and verify ignores it.

EventBridge mints a connection's ARN as connection/<name>/<id> and an
API destination's as api-destination/<name>/<id>, as botocore's ARN
patterns give them, and checks a connection on it (the user guide grants
events:RetrieveConnectionCredentials on connection/<name>/*), while the
Service Reference's formats stop at the name. MINTED_IDS records those
types (mintedIds), and a request naming one by its name is checked on
the ARN its service stores it under, which a StoredResourceArns the
service registers finds for the caller in the request's Region
(EventBridgeService does), or on <name>/* when there is none yet, a
create's included.

Not in this change: PutEvents, whose entries each name their bus, stays
on *, and UpdateEventBus with no Name, which no document says is the
default bus, stays on * too.
2026-10-25 21:21:53 -05:00
Matheus Oliveira 56196fec1c fix(s3): report the owner and ACL grantees as a canonical user id (#6549)
* fix(s3): report the owner and ACL grantees as a canonical user id

S3 reported the 12-digit account id where AWS reports the account's
canonical user id: the bucket owner in ListBuckets, the owner and the
multipart initiator in ListParts, and every CanonicalUser grantee and
Owner the ACL responses name. All of them now answer the canonical id,
a 64-character lowercase hex string Floci derives as the SHA-256 of the
account id, so the same account answers the same id across calls,
restarts and storage modes and two accounts never share one. The
account id stays the internal identity; only the emitted value changes,
and ACLs persisted by an older Floci keep serving the form they store.
Owner evaluations, the public-access checks and bucket-policy
CanonicalUser principals accept the canonical id and the account id
alike, so stored policies and scripts written against the old form keep
working.

Closes #6242

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* test(s3): say why the cleanup catches stay silent

The two new compatibility cleanup catches swallowed without a word,
which the guide allows only for a named, explained tolerance. Both now
name the reason: cleanup must not mask the assertion.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* test(s3): expect the canonical owner in the namespace ACL assertions

The cross-account object metadata test still expected the raw account id
in the ACLs, which the canonical owner id broke, and its ACCOUNT_B
assertFalse checks passed whatever the ACL held. All four assertions now
name the accounts the way the ACLs do, through AwsCanonicalUserId.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* test(s3): share the compatibility cleanup between the two tests

The explained cleanup catches landed on the wrong method, a helper that
was already on main, leaving the new canonical owner test with bare
catches. One deleteObjectAndBucketQuietly helper now holds the commented
catches and serves both tests.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

---------

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
2026-10-25 22:11:19 -04:00
Matheus Oliveira 9b4e27c80a fix(iam): authorize KMS operations against the key named in the request (#6458)
* fix(iam): authorize KMS operations against the key named in the request

KMS is JSON 1.1 posted to /, so the path-based key extraction never
found a key and every action was evaluated against key/*: a policy
allowing kms:Decrypt on one key refused that very key, and a policy
restricted to a key restricted nothing. Enforcement now derives the
request's resources the way the KMS permissions reference gives them:
the key-scoped operations name the key the KeyId member names, resolving
an id, an alias or an ARN to the stored key's own ARN; Decrypt without
a KeyId reads the key out of the CiphertextBlob; the alias operations
name the alias and the keys the alias pages give; CreateKey,
GenerateRandom, ListKeys, ListAliases and ListRetirableGrants stay at *.
A request nothing resolves falls back to key/* so the handler answers
its own NotFoundException. ReEncrypt stays the single action AWS splits
into ReEncryptFrom and ReEncryptTo, evaluated against both keys.

Closes #6256

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* fix(iam): authorize ReEncrypt and the grant operations against the keys they act on

A ReEncrypt without SourceKeyId resolved its source through Decrypt's
reader and trusted a KeyId member ReEncrypt does not even have, so a
caller allowed only on key B could send ciphertext encrypted by a
denied key A, name B everywhere, and get A's data back under B. The
source now resolves the way the handler decrypts: SourceKeyId when the
request names one, otherwise the key the CiphertextBlob itself names.
A RetireGrant carrying only a GrantToken was checked against key/*,
which a key-scoped policy never matches; it now answers the key its
grant belongs to, with the documented key/* fallback for a token nothing
resolves. RevokeGrant and the KeyId-plus-GrantId form of RetireGrant
now name the grant's own key beside the key the request names, so a
pair naming one key while the grant belongs to another can no longer
retire or revoke it.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* fix(iam): resolve a RevokeGrant target by its GrantId, never a GrantToken

The revoke target lookup preferred a GrantToken the RevokeGrant handler
never reads: a request could name the grant of an allowed key in a token
while its GrantId named the grant of a denied one, pass the check on the
token's key, and have the handler revoke the other grant. The lookup now
passes the GrantId alone, so the checked key is the key of the grant the
handler deletes.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* fix(iam): fall back when a CiphertextBlob is not a string

A Decrypt or ReEncrypt carrying a CiphertextBlob that is not a string
made binaryValue answer null on the enforcement path and blow up before
the handler could answer its own client error. A blob that is not text
now names every key the account holds, the documented fallback, so the
request is authorized and the handler answers the error AWS answers for
a malformed blob.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* fix(kms): share the grant token scan and its enforcement lookup

retireGrant scanned the region's grants for a token the same way the
enforcement lookup did; both now go through one findGrantByToken. The
builder's revoke target resolves through the shared grantKeyArn helper
with the members each handler actually reads, the token and the id for
RetireGrant and the id alone for RevokeGrant, whose handler never reads
a token. The two test javadocs that described the enforcement gap as a
review's finding now describe the gap itself.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

---------

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
2026-10-25 21:19:18 -04:00
Priamo Germosen 932af22f4a fix(iam): check requests on the resources they name (#6511)
Under IAM enforcement a request is checked against the resources it acts
on. ResourceArnBuilder builds their ARNs by hand for 17 namespaces;
every other request was checked on *, so a grant scoped to a resource
was refused and a deny scoped to one never applied.

AWS's Service Reference lists the resource types each action acts on and
each type's ARN formats, but not which request member names a resource;
botocore's models give the members. A new generator,
tools/aws/regen_iam_request_resources.py, joins the two into
src/main/resources/aws/iam-request-resources.json: for each operation,
the action it is checked as, that action's resource types and the
resources its request names, by a member holding a resource's ARN or by
members filling the variables of a type's format, matched by name. A
variable nothing fills is left open, as a service mints a new resource's
id; a type nothing names is not checked, as an action lists the optional
resources its requests may use; and types named only through the same
members are alternatives, of which the one named in full is kept.
Corrections give a v2 CreateLoadBalancer the load balancer of its Type,
application when it gives none (a Type outside application, network and
gateway is now refused, as AWS refuses it, rather than read as an
application load balancer the table does not name), and read
StartExecution's and StartSyncExecution's stateMachineArn up to a #, as
Floci runs the machine before Step Functions Local's test case. A state
machine's version or alias, stateMachine:<name>:<qualifier>, is checked
on the state machine's ARN, as Step Functions authorizes it, so an
execution started through one is the state machine's too.

RequestResources reads them from a JSON or CBOR body or a Query form,
for the namespaces the table reads, and ResourceArnBuilder uses them
where it has no branch. They are read for the operation the request is
dispatched as, which IamEnforcementFilter resolves and checks the action
of (the Query action, the JSON target or the Smithy RPC v2 path's
operation), never for an X-Amz-Target or Action the request names again,
and as the handlers read them: a list only from a list, a number or a
null as its text. A member whose botocore shape is an account id gives
the account of the types named by variables: ECR's registryId selects
the registry its handler acts in, and a JSON null is no registry, the
caller's, as ECR reads it. ECR's
BatchGetRepositoryScanningConfiguration, whose AWS request has no
registryId, no longer reads one: it acts in the caller's registry, where
IAM checks it. An ARN value counts when it matches the format of a type
the action acts on; one naming another account or Region is checked as
given and as each resource of that name a handler may act on instead, in
its account or the caller's and its Region or the request's (ECR's tag
handlers keep the ARN's account in the request's Region). A request
naming none, or whose action acts on no resource type, stays on *, as
AWS checks it. A create's tagging action is checked on the same
resources, except where the create makes a resource under a parent its
action acts on: CreateListener acts on a load balancer and CreateRule on
a listener, and their tags are checked on the new listener or rule,
built from the parent's ARN with the type word replaced and its own id
open. The table gives these from the formats: a child type's is its
parent's with one id appended. So the AWS Load Balancer Controller's
policy, which allows AddTags at creation only on target groups and
application and network load balancers, and on listeners and rules, now
holds.

The first namespaces read are Elastic Load Balancing, ECR, Step
Functions and Cognito user pools (298 operations); the 99 others Floci
serves are listed as not read yet, with their reason, and
RequestResourceNamespacesIntegrationTest fails for a served namespace in
none of the lists. make iam-request-resources-check, part of
aws-data-check, re-derives every operation from the pinned botocore;
make iam-request-resources-verify, part of iam-data-verify, checks the
actions, types and formats against AWS, and the IAM data drift workflow
also runs on a change to the table or its generator.

Not in this change: the 99 other namespaces, Query lists other than
Name.member.N, identifiers inside structures (SetRulePriorities,
CreateStateMachineAlias' routing configuration) and EventBridge.
2026-10-25 14:51:39 -05:00
Priamo Germosen 68e7b313a8 fix(iam): validate the values each ReplacementValues entry carries (#6478)
ReplacementValueEntry declares Values required and replacementValueListType
bounds it at 1 to 20 values, which the API Reference spells out as "Array
Members: Minimum number of 1 item. Maximum number of 20 items" with
"Required: Yes", and AcquireRole read only the map's own 30-entry cap. An entry
carrying no values and an entry carrying 21 of them both reached the template
lookup and answered NoSuchEntity, where the validation ahead of the operation
answers ValidationError.

A Query list of no members is how an absent member arrives, so the lower bound
of 1 is never reached on its own: an entry carrying nothing is the required
member reading as null. The values are counted by the member being present
rather than by what it holds, the list's members publishing no constraint of
their own, so a value sent empty is a value; they are read through the helper
the other Query services read a list with. The violation names the entry by its
key, the way the account properties map names one, rather than by the index the
request numbered it with, and an entry is read back under the index the request
spelled rather than under the number that index reads as, the parameters that
carry it being named after the spelling. The map's own length is now reported
beside its entries rather than ahead of them, the shape being walked from the
outside in, so a request broken in several places is told all of it at once.

No recorded AWS violation on a map member is on hand to confirm that path
spelling against the nested "Map value must satisfy constraint" form, so the
role template docs say it is Floci's reading and what would change it.

Five tests: an entry with no values at all, a 21st value in one entry with 20
of them carried through to the 404, an entry whose only value is empty, an
entry numbered 01 read under that spelling, and 31 entries with two of them
left empty answered in one message. The role template docs say what is read
before the lookup, so they name the entries too.
2026-10-24 23:03:26 -05:00
TATSUNO “Taz” Yasuhiro cd2dac708d feat(lambdaweb): check the code bucket versioning and policy as AWS does (#6479) 2026-10-24 23:33:50 -04:00
Priamo Germosen 64f4f9e489 fix(iam): check a create's tags on its own and its tagging action (#6452)
Under IAM enforcement a request that tags the resource it creates was
checked only for the operation's own action. AWS also checks the
service's tagging action, as the SNS API reference says: "To be able to
tag a topic on creation, you must have the sns:CreateTopic and
sns:TagResource permissions." A caller allowed to create but not to tag
could set at creation the tags that a tag-based policy trusts. The
operation's own action did not see the tags either: aws:RequestTag and
aws:TagKeys were set only for Logs, S3 and EC2 RunInstances, so a
policy allowing sqs:CreateQueue only with aws:RequestTag/team never
matched, and one denying it when aws:RequestTag/team is null refused a
tagged create.

AWS's Service Reference lists the tagging action among each operation's
authorized actions and marks the actions that only tag, but does not say
which request member carries the tags; botocore's models do. A new
generator, tools/aws/regen_iam_tag_on_create.py, joins the two into
src/main/resources/aws/iam-tag-on-create.json: 581 operations over 69
namespaces, those Floci authorizes by operation. An
operation is in it when the reference lists, beside its own, an action
that only tags and adds tags; its tags are read from a top-level member
named Tags, TagList, TagSpecifications or the like that holds a tag list
or map. 569 are read from the table (579 members), CloudWatch Logs
CreateLogGroup is checked by hand as before, and 11 carry no tags this
file can read, each with its reason. A correction gives SQS's Query
name, Tag.N, and one drops an EC2 IPAM pool's allocation rule, which
tags nothing.

When a request carries tags, IamEnforcementFilter checks the tagging
action for each resource's tags apart, with them as aws:RequestTag/<key>
and aws:TagKeys, and, where the action takes it, the operation as its
namespace's CreateAction key (ec2:CreateAction is RunInstances for an
instance launched with tags). A tag specification's tags are checked on
the resource of the type it names, from the ARN the reference gives the
type with its name left open (arn:aws:ec2:<Region>:<account>:instance/*),
which the table carries for EC2 and RDS; other tags on the resources the
operation is checked on. Lambda's CreateFunction is now checked on the
function its body names, which the reference gives it, rather than on *,
so a grant scoped to the function covers both its action and its tags.
The operation's own action is checked with the
same two keys, once for each resource's tags, where the reference lists
them for it or for a resource it acts on (542 of the 569), keeping any a
service's own condition keys set. The table is keyed by operation, so
the filter now carries the operation it resolved beside the action,
which differs for an operation AWS authorizes under another name
(Budgets' CreateBudget is budgets:ModifyBudget).

The tags are read as the Floci handler that applies them reads them, so
the check sees the tags the resource gets. A form's are read under the
SDK's spelling, from 1 to the first number with no key, and under the
further spellings the RDS, DocumentDB, Neptune, ElastiCache and Redshift
handlers read, numbered as each numbers them; EC2's from every tag
specification under either TagSpecification spelling, to the first
naming no resource type. A body's member is read under its own name, and
CloudWatch's PutMetricAlarm and PutCompositeAlarm also under tags, and a
CodeDeploy tag as Key and Value or key and value, each as text whatever
it holds, as its handler reads. The
tagging action is also checked for tags under any other spelling a
handler might read (a name, key or value in any case, any list spelling
and number, an object's structures), so none a handler applies goes
unchecked. The operation's own action is checked with every reading, its
handler's, any other spelling's, and none where its handler reads none,
and refused if any is denied, so a deny on a tag holds and a required tag
counts only where the handler applies it.

make iam-tag-on-create-check, part of aws-data-check, re-derives every
member from the pinned botocore; make iam-tag-on-create-verify, part of
iam-data-verify, checks every operation against AWS, and the IAM data
drift workflow also runs on a change to the table or its generator.

Not checked: sts:TagSession in a role's trust policy, service-specific
request tag keys such as rds:req-tag, EC2 RequestSpotFleet's nested
tags, and the REST services whose routes no rule maps yet.
2026-10-24 22:12:56 -05:00
Priamo Germosen 32663a24ad feat(iam): dispatch GetMFADevice, AcquireRole and GetRoleTemplateVersion (#6453)
The last three operations the IAM model publishes and Floci did not dispatch.
All three can only ever answer NoSuchEntity here, and that is the argument for
dispatching them rather than against it: a 404 both their API pages model beats
the UnsupportedOperation 400 an undispatched action answers, which no SDK maps
to anything for these operations.

GetMFADevice reads a FIDO security key. The reference says of its serial number
that "For this API, we only accept FIDO security key ARNs", and nothing in the
IAM API creates such a device: CreateVirtualMFADevice is the only operation that
mints one here and it mints an mfa/ device, so there is never a FIDO key to
find. A virtual device's serial is refused the same way, deliberately, since
answering with it would hand back a device AWS would not return for the same
request. The page models NoSuchEntity and ServiceFailure and nothing else, so
there is no validation answer to prefer over the 404.

Role templates are AWS's own. The user guide has role manager using "AWS-managed
role templates" and a role created from one with iam:AcquireRole and the
template's ARN, and the model agrees from the other side: GetRoleTemplateVersion
is the only operation that names a template and there is no create, list, update
or delete, so nothing a client can call puts a template into an account. Both
operations answer NoSuchEntity naming the ARN they were handed.
RoleTemplateDisabled is the other refusal AcquireRole models and it is not this
one: it reads "the specified role template is disabled", which is a statement
about a template that exists.

That this is a reading, and what would change it, is written into
docs/services/iam.md rather than left in a commit message. The guide publishes
the template ARNs but not their bodies, so a published body would turn those
ARNs into answers and leave the 404 for every other, and RoleManager/Enabled,
role manager's own switch, is a separate question this does not read.

The declared constraints are read before the lookup, as #6402 put them
elsewhere in this package: SerialNumber to serialNumberType's 9 to 256 and its
pattern, UserName to userNameType whenever the request carries the member, a
blank one included, the member being present whatever it holds, TemplateArn to
arnType's 20 to 2048, the two minor versions to being integers, answering
InvalidInput for a value that is not a number, and ReplacementValues to the 30
entries it declares. The ARN check is #6402's, read through one helper now
rather than copied, and the member path validation messages spell is a helper
too.

role-template leaves ResourceArnBuilder.UNRESOLVED_TYPES, which is empty now.
GetRoleTemplateVersion carries the template's ARN, so the type resolves like any
other the request names, in the aws account rather than the caller's.
AcquireRole stays on *, AWS's service reference publishing no action for it.

Eleven tests. Five on GetMFADevice: the FIDO serial reported missing rather
than unsupported, a virtual device refused and still listed afterwards, the
serial's length and pattern as counted violations, a user the account does not
hold reported instead of the device, and a blank UserName read as a value
rather than as absent, which breaks both of userNameType's constraints when it
is empty and its pattern when it is whitespace. Six on the templates: both
operations' 404s, TemplateArn under its length and absent on each, a minor
version that is not a number on each, and 31 replacement values refused where
30 reach the 404. The unresolved-types test lost a guard an empty map would
fail and gained the claim that emptied it.
2026-10-24 20:22:23 -05:00
Priamo Germosen b36fd2f0be fix(iam): authorize Budgets operations as ModifyBudget and ViewBudget (#6436)
Under IAM enforcement a Budgets operation other than a budget action was
authorized as its own name, budgets:CreateBudget and the like, which is
no IAM action. A policy granting budgets:ModifyBudget was denied
CreateBudget, and one granting budgets:ViewBudget was denied
DescribeBudgets, while a policy naming the operation, which grants
nothing on AWS, let it through.

AWS's Service Reference authorizes these operations as
budgets:ModifyBudget or budgets:ViewBudget. Beside that action it lists
the aws-portal Billing console permissions and, for CreateBudget, the
tag-on-create budgets:TagResource, so the authorized-action generator
counted two or three actions and left them out. It now counts neither:
the aws-portal actions gate the Billing console, and the Billing and
Cost Management user guide says programmatic requests to AWS Budgets
are not affected by them; a namespace's tagging action beside exactly
one other is the tag-on-create permission. That adds the 15 Budgets
operations and IoT FleetWise BatchCreateVehicle, which Floci does not
serve, to the vendored map.

Not checked: budgets:TagResource when CreateBudget or CreateBudgetAction
carries tags.
2026-10-24 14:58:08 -05:00
Priamo Germosen 62c202f073 fix(iam): read declared constraints before the lookup they precede (#6402)
The validation AWS runs ahead of an operation never reaches its store, so a
request that breaks a declared constraint is refused whether or not the thing it
names exists. Four places here had the order the other way round, and each one
answered a 404 for a request AWS answers with a 400.

The three Access Advisor and Organizations report readers looked the job up
before reading JobId, MaxItems and Marker, so an unknown job carrying a
MaxItems of 0 answered NoSuchEntity, and a JobId of the wrong length was never
held to its shape at all. jobIDType is min 36 and max 36, and the fixed length
reports as one constraint, "Member must have length equal to 36", which is the
form lifecycleActionToken already uses for the same shape in Auto Scaling. The
MaxItems check moves out of paginate so a reader can run it early, and paginate
still runs it, being reached from readers that look nothing up.

GenerateServiceLastAccessedDetails had the same order on its Granularity enum,
reading it inside the generate that sits behind the ARN resolution, so a
granularity AWS refuses answered NoSuchEntity for an ARN that named nothing.
The check is its own method now and the handler runs it first.

PolicySourceArn is arnType, min 20, and the simulators resolved the entity out
of whatever followed the last slash, so ":user/bob" simulated against a user
named bob. A value too short to be any ARN is now the length ValidationError
IAM answers for a short ARN member. A value that clears 20 characters and still
parses as no ARN is left alone: the member publishes no pattern, and no source
records what AWS answers for one.

The service-specific credential id reported both of its length bounds in one
violation, so a short id was told about a 128-character ceiling it was nowhere
near. Each message names the one bound the value broke, which is how every
recorded IAM length violation reads: "Member must have length less than or
equal to 64" for a user name over 64, and "Member must have length greater than
or equal to 20" for an ARN under 20.

Seven tests. Four over the wire on the readers: a JobId of the wrong length
refused before any lookup on both the last-accessed reader and the entities
reader, the same on the Organizations reader with no organization built at all,
and an unknown job carrying a bad MaxItems, a bad Marker and then nothing wrong,
which pins the 400s and the surviving 404. One on the generator, where the
granularity is refused for an ARN that names nothing. One on both simulators for
a PolicySourceArn under 20. And the credential id's two bounds, each asserting
the other bound is absent from the message, with the credential itself still
listed once the refusals are done: a validation error that deleted something on
its way out would read the same from the response alone.
2026-10-24 08:38:33 -05:00
Priamo Germosen 1276a8857f fix(iam): check iam:PassRole from a table generated from the Service Reference (#6422)
Under IAM enforcement a request that names a role is checked for
iam:PassRole only where PassedRoles has a case for its operation, so most
of the operations AWS's Service Reference lists with iam:PassRole went
through without it: a caller allowed to create a CodeBuild project, a
Firehose stream, a Glue job or an SSM association could hand it any role
in the account. Adding a case per operation took one pull request per few
services.

The Service Reference names, for each operation, the services its role
goes to, but not the request member that names it; botocore's models give
the members. tools/aws/regen_iam_passed_roles.py joins the two into
src/main/resources/aws/iam-passed-roles.json: every operation listing
iam:PassRole in the namespaces Floci serves over JSON, Query and Smithy
RPC v2 CBOR, and in the REST services whose routes are authorized as
operations, each either read from the table, read by hand in PassedRoles,
or not read with a reason. Generation fails on an operation in none of
the three.

A member names a role when its name ends in Role, RoleArn or RoleName (a
plural, or one followed by Update or Override) and it holds a string or a
list or map of them, not an enum. A member whose documentation says it
takes a role by name is checked on the ARN IAM holds the role under. A
role the Service Reference passes to no named service, as it does
Cognito's, is checked with no iam:PassedToService. The generator records
its corrections with their reasons: members that pass no role (the roles
a Budgets action attaches a policy to, a CodePipeline action's role,
which the pipeline's role assumes, SSM target accounts' execution roles,
the roles a Glue job's generated nodes assume with STS, Firehose's
Snowflake role), members the rule does not see (a Cognito user pool's SMS
caller roles, a Glue connection's ROLE_ARN property and a view's definer,
Service Catalog's AssumeRole and LAUNCH_ROLE keys), and which service a
member's role goes to where the reference names several.

PassedRoles reads a table member from a JSON or CBOR body, or from Query
form parameters in either list form. Its own cases now return null for an
operation they do not read, and the table covers the rest. New cases read
SNS's role attributes (a topic's delivery status roles, a platform
application's, a Firehose subscription's and the SMS one, as the SNS
handlers read the map; an attribute with no value names none), a
CloudWatch Logs subscription filter policy's RoleArn, a Service Catalog
launch constraint's role, by the type Service Catalog holds for the
constraint on an update and in any case, since Floci keeps the type as
given, and an SWF decision's Lambda role from the attributes its type
names.

Not read: requests that name no role, roles that are a runbook's
parameter, operations whose roles go to several services without the
reference saying which member goes where (EMR RunJobFlow, EKS
UpdateClusterConfig, CloudWatch Logs CreateImportTask, SageMaker
CreateTrainingSession), XML bodies (S3 PutBucketReplication), EC2's
RequestSpotFleet, and REST services whose routes no rule maps yet.

make iam-passed-roles-check, part of aws-data-check, re-derives every
member from the pinned botocore; make iam-passed-roles-verify, part of
iam-data-verify, checks every operation against AWS; the IAM data drift
workflow now also runs on a change to the table or its generator.
PassedRoleNamespacesIntegrationTest fails for a namespace Floci serves
that the table neither reads nor names as not read yet.
2026-10-24 08:38:14 -05:00
Priamo Germosen 6215b6fd38 fix(iam): check iam:PassRole for RDS and DMS (#6389)
Under IAM enforcement an RDS or DMS request that names a role went through without iam:PassRole on
it. AWS's Service Reference lists iam:PassRole, passed to rds.amazonaws.com or dms.amazonaws.com,
for each of these operations, so a caller allowed to change a database could attach any role in
the account to it.

RDS, to rds.amazonaws.com:
- AddRoleToDBCluster, AddRoleToDBInstance, RemoveRoleFromDBCluster, RemoveRoleFromDBInstance,
  CreateDBProxy and ModifyDBProxy pass RoleArn, and StartExportTask passes IamRoleArn;
- CreateDBInstance, CreateDBInstanceReadReplica, ModifyDBInstance, CreateDBCluster,
  ModifyDBCluster, RestoreDBClusterFromSnapshot and RestoreDBClusterToPointInTime pass the
  Enhanced Monitoring role, MonitoringRoleArn ("The user that enables Enhanced Monitoring must be
  granted the PassRole permission.");
- they, RestoreDBInstanceFromDBSnapshot and RestoreDBInstanceToPointInTime pass the directory role
  DomainIAMRoleName names, checked on the ARN IAM holds it under, since the name carries no path;
- CreateDBCluster and the two cluster restores pass each role in AssociatedRoles, at any index and
  in either list form, as the RDS handler reads them;
- ModifyOptionGroup passes the role each option it includes takes in its IAM_ROLE_ARN setting, as
  SQL Server's native backup and audit options do, read as the handler reads OptionsToInclude.

DMS, to dms.amazonaws.com: CreateEndpoint and ModifyEndpoint pass ServiceAccessRoleArn and the
role members the DMS model gives each engine's settings structure (ServiceAccessRoleArn,
SecretsManagerAccessRoleArn, SecretsManagerOracleAsmAccessRoleArn), and CreateReplicationInstance
and ModifyReplicationInstance pass KerberosAuthenticationSettings.KeyCacheSecretIamArn.

docs/services/iam.md lists the operations and the roles they pass.
2026-10-23 22:15:57 -05:00
Priamo Germosen ec5597eb5c fix(iam): check EKS's REST routes and roles, and routes with a trailing slash (#6323)
Under IAM enforcement a REST request whose route no rule maps is let through unchecked. No EKS
route had a rule, so any signed caller could create, read, change or delete clusters, node groups,
Fargate profiles, add-ons, access entries and Pod Identity associations with no EKS permission, and
without iam:PassRole on the roles they named. A Pod Identity association hands its service
account's pods the credentials of its role, so a caller could have pods run as any role in the
account.

Every operation of the eks model now has a rule and is checked as the action of its own name, as
the Service Authorization Reference gives it, including the routes Floci does not serve yet, and
IamRestRouteCoverageTest checks the whole model. Floci takes an access entry's principal as the
rest of the path, so a GET or DELETE under an entry reads or deletes an entry: the entry's access
policy routes, which Floci does not serve, run as DescribeAccessEntry and DeleteAccessEntry and are
checked as those.

Each is checked against the resource the reference gives it, in the caller's account, where EKS
looks everything up:
- a cluster against the ARN EKS holds it under, or cluster/<name> in the request's Region for one
  it holds none of, and CreateCluster against the cluster its body names, as the EKS user guide's
  example policy for creating a cluster grants it;
- a node group, Fargate profile, add-on, access entry or Pod Identity association against the ARN
  EKS holds it under, which ends in an id the request does not carry, read through
  EksService.findResourceArn with the lookups its handlers make; listing and creating them, and the
  other routes under a cluster, against the cluster;
- DescribeUpdate against the add-on the update was made to, since the updates Floci keeps are its
  add-ons' and EKS returns one whether or not the request names its add-on, and otherwise the
  cluster;
- a tagging request against the caller's cluster named after the ARN's last /, as EKS tags it.

The roles each operation passes need iam:PassRole, with iam:PassedToService the value the Service
Reference gives: the cluster role, node role, Fargate pod execution role and an add-on's service
account and Pod Identity roles go to eks.amazonaws.com, a Pod Identity association's roleArn to
pods.eks.amazonaws.com ("The IAM principal that is creating the association must have
iam:PassRole."), and an EC2_LINUX or EC2_WINDOWS access entry's principal to ec2.amazonaws.com.

The router also matches a path with a trailing slash as the path without it, while the rules
matched the slash: POST /clusters/, GET /schedules/ and GET /2015-03-31/functions/<name>/ reached
their operation unchecked. A route is now matched without its trailing slash, as the router
matches it. An S3 path is matched as sent, as before: an S3 key may end in a slash, as a folder
marker's does, and S3's rules already take a bucket's one trailing slash.

docs/services/iam.md says which EKS routes are mapped, what each is checked against and the roles
they pass.
2026-10-23 22:15:46 -05:00
Priamo Germosen a8b5e8b8ec fix(iam): hold a root approval of a delegation request to four hours (#6321)
Delegated access has two ceilings and only one of them belongs to the request.
The twelve hours sessionDurationType declares are held at the filing, where
SessionDuration arrives. The other is the approver's, and the user guide's own
note states it: "The maximum duration for delegated access is 12 hours.
However, root users can only approve delegation requests with a duration of 4
hours or less. If a request specifies more than 4 hours, you must use a
non-root identity to approve the request." Nothing read it, so the account root
could approve a twelve-hour delegation and the credentials it bought ran that
long.

It is read at the approval rather than at the filing, because that is where the
approver is known: a request longer than four hours is refused for root and the
same request is approvable by an IAM user or role of that account, which is the
remedy the note itself names. Root is the caller whose ARN ends in :root, what
this family already names an approver by, and what a key naming no IAM user
resolves to, so approving a long request locally means signing as a user rather
than with a bare account id.

AcceptDelegationRequest models NoSuchEntity, ServiceFailure and
ConcurrentModification and nothing for this, and no source gives the code AWS
answers, so AccessDenied is chosen and recorded in docs/services/iam.md: the
guide states the rule as which identity may approve, which is what the
release's own OnlySendByOwner rule already answers that way.

Five tests. Three on the service: the refusal at five hours with the privileged
user then approving the same request, the cap itself approved at four hours
exactly, and twelve hours approved by a user to show the cap is the approver's.
Two over the wire: the same refusal where the account id is the signing key,
and the release's id check answered for an id that breaks its pattern rather
than one that is absent, which the absent half's test left uncovered.
2026-10-23 07:27:14 -05:00
Alessandro Lattao 3944d6edc2 fix(dsql): enforce IAM and the cluster's policy on the control plane (#6328)
* fix(dsql): enforce IAM and the cluster's policy on the control plane

A cluster's resource-based policy governs DSQL's control plane as well as
its connections (measured, eu-west-1): a Deny of dsql:GetCluster,
UpdateCluster, TagResource or GetVpcEndpointServiceName refuses that call,
and a call it does not name still answers. With IAM enforcement on, Floci
left every DSQL control plane route unchecked: no rule in
IamActionRegistry mapped one, so the policies, identity or resource, were
never read there.

IamActionRegistry maps every operation of DSQL's model to its action, the
stream operations Floci does not serve included, and
IamRestRouteCoverageTest now checks all of them against botocore's routes,
vendored for DSQL by regen_rest_routes.py. ResourceArnBuilder names the
resource each call is checked against, as the Service Authorization
Reference gives it: the cluster, the stream, or the ARN a tagging route
names, minted in the request's partition. CreateCluster and ListClusters
are checked against cluster/*, as DSQL checks them (measured; the
reference lists ListClusters with no resource). The enforcement filter
then reads the cluster's policy through DsqlResourcePolicyProvider, as it
reads a topic's or a function's.

* fix(dsql): check tagging at /tags too, where the ARN is in the query or body

Asked in review: Floci serves DSQL's tagging at /tags as well as at
/tags/{arn}, naming the ARN in the resourceArn query parameter or body field,
and the rules matched only the path form, so a bare /tags call reached DSQL's
tag handler unchecked. The rules now match both, as Scheduler's do, and the
control plane test tags, lists and untags through each form.
2026-10-23 06:51:19 -04:00
Priamo Germosen 27338a62b7 feat(iam): answer GetHumanReadableSummary for a delegation request (#6298)
The ninth and last operation of IAM temporary delegation, and the last one the
model publishes that is not an M3 404: a delegation request now comes back as a
Markdown summary instead of UnsupportedOperation, which takes IAM to 177 of the
180 operations botocore 1.43.113 publishes.

AWS generates that text with a large language model, so this is the one piece of
the family that cannot be its answer. What is sourced is the format, the
reference's own example answering "Human readable summary in Markdown format",
and the shape: EntityArn 20 to 2048, Locale 2 to 12, SummaryContent up to 10000
characters and the four SummaryState values. Every line is read off the record,
so one request summarizes the same way twice: what is being asked for, by whom,
for how long, and where it has got to. The services and actions the console
credits its AI summary with are the one half missing, for the same reason
nothing renders a PermissionPolicy here, that no API registers the template AWS
resolves one from, so the template and its parameters are named instead.

Who may read a summary is who may read the request, which the reference states
outright, so the lookup is GetDelegationRequest's and so is the NoSuchEntity it
answers. The request is authorized against the ARN Floci mints around the id
EntityArn names, which is the one its five by-id siblings already resolve: a
policy naming one request authorizes that request alone, and a deny on it holds
however the caller respells the ARN. An ARN of another service names no request
of IAM's to summarize.

Four answers are chosen rather than read, each recorded in docs/services/iam.md:
an ARN of another entity type is NOT_SUPPORTED, a locale Floci does not write is
NOT_AVAILABLE with no content, a value that is no ARN at all is the modeled
InvalidInput, and an id inside a well formed ARN that no id could match is
NoSuchEntity rather than a constraint failure.

The text is the requester's, and the summary is Markdown, so it is escaped
rather than passed through: the model lets a description, a message and a
parameter value carry newlines and backticks, which would otherwise forge a
heading, a bullet or a code span inside a document read as Floci's own account
of the request. A parameter value the record does not hold is left out, and an
indexed value arriving as a key with nothing under it is no longer stored as
one.
2026-10-22 21:55:05 -05:00
Priamo Germosen c094ce3973 feat(sts): dispatch AssumeRoot and authorize centralized root access (#6251)
Floci dispatched the five operations that turn centralized root access on
and off and nothing that uses it, so the feature was half emulated:
AssumeRoot, the operation they exist for, answered UnsupportedOperation. The
five took no caller check of their own either, so any account could enable
or disable organization wide root features, and the record they wrote was
scoped to the calling account, which left the management account's toggle
invisible to a delegated administrator.

All five answer for one organization now, so all five check the caller, and
each refusal is a shape the reference models on them and on nothing else: no
organization is OrganizationNotFound, one without All features is
OrganizationNotInAllFeaturesMode, one without trusted access for IAM is
ServiceAccessNotEnabled, and a caller that is neither the management account
nor a delegated administrator is
AccountNotManagementOrDelegatedAdministrator. The two enable operations add
CallerIsNotManagementAccount, modeled on them alone, so a delegated
administrator may read the features and turn them off but not on. The
feature set belongs to the organization, so it is read and written in the
management account's scope whoever asks, and the OrganizationId the model
declares beside EnabledFeatures is answered now that the organization is
known. Organizations answers all of this through a provider interface in the
iam package, the way ScpProvider already does, so IAM still does not depend
on it.

AssumeRoot opens the session those features allow. It acts as the member
account's root user, which no identity policy grants or denies, scoped by
the TaskPolicyArn the request names: the five AWS managed policies the model
names, under the root-task path, each denying everything it does not name,
so the policy is the whole of the bound and is read beside the root's own
allow-all rather than as a session policy with nothing to allow. A customer-
managed policy can carry that path too and is refused, being the caller's
own document rather than one of AWS's. The caller must be able to manage
root access and have RootSessions enabled, the target must be a member
account other than the management account, and the audit reads those
policies allow name the member account's root user when they carry no
UserName, which is what their own arn:aws:iam::*:root asks for.

What is chosen rather than read is documented in docs/services/sts.md: the
operation models only RegionDisabled and ExpiredToken, so every caller,
target and feature refusal is AccessDenied 403 and a task policy outside the
root-task path is a ValidationError, the shape MinimumSessionTokenSize also
answers outside the 0 to 4096 the model declares for it, the size asked for
being the size issued. The guide's refusal of root user credentials covers
both credentials this emulator reads as the account root, one that resolves
to a root ARN and the bare account-id key the enforcement filter calls
floci's account-root principal, so a privileged session is opened by an IAM
user or role of the management account as it is on AWS. The global endpoint
is refused when the request arrives on that host, which is the only way a
request says so.
2026-10-22 17:06:12 -05:00
Priamo Germosen 812c95499d fix(iam): check iam:PassRole for Redshift, Redshift Serverless and AddRoleToInstanceProfile (#6250)
Under IAM enforcement a request that passes a role to a service needs iam:PassRole on that role,
but no Redshift or Redshift Serverless operation was checked for it. A caller allowed to create a
cluster or change its roles could attach any role to it, and Floci's COPY, UNLOAD and Spectrum
statements then run as that role; statements run through the Data API on a Redshift Serverless
workgroup can use its namespace's roles the same way.

Now checked, with iam:PassedToService as the Service Authorization Reference gives it:
- Redshift CreateCluster and RestoreFromClusterSnapshot pass the roles in IamRoles, and
  ModifyClusterIamRoles those in AddIamRoles, to redshift.amazonaws.com. The lists are read through
  the Redshift handler's own member pattern, so IamRoles.IamRoleArn.N, as the SDK sends it,
  IamRoles.member.N and IamRoles.N all count. RestoreFromClusterSnapshot is checked although
  Floci's restore attaches no role yet, as AWS checks it.
- Redshift Serverless CreateNamespace and UpdateNamespace pass the roles in iamRoles and the one
  in defaultIamRoleArn, and CreateScheduledAction and UpdateScheduledAction pass roleArn, to
  redshift-serverless.amazonaws.com.

The Redshift management guide: "To associate an IAM role with a cluster, a user must have
iam:PassRole permission for that IAM role." A role named only as a cluster's default,
DefaultIamRoleArn, is not checked on its own: the default is one of the roles the cluster holds, and
Floci does not act on it. A namespace's defaultIamRoleArn is checked, since Floci keeps it whether
or not iamRoles holds it.

COPY, UNLOAD and Spectrum now take a role only under the ARN IAM holds it under, path included, as
STS AssumeRole does. They looked the role up by its name alone, so a cluster given
role/sandbox/AdminRole, which a PassRole grant on role/sandbox/* allows, ran its statements as the
AdminRole IAM holds under another path.

IAM's AddRoleToInstanceProfile now passes the role it adds to ec2.amazonaws.com. Every instance
running with the profile gets that role's credentials from the instance metadata service, so adding
a role to a profile already attached to a running instance handed it any role. The IAM API
reference: "The caller of this operation must be granted the PassRole permission on the IAM role by
a permissions policy." RoleName names the role without its path, so the check uses the ARN IAM holds
the role under, or, for a role IAM does not hold, the ARN the name gives.

docs/services/iam.md lists the new operations, and docs/services/redshift.md the path rule.
2026-10-22 17:06:02 -05:00
Priamo Germosen 6763b405dd fix(iam): check the rest of the Lambda function API's routes (#6226)
Under IAM enforcement a REST request whose route no rule maps is let through unchecked. 51
operations of Lambda's function API had no rule, 25 of them served by Floci, so any signed caller
could read a function's configuration, environment variables included, publish versions, set its
concurrency and event invoke config, and create, read or delete layer versions and code signing
configs, with no Lambda permission at all. ListFunctionsByCodeSigningConfig, whose route ends in
/functions, was checked as lambda:ListFunctions.

Every operation of the function API now has a rule and is checked as the action of its own name,
as the Service Authorization Reference gives it, including the routes Floci does not serve yet:
provisioned concurrency, capacity providers, layer version permissions, the recursion, scaling and
runtime management configs, PutFunctionCodeSigningConfig, InvokeAsync, ListFunctionUrlConfigs and
the resource policy routes. IamRestRouteCoverageTest checks every operation of the lambda model,
as it does Scheduler, Pipes, MicroVMs and network connectors.

Each is checked against the resource the reference gives it:
- a function's settings against the function, as the other function routes are;
- an event source mapping against event-source-mapping:<uuid>, which DeleteEventSourceMapping now
  gets too in place of *;
- a code signing config against code-signing-config:<id>, the id that ends the ARN the route takes,
  in the request's account and Region, as Lambda looks it up;
- a layer version, its policy and its permissions against layer:<name>:<version>, the name as
  given, even a name given as an ARN or holding an encoded /, since Lambda looks the layer up by it
  as it is, and the version as the number Lambda parses, so 01 is checked as 1;
  PublishLayerVersion against layer:<name>, and GetLayerVersionByArn against the version its Arn
  names, its number read the same way;
- account settings, creating a config, and listing configs, layers or a layer's versions against
  *, as they name no resource.

AWS also checks lambda:AddPermission, lambda:GetPolicy or lambda:RemovePermission for the resource
policy operations, and iam:PassRole for CreateCapacityProvider. Floci serves neither, so they are
checked as their own action alone.

docs/services/iam.md says which Lambda routes are mapped and what each is checked against.
2026-10-22 07:24:10 -05:00
Priamo Germosen 8427c0b71d feat(iam): publish delegation request notifications to the partner's topic (#6199)
IAM temporary delegation had no way out. The exchange token is answered by no
operation on the family, so a partner that filed a request could not obtain
what it exchanges, and NotificationChannel was stored with nothing reading it.
DelegationNotifier publishes the two notifications the user guide documents to
the SNS topic the request names, which is the channel AWS gives this feature.

Every state the guide's notification table lists notifies: ASSIGNED,
PENDING_APPROVAL, ACCEPTED, FINALIZED, REJECTED and EXPIRED, leaving only the
UNASSIGNED a request starts in, which the partner filed itself. FINALIZED
sends two, a StateChange and the ExchangeToken notification carrying the token
and an ExpiresAt of release plus SessionDuration. The payload is the guide's
own field list, a JSON string in the Message of an ordinary SNS notification,
with the owner account left out until the request carries one, which a request
filed at a named customer does from the start. A notice is taken wherever a
state is written rather than at each call site, so an expiry found on a read
announces itself the way a claim does, and a call that then fails on the
expired request still sends it. What notifies is a transition: a second
UpdateDelegationRequest on a request already under review writes its notes and
tells the partner nothing. NotificationChannel is held to more than its
declared shape, which is looser than an ARN: the member's own documentation
says only SNS topic ARNs are accepted, so a value naming no topic is refused
on the create with InvalidInput rather than accepted into a lifecycle nobody
would hear about.

IAM publishes as iam.amazonaws.com through ServiceCallAuthorizer, so the topic's
own policy decides and nothing the caller holds plays any part, which is the
statement the guide has partners add to their topic. The request's own ARN and
the account that filed it go as aws:SourceArn and aws:SourceAccount. Both the
policy and the topic are read in the account the topic ARN names: the topic is
the partner's and most of these transitions are the customer's calls, so account
aware storage would otherwise look in the caller's account and find no topic at
all.

Notifications go out once the delegation lock is released, from a snapshot taken
while the transition still owns the record, a stored request being a mutable
instance every caller holding it shares. A delivery that fails costs the
notification and not the transition behind it.
2026-10-22 07:23:56 -05:00
Priamo Germosen 2f57441b84 fix(core): treat a request no protocol claims as the call its route runs (#6200)
With floci.protocols.strict-claiming off, the default, a request that no wire protocol claims is
logged and served by whatever route it matches. The checks after routing read the claim, so they
saw a request of no protocol:
- IAM enforcement served it unsigned. The MissingAuthenticationToken refusal applies only to a
  JSON, CBOR or Query claim. An unsigned SQS ListQueues over JSON or Query, or a Kinesis
  ListStreams over CBOR, was served when it carried a Smithy-Protocol header Floci does not serve
  that path by: an unknown value, or rpc-v2-cbor outside the rpcv2 path. An X-Amz-Target call with
  no Content-Type reached the CBOR endpoint the same way.
- IAM enforcement checked a signed REST request as the action its X-Amz-Target header named, not
  its route's. A user allowed only s3:GetObject deleted an object by sending the DELETE with
  X-Amz-Target: AmazonS3.GetObject and any Smithy-Protocol header. A signed JSON call it refused
  got the REST status, 403, rather than JSON's 400 AccessDeniedException.
- A call to a disabled service was served when only its claim would have named the service, as for
  an unsigned JSON or rpcv2 call.
- A REST JSON service request that fell through to S3's wildcard routes was not rejected, and a
  REST request signed for a service Floci lacks skipped the guard that refuses it before routing,
  so S3's routes answered it with a misleading error.

The new AwsRouteClaimFilter runs after route matching and before every filter that reads the
claim, AccountContextFilter's unknown-Region refusal and the signature check among them. It claims
such a request by the route it reached, through ProtocolClaimer.routeClaim:
- the JSON 1.0, JSON 1.1 and CBOR endpoints by X-Amz-Target;
- the rpcv2 route by its path;
- the Query endpoint's POST by the form;
- every other route as REST.
Those routes serve the request the same way whatever Smithy-Protocol header it carries, so the
claim names the call that runs. A request claimed as REST also gets the unknown-service-scope
check a claimed one gets before routing, which AwsProtocolClaimFilter now exposes for it. A
claimed request is left as it was, and strict claiming still rejects an unclaimed one before
routing.

An X-Amz-Target post with a content type no protocol uses, the third kind of request the
strict-claiming docs list, matches no route at all, and got a 500 rather than its 415, as any root
POST in a content type no endpoint consumes did. Several resource methods share POST /, so RESTEasy
Reactive routes it to a placeholder with no method of its own that picks one by content type, and
answers 415 from there when none consumes it. The ResourceInfo producer then returns the
placeholder's missing method, and CDI refuses the null with IllegalProductException.
AwsRestJsonErrorHeaderFilter and S3CorsFilter read ResourceInfo on every response, so each failed
on it. Both now read it through the new RoutedResource, which gives null when routing chose no
method.

docs/services/iam.md and the strict-claiming setting's docs say how such a request is handled.

IamEnforcementFilter builds its rpcv2 route claim through the same ProtocolClaimer helper.
2026-10-22 07:23:41 -05:00
Priamo Germosen 29384867cf fix(iam): check the Lambda MicroVM and network connector routes (#6122)
Under IAM enforcement no Lambda MicroVM or network connector route was
mapped to an IAM action, so every call went unchecked, and the roles
they take with it.

- Every MicroVM route (2025-09-09) and network connector route
  (2026-04-04) is mapped, and IamRestRouteCoverageTest now checks every
  operation of both models. An image or connector request is checked
  against microvm-image:<name> or network-connector:<id> in the
  request's account and Region, an identifier given as an ARN taken for
  its name, as the service looks it up. RunMicrovm is checked against
  the image its imageIdentifier names, an action on a running MicroVM
  against the image it runs, and a managed image's versions against
  that image, which aws owns. Creating an image or a connector and the
  list operations name no resource, so they are checked against *.
- Lambda's own tag routes, /2017-03-31/tags/<arn>, which MicroVM images
  share with functions, are mapped and checked against the resource
  they tag: the caller's own function, image or connector of the ARN's
  Region and name, whatever account the ARN names, as Lambda looks it
  up, a target without the arn: prefix read as the MicroVM tag handler
  reads it, and an event source mapping's ARN as written.
- iam:PassRole, to lambda.amazonaws.com as the Service Reference gives:
  CreateMicrovmImage and UpdateMicrovmImage (buildRoleArn), RunMicrovm
  (executionRoleArn), and CreateNetworkConnector and
  UpdateNetworkConnector (OperatorRole). This finishes the Lambda half
  of the follow-up on #5938.
2026-10-21 18:37:24 -05:00
Priamo Germosen f731951c53 fix(iam): check iam:PassRole for EC2 Auto Scaling and Application Auto Scaling (#6186)
Under IAM enforcement, a request that handed Auto Scaling a role needed
no iam:PassRole on it. A user allowed only the Auto Scaling actions
could create a group from a launch template whose instance profile holds
any role in the account, and Floci launches the group's instances with
that profile, so they got the role's credentials. The IAM user guide
requires the permission for every role passed to a service, and the EC2
Auto Scaling user guide lists where these operations pass one:

- CreateLaunchConfiguration passes the roles of its IamInstanceProfile,
  given by name or ARN, or else of the profile of the instance it is
  made from, which the configuration copies, to ec2.amazonaws.com.
- CreateAutoScalingGroup and UpdateAutoScalingGroup pass the roles of
  the instance profile in each launch template they name, at the version
  the group launches from, there too: the permission is "needed on the
  IAM identity (user or role) that creates or updates an Auto Scaling
  group using a launch template that specifies an instance profile".
  That covers the group's own template, its mixed instances policy's and
  each override's. StartInstanceRefresh does the same for its desired
  configuration, read merged with the group as Auto Scaling applies it:
  a version named alone moves the group's own template to it, and a
  template named alone keeps the group's version.
- A ServiceLinkedRoleARN other than the default
  AWSServiceRoleForAutoScaling, and a lifecycle hook's RoleARN
  (PutLifecycleHook, and the hooks CreateAutoScalingGroup names), go to
  autoscaling.amazonaws.com. The guide asks for the permission "when a
  nondefault service-linked role, an IAM role for a lifecycle hook, or a
  launch template that specifies an instance profile ... is provided".
- Application Auto Scaling's RegisterScalableTarget passes RoleARN to
  application-autoscaling.amazonaws.com when the request names one.

A group from a launch configuration passes nothing, since the
configuration's role was checked when it was created. Launching an EC2
instance straight from a launch template is unchanged: the EC2 user
guide has that role checked where the template is made.

The launch template version, a source instance's profile and a refresh's
merged template are looked up through PassedRoleLookup, which the Auto
Scaling service now implements with the code its own operations use, so
the filter does not depend on Auto Scaling.
2026-10-21 18:37:02 -05:00
Priamo Germosen 94b09ff46b feat(iam): dispatch UpdateRoleDescription, the description half of UpdateRole (#6029)
UpdateRoleDescription answered UnsupportedOperation 400, where the reference
publishes it as a role operation of its own: "Use UpdateRole instead", and
"modifies only the description of a role. This operation performs the same
function as the Description parameter in the UpdateRole operation". So it is
that path rather than a second one. updateRole now answers the role it wrote,
updateRoleDescription is that call with the session duration left alone, and
the roleNameType check comes along rather than being restated. The handler
renders the Role the operation answers through the same roleXml fragment
GetRole and CreateRole use, detailed, there being no documented exclusion to
honour: the page's Response Elements section lists one Role object and says
only that it "contains details about the modified role".

Both members are required here, where UpdateRole's are optional, and that is
the one place this does not simply delegate. Description is read off the
request rather than through requireParam, which reads a blank value as an
absent member: roleDescriptionType carries a maximum of 1000 and no minimum, so
an empty description is a value that clears the description and only a missing
one is a refusal. It is rendered the way the handler renders every other
missing required member, "Value null at 'description' failed to satisfy
constraint: Member must not be null". RoleName is answered for by
validateRoleName, which reads a null as "Member must not be null" and a bad
shape before any lookup, as the other 21 roleNameType operations have since
#5391.

A service-linked role takes a description edit, through either action. The user
guide says so plainly, "You can edit the description of any role from the IAM
console, API, or CLI", its own procedure for editing one is update-role with
--description or the UpdateRoleDescription API, and it publishes a policy
granting iam:UpdateRoleDescription over arn:aws:iam::*:role/aws-service-role/*
for that. Both actions model UnmodifiableEntity, and a modelled error is not a
list of what triggers it: the guard now stands on MaxSessionDuration, the only
other member UpdateRole takes. So a description-only UpdateRole goes through
where it was refused before, a request carrying both is refused whole with
neither field written, and the other ten protected role actions are untouched.

Authorization needed nothing. AWS gives the action the role resource type in
the vendored authorization metadata, NAME_PARAMETERS already maps role to
RoleName, and ResourceArnBuilder mints the ARN from the stored role, so the
action is authorized against that role rather than against the wildcard. The
routing table has carried the name since routing became generated from the
model, so what changed there is only that it stops falling through to the
unsupported-action arm.

A role Description is held to the shape AWS publishes for it, and on every
action that takes one rather than only the new one: at most 1000 characters of
[\u0009\u000A\u000D -~¡-ÿ], which admits tab, newline and
carriage return and no other control character. CreateRole, UpdateRole,
UpdateRoleDescription and CreateServiceLinkedRole share one
validateRoleDescription, run before the role is looked up or created, so a
refused description never reaches a stored role.

That is more than strictness. XmlBuilder escapes the five XML entities and
passes everything else through, so a control character stored in a description
would make the Role these actions and GetRole answer unparsable, which
CreateRole could already produce before this. The rendering names neither the
offending value nor the set, following the one IAM constraint message a
recording covers, which also keeps the refused bytes out of the error body they
would otherwise break. Reverting the three call sites fails the maximum, the
control character and the sibling cases and nothing else.

Sixteen tests. Ten over the wire in IamRoleDescriptionIntegrationTest: the
description applied and answered, an empty description clearing it, the session
duration and the trust policy untouched, the maximum taken and one character
past it refused with the stored description intact, a control character refused
while tab and newline are taken, CreateRole and UpdateRole answering the same
way with nothing stored, an absent Description refused with the role left as it
was, an absent RoleName, a name outside the shape refused ahead of the lookup,
and an unknown role answering NoSuchEntity. Four on the service: the role that
comes back, the shape across the create and update paths, the name read before
the lookup, and a service-linked role taking the edit while refusing the
duration. Two in IamServiceLinkedRoleIntegrationTest: that allowance over the
wire, and CreateServiceLinkedRole answering ValidationError for a description
outside the shape rather than its own InvalidInput. The protected-actions test
pins UpdateRole on MaxSessionDuration, which is what AWS protects there.

Docs carry the table row, the three ways this differs from UpdateRole, the
description constraint and why it matters for the answer, the carve-out in the
service-linked section, and the matrix row at 176, which check_service_matrix
reads off the handler's own switch rather than taking the number on trust.
2026-10-20 17:17:59 -05:00
Priamo Germosen 77c5d74a7d fix(iam): check the EventBridge Scheduler and Pipes routes (#6044)
Under IAM enforcement no Scheduler or Pipes route was mapped to an IAM
action, so every call to either went unchecked, and the roles they take
with it.

- Every Scheduler and Pipes route is mapped, tagging at /tags as well as
  /tags/<arn>, and IamRestRouteCoverageTest now checks every operation
  of both models. Each request is checked against the resource the
  Service Reference gives: schedule/<group>/<name>, the group read where
  Scheduler reads it (the body's GroupName on a create or an update,
  groupName otherwise, else default), schedule-group/<name>,
  pipe/<name>, the ARN a tagging route names, and * where the request
  names none. Scheduler and Pipes ARNs are minted in the request's
  partition, as those services mint theirs.
- SchedulerController joins the Scheduler descriptor, so a schedule
  request is checked as Scheduler whatever scope signs it. Otherwise one
  signed for another service was checked by that service's rules.
- The shared tagging routes, /tags and /v1/tags, hand a request to the
  service its ARN names, so it is checked as that service, against the
  ARN the controller acts on: the body's resourceArn on POST /tags, the
  query's on the other bare routes. Otherwise a Pipes grant could tag a
  schedule group, a scope with no tagging rule went unchecked, and a
  query ARN could stand in for the body's.
- iam:PassRole: CreateSchedule and UpdateSchedule pass the target's
  RoleArn to scheduler.amazonaws.com, and CreatePipe and UpdatePipe
  their RoleArn to pipes.amazonaws.com, as the Scheduler user guide's
  example policies and the EventBridge user guide say.
2026-10-20 17:17:48 -05:00
Niels Kootstra 73e890dbc7 fix(logs): require the policy type's read permission for DescribeAccountPolicies (#6097) 2026-10-20 17:15:13 -04:00
Aymen JAMAAOUI d0dac9814f fix(redshift): check the extra IAM actions GetClusterCredentials needs (#6067) 2026-10-20 07:29:25 -04:00
Priamo Germosen 24a960a599 fix(iam): check the API Gateway and Lambda routes the action map names, and test them (#6036)
Under IAM enforcement a REST request is checked as the action its route
maps to, and a route no rule maps is let through unchecked. On #5604 the
S3 and API Gateway entries of iam-authorized-actions.json were noted as
never read, since those requests are authorized by route, with a test
comparing them with the route table asked for. This adds that test,
against each operation's real route, and fixes what it found.

- IamRestRouteCoverageTest builds a request on each operation's route,
  as botocore's model gives it, and checks that the registry resolves
  every S3, API Gateway and Lambda entry of iam-authorized-actions.json
  to the action the entry names. The routes are vendored, one operation
  to a line, in src/test/resources/aws/rest-routes.json by the new
  tools/aws/regen_rest_routes.py, which make aws-data-sync and
  aws-data-check now run.
- API Gateway: only /account and /restapis were mapped, so API keys,
  usage plans, client certificates, base path mappings, domain names
  and all of the v2 API went unchecked. The management API is now
  checked as apigateway:<method> on any route, as AWS authorizes it,
  and RejectDomainNameAccessAssociation and PutRoutingRule as their own
  actions. The v2 operations AWS checks only as actions of their own
  names, routing rules and portals, are not served by Floci.
- Lambda: InvokeWithResponseStream went unchecked; it is now checked as
  lambda:InvokeFunction, against the qualified function as an invoke
  is. GetLayerVersionByArn is checked as lambda:GetLayerVersion. It
  shares its path with ListLayers, so a rule can now require a query
  parameter.
- S3: the two bucket metadata configuration entries are not applied.
  Floci serves no metadata configuration, and such a request falls
  through to ListObjects or DeleteBucket, so it stays checked as the
  operation that runs.
2026-10-19 21:32:37 -05:00
Priamo Germosen eba0f72255 fix(iam): check iam:PassRole for ECS, Step Functions, EventBridge and CloudFormation (#5971)
Under IAM enforcement, a request that handed one of these services a role
needed no iam:PassRole on it. A user allowed only ecs:RegisterTaskDefinition
and ecs:RunTask could start a task with any role in the account, and with
ECS task-role credentials on, the task got that role's credentials. The
IAM user guide requires the permission for every role passed to a
service. AWS's Service Reference names the service each operation passes
its role to, and the check now covers these operations as it already
covers Lambda and EC2:

- ECS: RegisterTaskDefinition passes its task and execution roles to
  ecs-tasks.amazonaws.com. RunTask and StartTask pass the task
  definition's roles and any role override, and CreateService,
  UpdateService and CreateTaskSet pass the roles of the task definition
  they name. The infrastructure roles go to ecs.amazonaws.com: a managed
  EBS volume's role, the service role, the load balancer, lifecycle hook,
  Service Connect TLS and VPC Lattice roles, and a Managed Instances
  provider's infrastructure role. A role given by name is the role of
  that name in the caller's account.
- Step Functions: CreateStateMachine and UpdateStateMachine pass roleArn
  to states.amazonaws.com, in a JSON or a CBOR body, gzip-encoded or
  not, since the CBOR endpoint decompresses a body before running it.
- EventBridge: PutRule passes RoleArn, and PutTargets each target's
  RoleArn, to events.amazonaws.com.
- CloudFormation: CreateStack, UpdateStack, DeleteStack, CreateChangeSet
  and ContinueUpdateRollback pass RoleARN when the request names one. A
  later operation that names none reuses the stack's role without the
  check, as CloudFormation does. CreateStackSet and UpdateStackSet pass
  AdministrationRoleARN, or the default
  AWSCloudFormationStackSetAdministrationRole for a self-managed
  StackSet, as the CloudFormation user guide says. An update goes by the
  StackSet's own permission model, which Floci keeps whatever
  PermissionModel the request names.

A role override on RunTask is checked as well as the task definition's
roles, not instead of them, because Floci runs a task with the
definition's task role. The task definition and the StackSet's permission
model are looked up through a new PassedRoleLookup interface, which ECS
and the StackSet service implement, so the filter does not depend on
either service.

Three services are left out. Floci authorizes Cloud Control as
cloudcontrolapi:*, where AWS uses cloudformation:*, so its RoleArn waits
until that namespace is fixed. EventBridge Scheduler and Pipes are REST
services that no IAM route rule maps to an action yet, so enforcement
does not check their requests at all, iam:PassRole included.
2026-10-19 17:07:08 -05:00
Aymen JAMAAOUI 09b14e9d10 fix(s3): check the extra IAM actions a CreateBucket needs (#5961)
* fix(s3): check the extra IAM actions a CreateBucket needs

A CreateBucket whose headers configure the new bucket needs more than
s3:CreateBucket, as the CreateBucket API reference lists:

- s3:PutBucketAcl for a canned ACL other than private, or a grant header
- s3:PutBucketObjectLockConfiguration and s3:PutBucketVersioning for
  x-amz-bucket-object-lock-enabled: true
- s3:PutBucketOwnershipControls for x-amz-object-ownership

S3Controller now checks these actions before the bucket is created, so
a denied request creates nothing.

* chore(s3): move the CreateBucket header actions next to the object ones

S3ObjectActions.bucketCreationActions now gives the actions a
CreateBucket needs from its headers, and reuses GRANT_HEADERS.
EnforcementFixtures.putUserPolicy replaces the test's own PutUserPolicy
helper.
2026-10-19 09:30:22 -04:00
Priamo Germosen b14537baa7 fix(iam): take every access key status the model publishes (#5968)
UpdateAccessKey refused the Expired that statusType permits, answered a
message of its own making, and read the status only after it had looked the
key up, so a bad key carrying a bad status answered NoSuchEntity 404 where the
shape is what AWS answers for. The reference's Valid Values line on the
operation reads "Active | Inactive | Expired" and the pinned model's
statusType holds those same three.

The fix is one call rather than a new rule. requireStatusFromEnum already
serves UpdateSigningCertificate, UpdateSSHPublicKey and
UpdateServiceSpecificCredential: it validates before each of those lookups and
answers the rendering a recording of the third shows, naming neither the
offending value nor the permitted set. UpdateAccessKey was the one operation
of the four not calling it, so it calls it, and the helper's javadoc and the
set behind it say four instead of three.

UserName was the other half. The page carries the sentence DeleteAccessKey
carries, "if the UserName is not specified, the user name is determined
implicitly based on the AWS access key ID used to sign the request", and the
handler passed the raw parameter straight through, so a call that omitted it
compared the key's owner against null and answered NoSuchEntity. It resolves
through resolveUserName now, as GetUser, ListAccessKeys and DeleteAccessKey
do, and AccessKeyId is read through requireParam, as the sibling handlers read
the ids they require.

AWS::IAM::AccessKey refused Expired as well, and its own Allowed values line
in the CloudFormation template reference reads "Active | Inactive | Expired".
Leaving it would have been the same drift on a second surface, and taking
Expired on the API while refusing it in a template is worse than either
alone. The provisioner keeps its own guard, which runs before a key is created
so that a refusal cannot orphan one, and its own message, which names the
resource it refuses.

One more drift came out of reading the method back, and it is the one that
mattered. updateAccessKey is a read-modify-write that took no lock, where each
of the three sibling status operations holds its family's. There was no access
key lock at all: createAccessKey counted a user's keys and only then stored
another, and the user rename rewrote each key's owner outside one, the single
credential family that rename did not guard. Measured before the fix, racing
the calls against each other: an update racing a delete wrote the deleted key
back on 80 of 2000 trials, and four callers racing the two-key quota left more
than two on 226 of 500. One accessKeyLock now covers the count and the store,
the lookup and the delete, the read-modify-write, and the rename's loop, and
the owner check that the delete and the update each carried is one helper.
Substituting a fresh monitor for that lock at all four sites fails the quota
case on its first trial and the resurrection case by its eighty-third.

Three more places the lock has to reach, each measured the same way. The rename
read the key list before taking the lock and rewrote it inside, so a delete that
landed in between was undone and the key came back under the new name, where it
authenticates again; the read moves inside the lock, where every other
credential family already reads its own, and putting it back outside fails by
the third trial. createAccessKey confirmed the user before taking the lock and
deleteUser checked for keys without holding it, so a create could store a key
for a user the delete had just removed; the confirmation moves inside the lock,
the way UploadSigningCertificate's already is, and deleteUser holds the lock
across its key check and the delete, outermost of the five it nests, which is
the order UpdateUser leaves intact by taking that lock on its own. Reverting
either half alone puts the orphan back, by the seventeenth trial and by the
second.

Fifteen tests. Seven over the wire: Expired stored and read back, a status
outside the set, an absent status, an absent key id, the order against a key
that is not there, a call that names no user, and another user's key still
answering NoSuchEntity. Three on the service for the three statuses, the
order, and the absent status. One on the provisioner for a template declaring
Expired. And four in IamConcurrencyTest, which raced six collections and
no credential family before this: an update against a delete, four creates
against the quota, a rename against a delete, and a create against DeleteUser.
The two refusals also read the key back, over the wire and on the service, so a
validation that wrote before it refused would not pass them. What is left is
the count: AWS reports "2 validation errors detected" when the id and the
status are both wrong, where every message here leads with one, which is the
follow-up #5280 already carries.
2026-10-19 07:45:19 -05:00
Priamo Germosen f0975a9f47 fix(iam): check iam:PassRole when Lambda or EC2 is passed a role (#5938)
Under IAM enforcement no request was checked for iam:PassRole. A user
allowed only lambda:CreateFunction, or ec2:RunInstances, could give the
function or the instance any role in the account, and Floci runs the
function with that role and serves the instance its credentials, so the
user could act with the role's permissions.

A request that passes a role to Lambda or EC2 now also needs
iam:PassRole on that role, as the IAM user guide requires: "To pass a
role (and its permissions) to an AWS service, a user must have
permissions to pass the role to the service." The check offers
iam:PassedToService, the service AWS's Service Reference names for the
operation, so a grant to pass a role to one service does not cover
another. It covers Lambda's CreateFunction, UpdateFunctionConfiguration
when it sets the role, CreateWebFunction and CreateWebFunctionRevision,
and EC2's RunInstances, RequestSpotInstances,
AssociateIamInstanceProfile, ReplaceIamInstanceProfileAssociation,
CreateLaunchTemplate and CreateLaunchTemplateVersion, which pass the
roles of the instance profile they name, and CreateFlowLogs. A Spot
Instance request now takes its instance profile by name as well as by
ARN, as RunInstances does, so the role checked is the one the instance
gets.

Launching from a launch template checks nothing, as on AWS: the EC2 user
guide warns that whoever can create a template version can pass its
role without iam:PassRole. The role parameters of other services are
left for later changes.
2026-10-18 20:43:15 -05:00
Priamo Germosen 494a6725a1 feat(iam): release and exchange the delegation token (#5914)
M4a dispatched the delegation request lifecycle as far as ACCEPTED and
stopped there, so no request reached FINALIZED and the credentials the whole
feature exists to hand over could not be obtained at all. This is the token
half: IAM SendDelegationToken and STS GetDelegatedAccessToken, the last two
of the ten operations the family spans.

SendDelegationToken takes a request id, answers no output shape, and moves an
ACCEPTED request to FINALIZED. The reference says that "cannot be rolled
back", which makes it the one transition that refuses to repeat itself:
releasing twice answers ConcurrentModification, the wrong-state shape the
other four writers already use. Releasing mints the token and records the
instant it happened, both on the request, because the shape publishes neither
and nothing else is going to hold them.

Releasing is also where OnlySendByOwner is finally read. M4a stored the flag
with nothing looking at it, which was right while nothing could release;
SendDelegationToken is the one operation it speaks to. It "prevents any party
other than the owner from calling SendDelegationToken API for this delegation
request", for the case the reference spells out: the owner lacked the
permission to approve, forwarded the request to a more privileged user, and
still has to be the one who hands the token over. So the release is the one
call on this family decided per identity rather than per account, the handler
passing the caller ARN as associate and accept already do, and an approver who
is not the owner answers AccessDenied 403, which the API reference publishes
as a common error for every IAM operation.

GetDelegatedAccessToken exchanges that token for credentials in the
customer's account. The delegation period "starts when customer releases the
exchange token, not when the product provider redeems it", and "all
credentials obtained from the same exchange token expire at the same time",
so the expiry is release plus SessionDuration whenever it is redeemed and a
token can be exchanged repeatedly, each exchange buying less time than the
one before. AssumedPrincipal is the identity that approved the request rather
than the one that claimed it: accepting a request "records the details and the
state of the identity that called this API", and "this is the identity that
gets mapped to the delegated credential", which the user guide says the same
way, the provider obtaining the "approver's temporary credentials". The two
are the same identity until a request is forwarded for approval, which is the
case OnlySendByOwner serves. PackedPolicySize is left out: the model
deprecates it and states it is not populated for this operation.

Two answers had to be chosen rather than read off, both forced by the error
set. GetDelegatedAccessToken models exactly three errors, and none of them
says "no such token", so a token nothing matches is answered as an expired
one: from the caller's side the two are the same situation, and the
reference's own remedy, "Request a new token and retry the operation", fits
both. A token offered by an account that did not file the request answers
AccessDenied 403 instead, the shape this handler already uses for a caller
who may not perform the operation, because "the exchange token can only be
redeemed by the product provider account that created the delegation
request" is a refusal rather than an expiry. The account is checked before
the window so that neither guard can hide the other, and both are tested
with the other one passing.

The code is ExpiredTradeInTokenException, not ExpiredTradeInToken. The model
writes the Exception suffix into error.code for that shape and for
RegionDisabledException while PackedPolicyTooLarge drops it, so each code is
read off its own shape rather than derived from the shape's name.

What the credentials carry is the request's PermissionPolicy, the policy AWS
renders from the partner's registered template. No API registers a template,
so nothing sets it and the session carries none, which is where M4a left
PolicyTemplateArn for the same reason.

The session is filed in the customer's account with no issuing key, and as a
delegated session rather than an issued one. The delegation is the customer's
grant, so a partner key that happened to name an IAM user must not become the
session's issuer: issuingUser bounds a session by the issuer's own
permissions, which would be the partner's rather than what the customer gave
away. The approver is carried in a field of its own for the same reason the
issuer is left empty. An issued session holds its identity in the role ARN
slot, which is resolved by name, so an approver named like a role would act
with that role's permissions, one named like no role would act with none, and
GetCallerIdentity would answer for a role that does not exist. A delegated
session instead resolves its approver from what the ARN says it is: a user's
own policies and boundary, the account's access where the root approved the
request, the role behind a session assumed from one, and nothing where that
identity is gone. The account is the owner's either way, a request being
visible only from the account that claimed it. The request's PermissionPolicy
still bounds it on top wherever one exists, which is where the registered
template would land.

One gap this step cannot close on its own. AWS publishes the exchange token
only in the ExchangeToken notification on the partner's SNS topic, and no
operation on the family answers it. Floci sends no notification yet, so the
token is minted onto the record and nothing hands it back over the wire. The
integration test reads it from the service for that one step and drives
everything either side of it over the wire.

Twenty-one tests: eight on the service covering the release, the owner-only
flag either way, the repeated exchange, both refusals and the window, with a
clock the test owns, eight over the wire across the two accounts, one on the
handler holding the session to the customer's account and to its approver, and
four under IAM enforcement on what the credentials may then do: an approver
allowed to read and not write, whose delegated credentials do exactly that, a
request forwarded to an administrator who approved it, whose credentials write
where its owner can only read, a role carrying the approver's name that lends
them nothing, and a request approved by the account root. Four probes, each
reverting one thing: mapping the credentials to the owner fails the forwarded
case and the handler test and nothing else, anchoring the expiry at the
redemption instant fails the two tests that describe it, filing the session
against the partner fails the one that holds it, and dropping the owner-only
guard fails the one that asks for it.
SendDelegationToken joins the delegation family in ResourceArnBuilder, AWS
giving it the delegation-request type, so it is authorized against the
request rather than the wildcard. Routing needs nothing added since #5879
reads each service's actions from its botocore model, which names both of
these, so the matrix rows in docs/services/index.md are the only counts this
moves: IAM 174 to 175 and STS 7 to 8.
2026-10-18 20:43:05 -05:00
Niels Kootstra e9154fb928 fix(logs): require the policy type's own permission for PutAccountPolicy (#5956) 2026-10-18 20:37:16 -04:00