Commit Graph
113 Commits
Author SHA1 Message Date
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
Priamo Germosen c17bd49096 fix(s3): check bucket policies for the actions IAM checks (#5913)
S3's own access check under floci.services.s3.enforce-auth, which
evaluates bucket policies and ACLs, lagged behind IAM enforcement. It
checked a version's tagging, ACL and annotation requests as the base
actions, an object created with tags, an ACL or Object Lock settings as
s3:PutObject alone, GetObjectAttributes without the read, and a write
carrying If-Match without the read IAM checks for it. It offered a
bucket policy none of the request's condition keys, and asked for
s3:BypassGovernanceRetention on an annotation delete, which the user
guide says the permission "does not apply to".

The bucket-policy check now checks the actions IAM does: the version
counterpart when a request names a versionId, the tagging, ACL,
retention and legal-hold actions an object creation's settings need, a
copy of a tagged source included, s3:GetObject beside
s3:GetObjectAttributes and beside an If-Match write, and no bypass
permission on an annotation delete. A signed request's bucket policy is
offered the tag and Object Lock keys the request sets: an object
creation's headers and the tagging, retention and legal-hold bodies,
read by the same S3ObjectActions helpers IAM's condition resolver now
uses.

s3:BypassGovernanceRetention is asked for only by a request that
overrides a governance lock, by IAM and by the bucket policy. The user
guide's permissions table requires it "if you want to delete an object
that's protected by governance mode" and to "bypass the governance mode
of an Object Lock retention configuration", and DeleteObjects already
asked for it only then. DeleteObject and PutObjectRetention asked for
it whenever the header was sent; they now ask only for a delete that
removes a version under a governance lock, not one that only adds a
delete marker, and for a retention change that shortens or removes one.

The IAM condition resolver now reads the object key from the path as
it arrived, as S3Controller does, through the new S3ObjectKeys: the
normalized path drops a key's leading slash, so the lock and the
s3:ExistingObjectTag tags of "/doc" were looked up on "doc". A CopyObject
replacing its source's tags reads x-amz-tagging from the query as well,
as PutObject does, so it applies the tags both checks saw. An anonymous
creation that a public bucket ACL's WRITE grant admits may still apply
its ACL, tags and Object Lock settings, unless a public bucket policy
decides their actions, since an ACL grant names no actions.

The creation checks are told whether a request is a CopyObject rather
than guessing it from x-amz-copy-source, which a CreateMultipartUpload
ignores while it applies its own tags, so those tags are always
checked, by IAM and by the bucket policy. With an access check on, a
DeleteObject, a DeleteObjects entry and a PutObjectRetention hand
S3Service the bypass only when they override a lock whose bypass
permission the checks approved, IAM's decision travelling in
RequestContext, so a lock set after the checks is refused rather than
bypassed unchecked.

Refs #5716
2026-10-18 09:28:33 -05:00
Priamo Germosen 377c09733a fix(s3): check a presigned copy's source read against its credential (#5891)
Under IAM enforcement, CopyObject and UploadPartCopy also need
s3:GetObject on the copy source, or s3:GetObjectVersion for a version,
and S3Controller checks it itself, since the source appears only in the
x-amz-copy-source header. It passed IAM the Authorization header, which
a presigned request does not have, so IAM skipped the check. A user
allowed to write one place could presign a copy of any object they
cannot read into it.

The check now uses the request's credential, the header's or a
presigned URL's query credential, as the copied-tags check next to it
already does. The S3 user guide says "The capabilities of a presigned
URL are limited by the permissions of the user who created it."

The test signer's presignedQuery also signs the parameters already in
its URI's query, such as an UploadPartCopy's upload id, so a presigned
part copy verifies, and refuses a URI that is already presigned. docs/services/iam.md lists the copy source check.
2026-10-17 22:31:36 -05:00
Priamo Germosen 66fce77bdc feat(iam): generate, claim and answer delegation requests (#5797)
IAM temporary delegation lets an AWS Partner ask a customer for scoped,
time-limited access to the customer's account: the partner files a request,
the customer claims and answers it, and an accepted request releases an
exchange token the partner trades for credentials. Floci dispatched none of
it, so all seven lifecycle operations answered UnsupportedOperation 400.

The family was filed as a non-goal on the strength of
CreateDelegationRequest stating "This API is not available for general use.
In order to use this API, a caller first need to go through an onboarding
process described in the partner onboarding documentation". That sentence
appears exactly once in the whole API reference, and the partner user guide
describes a generally available feature with a published lifecycle. The gate
is an AWS-side account allowlist for ISV Accelerate partners, "Enable API
access for your specified accounts", not a protocol behaviour, and an
emulator has no allowlist. Answering NoSuchEntity because nothing can exist
would emulate the feature's absence rather than the feature.

This is the lifecycle half: Create, Associate, Accept, Reject, Update, Get
and List. SendDelegationToken and STS GetDelegatedAccessToken are the token
exchange and come next, so no request reaches FINALIZED yet, and
GetHumanReadableSummary stays undispatched because its summary is LLM-
generated on AWS.

A delegation request is the one IAM record two accounts share, which decides
how it is stored: keyed by id under the creating account and resolved across
accounts on read, because the reference makes the id globally resolvable and
decides access from the request's own owner fields. A request nobody owns
"can be called by any account"; one naming a target account is readable only
from there, which is why a partner loses sight of its own filing once it is
aimed. Floci decides that at account granularity, there being no per-
identity permission on a request to consult. ListDelegationRequests leaves
out a request with no owner even when it names the listing account, as the
reference states, so a partner does not list its own filings at all, which
matches the guide telling partners to track state from the notifications.

Expiry is applied when a request is next read rather than swept by a worker.
Each state carries the window AWS publishes, a day for UNASSIGNED and a week
for every other state including the terminal ones, and a request past its
window reads back as EXPIRED. That needs no scheduler to be correct and no
clock to be mocked globally, so the service takes its own Clock and the unit
test advances that rather than the shared test clock.

Two answers had to be chosen rather than read off. An operation asked to move
a request out of a state it no longer holds answers ConcurrentModification:
no modeled error says "wrong state", and AcceptDelegationRequest models only
NoSuchEntity, ServiceFailure and ConcurrentModification, so the conflict is
the closest of the three and is used on all four writers rather than a
different code each. PermissionCheckResult answers UNSURE when the check is
asked for, which the enum models, because a delegation request carries no
permission to evaluate.

A member that breaks the format or constraints it declares answers
ValidationError. The reference publishes that as a common error, "the input
doesn't meet the required format or constraints", for every IAM operation
while listing it on no operation at all, which is why it appears in no error
table and in none of these; the rest of IAM answers it in the same shape and
wording, so these operations do too. The InvalidInput they do model is kept
for a value that cannot be read as the member's type, which is where the
shared pagination already puts a MaxItems that is not a number.

A lifecycle call reads a request, checks its state and writes it back, so all
of them take one lock, as the sibling IAM services do with theirs. Without it
two callers could both claim the same unassigned request and the later write
would decide the owner, and two creates could both pass the workflow-id
uniqueness check. Each call also takes a single clock reading, threaded from
the lookup into the transition, so a request cannot be expired on the way in
and moved on anyway.

Two shape details come from the pinned botocore model rather than the
reference PDF, which omits both: GetDelegationRequest also takes
DelegationPermissionCheck and answers PermissionCheckStatus and
PermissionCheckResult, and ListDelegationRequests spells its flag
isTruncated in lower case where every other IAM list spells it IsTruncated.
The model names the member, so the wire follows the model. SessionDuration's
300 to 43200 range, PolicyParameter's shape and the 100-default,
1000-maximum page size come from there too.

The CLI reference supplies the constraints the PDF leaves hard to read: the
redirect URL's whole pattern, which the PDF breaks across a line, the
character class the free-text members carry, and the printable-ASCII class
on a policy parameter's name and values. Each is enforced. It also settles
that the Permissions structure is required while both of its members are
optional, marking neither. Reading it is what caught an empty required
member being treated as an omission: Description is required and its pattern
permits an empty string, so Description= is a value and only an absent
member is missing, which is a distinction that exists on the wire and is
tested there.

Notes and RejectionReason both exist on the shape and each gets exactly one
writer: an update carries notes for an administrator and a rejection carries
the explanation the reference describes for it.

An indexed member is read from the keys the request carries rather than
counted up from one, so Parameters.member.2 without a member.1 keeps its
entry instead of being dropped at the gap, and a boolean member has to carry
true or false rather than being read as false for anything else.

delegation-request leaves ResourceArnBuilder.UNRESOLVED_TYPES, since that
entry claimed the type belongs only to actions nothing dispatches. The four
by-id actions mint arn:<partition>:iam::<account>:delegation-request/<id>
from the request, the same way the ARN-carrying actions pass an ARN through,
one step earlier. CreateDelegationRequest stays at the wildcard because IAM
assigns the id, and UpdateDelegationRequest stays there because AWS
publishes no authorizable action for it at all.
UnresolvedResourceTypesIntegrationTest would have failed until this was
done, which is that test working as intended.

The console deep link follows the partition too. CreateDelegationRequest
answers the URL the partner redirects the customer to, and a caller in China
or GovCloud was handed a console their account cannot reach. The host now
comes from the region's partition, the way the CodePipeline approval links
already resolve theirs, keeping the commercial console's path because that
is the only path any partition publishes. The account-root stand-in behind
an owner ARN is minted through RegionResolver for the same reason rather
than concatenated, which is also the shape IamEnforcementFilter synthesizes.

Nothing is enforced that AWS does not publish. LimitExceeded is modeled with
no quota behind it, so none is invented. NotificationChannel is validated
and stored and nothing reads it, there being no notification to send yet.
PolicyTemplateArn is kept as given and resolved against nothing, templates
being registered by email with no API.

All four new model types are registered for reflection, the state enum
included: it is reachable from a stored request, and a native image that
cannot read it back loses every delegation request on restart, which is what
the persistence guard checks.

Twenty-seven unit tests drive the state machine, both expiry windows, the
two races and the deep link in each partition, with a clock the test owns,
and fifteen integration tests drive the lifecycle over the wire across two
accounts, the access key id being the account id as the rest of the suite
does it. Routing needs nothing added: #5879 has the Query router read each
service's actions from its botocore model, which names all seven already, so
the matrix row in docs/services/index.md moving 167 to 174 is the only count
this changes.
2026-10-17 22:31:06 -05:00
Priamo Germosen b0777a4020 fix(iam): check the actions an S3 operation needs besides its own (#5846)
Under IAM enforcement an S3 object operation was checked only as its own
action. A PutObject, CopyObject or CreateMultipartUpload that set tags,
an ACL, a retention period or a legal hold needed only s3:PutObject,
GetObjectAttributes needed only the read, and a retention change or a
delete asking to bypass governance retention needed no
s3:BypassGovernanceRetention. No Object Lock condition key was offered.

Each now also needs the actions the S3 user guide's permissions table
and the API references require besides its own. An object creation
needs the action of each setting it applies: s3:PutObjectTagging,
s3:PutObjectAcl, s3:PutObjectRetention or s3:PutObjectLegalHold. A copy
under the default COPY tagging directive keeps a tagged source's tags,
so it needs s3:PutObjectTagging too, checked where the source is read
against the request's credential, a presigned URL's included, and it
offers no request tag keys from the x-amz-tagging header it ignores.
GetObjectAttributes needs s3:GetObjectAttributes, or
s3:GetObjectVersionAttributes for a version. A PutObjectRetention or
DeleteObject that sends x-amz-bypass-governance-retention needs
s3:BypassGovernanceRetention; an annotation delete does not, as the
user guide says the permission does not apply to annotation operations.

s3:PutObject, s3:PutObjectRetention and s3:PutObjectLegalHold are
offered the Object Lock keys from the request's headers or body, and an
object creation offers its tag and Object Lock keys to each extra action.
A denial names the missing permission, and CloudTrail records the
operation that was refused, PutObjectRetention and GetObjectAttributes
included. Generated presigned URLs refuse all four creation settings,
as they refused tags.

Refs #5716
2026-10-17 10:17:28 -05:00
Suja Shaj a611e9ea6f fix(iam): authorize Secrets Manager requests against the secret's ARN (#5781)
* fix(iam): authorize Secrets Manager requests against the secret's ARN

IAM enforcement evaluated CreateSecret against secret:* because the
builder read only SecretId, and a secret named by its name was evaluated
as secret:<name>, without the random suffix every secret ARN carries.
A secret:<name>-?????? policy, the pattern AWS documents for granting
access to a secret that may not exist yet, matched neither.

CreateSecret is now evaluated against secret:<Name>-??????, standing in
for the suffix that is assigned at creation, and a name-based SecretId
resolves to the stored secret's full ARN in the target account.

Closes #5364

* fix(iam): pick the Secrets Manager target by the serving operation

CreateSecret now reads only Name and other actions only SecretId, so a
field the handler ignores cannot choose the resource. Minted ARNs take the
request's partition, and a name lookup also reads a legacy unprefixed
secret for the default account. Adds an SDK compatibility test.

* fix(iam): resolve a partial-ARN SecretId to the stored secret's ARN

A SecretId given as an ARN without the random suffix is now authorized
against the stored secret's full ARN, resolved in the caller's account in
the order the operations use: an exact ARN first, then the ARN read as a
partial one. The enforcement tests share EnforcementFixtures' auth, a new
assumeRole helper, and a new createRole helper that removes the role after
the test. The Secrets Manager enforcement test also deletes the secrets it
creates.
2026-10-16 23:24:38 -04:00
David Phillips 92be67d2df fix(logs): enforce group permissions for lifecycle changes (#5840)
* fix(logs): enforce group permissions for lifecycle changes

* fix(logs): accept bare group ARNs in lifecycle policies
2026-10-16 20:59:38 -04:00
Mario Toffia 2f56c225dc docs(iam): note which resource policies are not evaluated (#4899)
The IAM page says S3 bucket, Lambda function and SNS topic policies take
part in request authorization, but not that SQS queue and API Gateway
REST API policies are stored without being evaluated.

Add that next to the S3, Lambda and SNS bullets. No behaviour changes.
2026-10-16 20:11:34 -04:00
David Phillips 49a3ff9a10 fix(logs): bind ARN tag operations to their owning group (#5810)
* fix(logs): bind ARN tag operations to their owning group

* fix(logs): preserve literal names in tag requests

* test(logs): share authorization fixtures
2026-10-16 18:23:59 -04:00
Priamo Germosen 7e98592761 fix(s3): act on the object version a tagging request names (#5775)
PutObjectTagging and DeleteObjectTagging ignored versionId and changed the
current version. GetObjectTagging dropped it in the controller, so it read
the current version too, and the service took versionId=null as the
current version even on a key that has no null version.

All three now act on the version named. "null" names only the null
version, the object stored without a version id; on a key that has none
the request answers NoSuchVersion. Each returns the version it acted on in
x-amz-version-id. A request on a delete marker, named or current, answers
405 MethodNotAllowed with Method and ResourceType, and with
x-amz-delete-marker: true, as S3 does. A put or delete runs under the
bucket monitor that writes, deletes and the lifecycle sweep hold, so a
version deleted between the lookup and the write is not written back.

Since they act on the version named, a request naming one is now checked
as s3:GetObjectVersionTagging, s3:PutObjectVersionTagging or
s3:DeleteObjectVersionTagging, carrying s3:versionid, in place of the base
tagging action. Part 1 kept these requests on the base actions because the
operations changed the current version. The s3:ExistingObjectTag lookup
already read the version named, so the tags a condition sees are now those
of the version the request changes.

The IAM condition context still reads s3:ExistingObjectTag for
versionId=null from the current version, which GetObject still serves for
it, so a deny on those tags keeps applying.

Refs #5716
2026-10-16 07:55:28 -05:00
Priamo Germosen 608a38bff3 fix(iam): read a role trust policy with the caller's principal keys (#5770)
A role's trust policy was the one context a request is evaluated against that
did not say who was calling. AssumeRolePolicyEvaluator assembled its own map
and put aws:PrincipalArn into it alone, so a trust policy keyed on aws:userid,
aws:PrincipalType or aws:username could not match, where every other context a
request is evaluated against carries all four through
CallerArns.putPrincipalKeys. The user guide puts aws:PrincipalType and
aws:userid in "the request context for all requests, including anonymous
requests" and aws:username in it for every IAM user, and an sts:AssumeRole
request is no exception: the guide's own example of a resource-based policy
tells principals apart in a Condition on aws:userid. Raised by hectorvent on
the review of #5568 and left to its own PR.

The evaluator now takes the caller's CallerArns in place of its two ARN
strings and writes the keys through that single writer, so no second context
has to be kept in step. STS passes the caller it already resolves, and a
credential that resolves to no identity is the account root stand-in it
already names in its denial, now with the account's own keys: the guide gives
the root user the account id as its aws:userid, the type Account and no
aws:username, which is what S3 and the enforcement filter already build for
it. That construction had three copies and is now one factory on the record.

Step Functions passes the execution role as the session it is, carrying
AssumedRole as its aws:PrincipalType: it assumes that role on the state
machine's behalf, so a target role's trust policy may condition on the type.
It mints no session name there, and a session's aws:userid is
role-id:session-name, so that key and aws:username stay absent.

AssumeRolePolicyEvaluatorTest builds its callers through the record, with
three cases on the keys: a condition on aws:username matching the caller and
not matching the same caller carrying no keys, aws:PrincipalType and
aws:userid telling a user apart from a role session, and a value the caller
carries winning over the request's own copy.
AssumeRoleTrustConditionsIntegrationTest signs four more AssumeRole calls end
to end, over a condition on the calling user's name, on the principal type, on
the root stand-in's account id, and on a session's role-id:session-name.
Reverting the evaluator to aws:PrincipalArn alone fails all seven; writing the
keys with putIfAbsent instead fails the precedence case alone.
LambdaTaskAuthorizerTest covers the Step Functions caller from both sides, a
trust condition on the principal type matching it and one on the session's own
id not matching.
2026-10-16 07:55:16 -05:00
Priamo Germosen 21184df828 fix(iam): authorize S3 object operations as the actions S3 documents (#5756)
Under IAM enforcement, CreateMultipartUpload, CompleteMultipartUpload, RestoreObject and
SelectObjectContent were never checked against the caller's identity policies. They are POST
requests, the registry had no S3 POST rule, and an action no rule maps is allowed. A user with no S3
permission could start and complete multipart uploads, restore objects and read them through
Select.

Many other S3 requests were checked as the wrong action:
- ListParts and AbortMultipartUpload as s3:GetObject and s3:DeleteObject.
- Object retention and legal hold as s3:GetObject and s3:PutObject, so a user allowed only to write
  objects could set a retention period or a legal hold.
- Object annotations as the plain object actions.
- A request naming a versionId as the current-version action. A deny on s3:DeleteObjectVersion, the
  usual guard against permanent deletes, did not stop one, and reading a version needed s3:GetObject
  rather than s3:GetObjectVersion.
- Analytics, inventory and Intelligent-Tiering configurations as s3:ListBucket, s3:CreateBucket or
  s3:DeleteBucket.
- DeleteBucketTagging as s3:DeleteBucketTagging, which is not an IAM action. A policy naming it
  granted the call, and one granting s3:PutBucketTagging, the action AWS checks, was refused.
- A request naming two sub-resources as the first one the registry looked for. The controller runs
  a different one: GET ?acl&tagging returns the tags while needing only s3:GetObjectAcl.

The object sub-resources are now resolved per method, in the order S3Controller dispatches them. A
versionId selects the version action AWS checks for a read, head, delete, ACL or annotation
request, and for Select, which S3Controller runs on the version named; the bucket configurations
follow the controller's bucket chains. Tagging keeps the tagging actions: the tagging operations
still act on the current version whatever versionId names, so a version tagging action would
authorize one version and let the request change another.

The actions come from the S3 user guide's "Required permissions for S3 API operations" and
multipart permissions tables, the API reference and the Service Reference:
- s3:PutObject for creating and completing an upload;
- s3:RestoreObject, and s3:GetObject for Select;
- s3:AbortMultipartUpload and s3:ListMultipartUploadParts;
- the retention, legal-hold, version and configuration actions;
- s3:PutBucketTagging for DeleteBucketTagging, and each configuration's Put action for its delete.

A write carrying If-Match already needed s3:GetObject as well. The conditional-writes guide lists
PutObject, CopyObject and CompleteMultipartUpload as the operations that take the header, so now
that completing an upload is checked as s3:PutObject it gets that check too, while
CreateMultipartUpload and UploadPart, which ignore the header, no longer do.

A conditional delete with an If-Match ETag already needed s3:GetObject. A delete naming a version is
now s3:DeleteObjectVersion, so that check covers it too, still as s3:GetObject: the
conditional-deletes guide evaluates the condition against the current version only.

Condition keys, per the Service Reference:
- s3:versionid is given to the version actions.
- s3:ExistingObjectTag is given to the version actions and the annotation actions, read from the
  version the request names.
- DeleteBucketTagging, checked as s3:PutBucketTagging, keeps the bucket's tags in its context.

CloudTrail denials name the version actions' operations, and give no name to a POST operation
rather than a wrong one.

The actions an operation needs besides its own, S3 behaviour behind these checks and S3's own
bucket-policy check follow separately (#5716).

Refs #5716
2026-10-15 22:14:39 -05:00
Priamo Germosen b58d181a30 feat(iam): authorize the account password policy's self-service flag (#5717)
The account password policy accepted AllowUsersToChangePassword, echoed it
back from GetAccountPasswordPolicy, and no authorization decision read it: the
six references in src/main were the field, its accessors, the setter call and
the XML element. So under enforcement a user needed a policy naming their own
user however the flag was set, and the option AWS describes as account-level
authorized nothing.

The user guide: the option "gives users access to the iam:ChangePassword
action for only their user and to the iam:GetAccountPasswordPolicy action",
and it "does not attach a permissions policy to each user. Rather, IAM applies
the permissions at the account-level for all users."

So it is one document for the whole account rather than a grant assembled per
user: iam:ChangePassword on user/${aws:username} and on
user/*/${aws:username}, the two patterns AWS's own IAMUserChangePassword
policy writes, the second for a user under a path, plus
iam:GetAccountPasswordPolicy. The resource ARNs are minted in the request's
partition, for the account whose password policy sets the flag.

Writing it with the variable rather than the caller's resolved ARN is what
makes it the grant the guide describes, and it carries two properties for
free. The scope to "only their user" is the variable's, so one stored document
serves every user in the account. And the grant belongs to IAM users without a
principal check of its own: a role session and the account root have no
aws:username, the variable resolves to nothing, and a resource holding a
variable with no value "will not match any resource". It therefore rests on the
substitution #5639 added, now on main; without it the statement is literal
text and matches nobody, which is what the probe below shows.

The grant reaches the caller wherever the principal is an IAM user: its own
access key, a session token it minted, and the simulate path. It is appended
to the identity policies the evaluator already reads, so nothing about
evaluation order changes: an explicit Deny still refuses the call and a
permissions boundary still caps it. collectUserPolicies stays the user's own
set, so ListUserPolicies, ListAttachedUserPolicies and
GetAccountAuthorizationDetails report nothing new, which is the "does not
attach a permissions policy" half of the guide.

That half holds for the answers AWS scopes to attached policies.
ListPoliciesGrantingServiceAccess reports policies by name and type and has
none to report here, and GetContextKeysForPrincipalPolicy returns "only
context keys referenced by the identity-based policies attached to the
specified entity, and any additional policies that you provide", so it reads
the attached set rather than the evaluated one: it had been naming the
${aws:username} of the grant's own resource, twice, once per pattern, out of
a document the user does not hold.

A last-accessed report answers the other question, "every AWS service that
the resource could access using permissions policies", and an account-level
permission is one the user can reach: GenerateServiceLastAccessedDetails
lists iam for a user carrying no policy of their own while the flag is set,
and nothing for that same user once it is cleared. The grant goes into the
documents the service list is read from rather than into the policies the
report names, since it is no policy of the user's and has no name or ARN to
report as one.

One thing the variable form exposed. SimulatePrincipalPolicy built its context
from the call's ContextEntries alone, so a policy scoped to ${aws:username}
simulated as if the key were absent and this grant answered implicitDeny for a
permission the account really gives. The guide lists what a simulation starts
with, "aws:PrincipalAccount, aws:PrincipalId, aws:PrincipalType, aws:Type,
aws:UserId, aws:UserName", adding that "because these keys are populated for
you ... You provide the values for all other condition keys". So the handler
now populates them for a user policy source, through the same CallerArns
writer the enforcement filter uses, which makes a simulation read what an
enforced request reads: aws:PrincipalArn, aws:PrincipalType, aws:username,
aws:userid and the account. The guide's aws:PrincipalId and aws:Type are in no
request context here, so a simulation does not invent them either, and iam.md
says so rather than leaving the list to imply all six. A value the call
supplied still wins, in whatever case it spelled the key, since the context is
keyed the way the evaluator compares key names: keyed by the raw spelling, a
supplied aws:principaltype and a populated aws:PrincipalType were two entries
and the later lowercasing kept whichever hashing happened to reach first. The
account comes from the identity that resolved rather than from the ARN the
call wrote, which need not be one this emulator can parse: a PolicySourceArn
is resolved by its trailing name, so arn:aws:iam:user/bob names a user while
parsing as nothing, and parsing the request's own text turned that call into a
500. A role named as the source is not a session: there is no session name for
an aws:userid and no documented aws:PrincipalType for it, so those keys stay
absent and a statement matching on one does not match.

The flag that answers for a user is their own account's. A PolicySourceArn is
the one way to name a user elsewhere, and the lookup already resolves them in
the account their ARN names, so the flag is read there as well and the grant's
resource ARNs are minted for that account. This account's grant therefore
never resolves ${aws:username} to a user its password policy does not cover,
and a user of another account is not refused a permission their own account
really gives: an allowed answer needs their account to set the flag and the
resource to be theirs.

Thirteen integration tests under enforcement: the flag letting a user with
no policies change its own password and read the policy, the grant appearing
in neither listing nor in GetAccountAuthorizationDetails, nor among the
context keys a simulation's caller is told to supply, while a policy the
user really carries appears in all three, a last-accessed report listing iam
for a user carrying nothing else while the flag is set and nothing once it
is cleared, an explicit Deny of iam:ChangePassword still refusing the call,
a permissions boundary still capping it, the grant reaching none of GetUser,
UpdateLoginProfile or CreateUser, the flag read both ways by one user whose
policies never change, the scope checked through SimulatePrincipalPolicy
against another user's ARN, a supplied context value surviving a key spelled
in another case, a PolicySourceArn that parses as nothing still simulating,
this account's flag not reaching a user of another account, and that user's
own account's flag reaching them over their own ARNs. Each of the
authorizing ones ends on something only the grant allows, which the first
round of them lacked: two asserted refusals alone and passed with the grant
withheld. Probed six ways, by withholding the grant, by disabling
substitution, by dropping the simulator's populated keys, and by reverting
each of three tests' fixes, failing all ten, all ten, the one simulation,
and one test apiece. The three added here were probed the same way, one
behaviour at a time: the other account's user went back to implicitDeny, the
context keys answered aws:username twice, and withholding the grant from the
report emptied it.

Verified on main: 6680 tests across the 342 IAM, core, enforcement and
resource-policy classes that reach the evaluator, 13 skipped and none
failing, with Checkstyle, docs-check and partition-check clean, the last
because the grant mints its resource ARNs rather than writing a partition
literal.
2026-10-15 22:14:18 -05:00
David Phillips dbe7fdb92e fix(logs): enforce stream resource permissions (#5694)
* fix(logs): enforce stream resource permissions

* fix(logs): retain request partitions for stream permissions
2026-10-14 23:42:14 -04:00
Priamo Germosen 425cd3167d feat(iam): resolve policy variables in Resource patterns and Condition values (#5639)
A ${...} in a Resource pattern or a Condition value was matched as the text it
is written as, so a statement scoped to arn:aws:iam::*:user/${aws:username}
matched no user at all. AWS's own IAMUserChangePassword policy is written that
way and floci vendors it verbatim, so under enforcement it authorized nothing,
and it is not alone: 244 of the 1586 vendored managed policy documents carry a
variable, and of the 1635 occurrences in them 1443 sit in a Condition value
and 192 in a Resource. The Condition share is where the loss bites hardest,
since a variable that cannot resolve quietly drops a Deny that AWS honours.

The keys a variable resolves against arrived with #5568, which put
aws:username, aws:userid and aws:PrincipalType into the request context. This
is the other half of that work: without substitution the keys answer nobody,
and without the keys substitution has nothing to find.

Variables now resolve wherever the evaluator matches a statement, which covers
every document it reads: identity policies, resource policies, session
policies, permissions boundaries, SCPs, and the Condition of a role trust
policy, whose own Version now reaches the condition check. A trust policy is
the narrow case, since sts:AssumeRole is authorized before there is a session
to describe: that context carries aws:PrincipalArn, the account and region
keys, sts:RoleSessionName and sts:ExternalId, so a variable naming
aws:username, aws:userid or aws:PrincipalType finds nothing there, which
iam.md now says.

Two of the rules are easy to miss. Substitution is gated on "Version":
"2012-10-17", because under the older 2008-10-17, which is also the default
when the element is absent, the user guide says variables "are instead treated
as literal strings in the policy"; the version therefore rides on each parsed
statement, since statements from many documents are evaluated as one list. And
a variable with no value is not an empty string: in Resource the pattern "will
not match any resource", in NotResource that same rule excludes nothing, and
in a Condition the positive operators do not match while the inverted ones do,
which is what makes the Deny AWS documents for an unset principal tag fire.

The rest, also from the user guide: a variable resolves only in the resource
portion of an ARN, after the fifth colon; only with the string and ARN
condition operators, never Numeric, Date, Bool, IpAddress or Null; only for a
single-valued key, a multivalued one having no one value to stand in, which a
default does not rescue, since a default answers a key with no value rather
than one with several; and case-insensitively by key name, a name that holds
no space, the guide allowing one inside a quoted default and nowhere else. A
spaced name, an empty ${}, a missing brace and an unquoted default are the
forms the guide's policy checks call errors, and each stays the text it is.
${*}, ${?} and ${$} stand for a literal character, so the glob gained an
escape marker, honoured only on a pattern that came back from substitution and
stripped from whatever arrived in the policy: a document can write the marker
as a JSON escape, and reading it as one would turn a wildcard of the
document's own into a literal character and narrow the statement it sits in. A
resolved value is not escaped, matching AWS, whose policy checks warn that
variables "can be evaluated as effective wildcards".

Verified at this commit: 7442 tests across the 439 IAM, core, enforcement and
resource-policy classes the evaluator is reached from, Checkstyle and
docs-check clean. AWS's own IAMUserChangePassword document is attached to a
user and called on the request path, both of its patterns included, the second
scoping a user under a path. Each rule was probed by reverting it alone, which
is how two weak tests were found: a valueless variable beside a wildcard and
the operator restriction both needed a case whose answer flips. The escape
marker is probed from both sides, by letting the resolver keep one that
arrived in a policy and by honouring markers on every pattern rather than only
a substituted one, and each side fails a different case of the same test.
2026-10-14 22:22:06 -05:00
Priamo Germosen 29ead624f8 fix(iam): authorize a Smithy RPC v2 call as the operation its route runs (#5620)
A Smithy RPC v2 call names its operation in the path, /service/<service>/operation/<operation>,
not in a Query Action or an X-Amz-Target header. Enforcement found no action for it, and an
unknown action is allowed, so under enforcement any known key could run any operation of SQS, SNS,
DynamoDB, Kinesis, Step Functions, CloudWatch or Marketplace over RPC v2, explicit denies included.

Enforcement also took the call's shape from the protocol claim, which the claim filter reads before
routing, while the CBOR endpoint dispatches whatever its route matched. The two disagree in
several ways:
- An unrecognised smithy-protocol value leaves the call unclaimed. With strict claiming off, the
  default, it is still served, so an unsigned call was not refused.
- An X-Amz-Target header on the call named the operation it was checked as, while the path named
  the one that ran.
- A path with a prefix before /service/ is claimed as RPC v2 while another route serves it.

The filter now reads the service and operation from the route the call reached, the values the
endpoint dispatches. It authorizes that operation as the action AWS checks for it, under the
serving service's namespace, and records the call's claim, so the unsigned refusal and the CBOR
error format apply whatever its smithy-protocol header says. A call on any other route is handled
as before.

The resources and condition keys a request names in its body were read only from JSON, and a CBOR
body fell back to a wildcard resource: a deny on one queue, table or stream did not apply, a grant
on one did not match, and a ForAllValues dynamodb:LeadingKeys condition granted every key. The
body is now read as CBOR when its content type says so, on the RPC v2 path and on the
x-amz-cbor-1.1 one, which had the same gap.
2026-10-14 17:33:39 -05:00
Priamo Germosen 46f4977b23 fix(ses): publish to an SNS topic only when its policy allows SES (#5650)
Under IAM enforcement, SES published event-destination events and identity notifications to
whatever SNS topic it was configured with, through an internal call nothing checked, so a caller
refused sns:Publish could still put messages on a topic by pointing a configuration set at it. On
AWS, SES publishes as ses.amazonaws.com and the topic's policy decides: it has to allow SES, under
an aws:SourceArn naming the configuration set or identity whose configuration names the topic.

- ServiceCallAuthorizer decides a call one AWS service makes to another's resource on its own
  behalf from the target's resource policy alone, read through the same providers the request
  filter uses and picked by the target ARN's service. A target with no policy refuses, and with
  enforcement off every call is allowed. ResourcePolicyProviders collects what the providers
  supply, for the filter and the authorizer alike.
- IamConditionContextResolver.serviceCallContext builds that call's request context from the IAM
  User Guide's global keys: aws:PrincipalIsAWSService, aws:PrincipalServiceName and
  aws:PrincipalServiceNamesList, aws:SourceArn and aws:SourceAccount, aws:ResourceAccount and
  aws:RequestedRegion, and none of the keys that describe an IAM principal. A publish to an SNS
  topic from SES also carries aws:SourceOwner, which the SNS Developer Guide lists SES among the
  services setting, and which the default topic policy checks.
- SnsResourcePolicyProvider supplies a topic's policy and the account in its ARN, also when the
  topic does not exist. A topic with no Policy attribute gets the default a new topic has, for the
  topic's own account. Topic policies so also take part in a JSON-protocol request that names a
  topic, as any resource policy does.
- SesEventPublisher asks before publishing to SNS: for an event destination with the configuration
  set's ARN, for an identity notification with the ARN of the identity that names the topic, the
  sender's own or its domain's, both with the sending account. A refused event is dropped. A
  notification SES cannot publish, because the topic is gone from its own account or its policy
  refuses SES, also takes the topic out of the identity's bounce and complaint settings and turns
  email feedback forwarding back on, as the SES Developer Guide describes; a delivery setting
  stays. The identity's notification settings are written under the identity lock, so that
  write and an API call changing them cannot lose each other.
- CreateReceiptRule and UpdateReceiptRule ask the same question of an action's TopicArn, with the
  rule's ARN as aws:SourceArn, and answer InvalidSnsTopic when the topic's policy does not let SES
  publish, which the SES API Reference lists as "could not publish to the topic, possibly due to
  permissions issues". The rules still route no mail.
- A resource policy statement that names the caller only through its account, by its id, root ARN
  or S3 canonical user ID, delegates to that account (IAM User Guide, "AWS account principals"):
  across accounts it is still the owner's half of the grant, but within the account it no longer
  grants on its own, and the caller's identity policies have to allow the request. Floci let such
  a statement grant on its own, for bucket and function policies already, so a topic policy naming
  its own account would have let every user of the account publish.
- A Deny's NotPrincipal follows the IAM User Guide ("AWS JSON policy elements: NotPrincipal"): it
  spares an IAM caller only when it names the caller's account as well as the caller, since without
  the account AWS "might deny access to the entire account", and never spares one with a permissions
  boundary attached, which it "will always deny". CallerArns says whether a boundary is attached to
  the user or to the role a session assumed. An Allow's NotPrincipal still grants everyone it does
  not name, as Access Analyzer warns it can.
2026-10-14 17:32:55 -05:00
David Phillips 4ea7e3da23 fix(dynamodb): authorize every requested item return mode (#5652)
* fix(dynamodb): authorize every requested item return mode

* test(dynamodb): share authorization fixtures
2026-10-14 14:03:35 -04:00
Priamo Germosen eba058266b fix(iam): authorize an operation as the action AWS checks for it (#5604)
Under enforcement a request naming its operation, in a Query Action or an
X-Amz-Target header, was authorized as <namespace>:<Operation>, the operation's
own name. AWS authorizes some operations as an action of another name: SQS
SendMessageBatch, DeleteMessageBatch and ChangeMessageVisibilityBatch as
sqs:SendMessage, sqs:DeleteMessage and sqs:ChangeMessageVisibility, and SNS
PublishBatch as sns:Publish. None of the batch names is an IAM action, so a policy
AWS honours for a batch call was denied, and a policy naming the batch operation
granted something AWS does not check.

AWS publishes the mapping in the Operations of each Service Reference file.
tools/aws/regen_iam_authorized_actions.py vendors the operations authorized by
exactly one action of their own namespace under another name, 235 over 33
namespaces, into src/main/resources/aws/iam-authorized-actions.json. Everything else
keeps its own name. The generator leaves out operations that list:
- several actions, whose extras apply only when tags or a role are passed;
- no action, which is missing data;
- an action of another namespace;
- another action while one of the operation's own name exists;
- a tagging action alone;
- the same action for several SDK clients, which AWS can authorize differently,
  as S3 and S3 Control's GetPublicAccessBlock;
or whose name is listed again with another answer. A record of the wrong shape
fails the run instead of being skipped.
make iam-authorized-actions-check gates the file's shape on pull requests that touch it, and
iam-authorized-actions-verify, run by the IAM Data Drift workflow, checks every
entry against AWS.

IamAuthorizedActions reads the file through the new core.common
VendoredResources, rather than adding one more copy of the read-or-fail block a
dozen catalogs carry, and the Query and X-Amz-Target paths ask it for the action.
DynamoDB TransactGetItems, which AWS authorizes as dynamodb:GetItem, keeps its own
name: the transaction check recognizes the call by it and checks every Get as
dynamodb:GetItem on its own table, with its own dynamodb:LeadingKeys. Renamed, the
call would skip that check and be authorized as one GetItem whose body has no
top-level Key, which a ForAllValues condition accepts, so a fine-grained policy
would grant every key.

The check for operations AWS serves without credentials reads the Query action
directly, rather than through resolve with a placeholder scope, now that resolve
returns the authorized action. A Query request naming no action is not one of them.

An SDK compatibility test covers SendMessageBatch and PublishBatch, granted by
the single-item action and refused under the batch name, with enforcement on.
2026-10-13 22:29:06 -05:00
Priamo Germosen 287d683da7 feat(iam): populate aws:username, aws:userid and aws:PrincipalType (#5568)
The request context carried seven aws: keys plus aws:PrincipalArn, and none of
the three that say who is calling. A Condition matching on any of them could
not match, which is also why an IAM policy variable has nothing to resolve:
AWS's own IAMUserChangePassword policy scopes itself to user/${aws:username},
and substituting that needs the key to exist before it needs a substituter.

The values come from the user guide's principal key values list, one shape per
principal: Account with the account id for the account-root principal and for a
session token it minted, User with the user's own id for an IAM user access key
and for a session token that user minted, FederatedUser with account:name for a
GetFederationToken session, and AssumedRole with role-id:session-name for a role
session, which for a role on an EC2 instance is role-id:instance-id.

aws:username is the exception and is only published for an IAM user. The guide
is explicit: "always included in the request context for IAM users" while
"anonymous requests and requests that are made using the AWS account root user
or IAM roles do not include this key". Leaving it absent is what makes a
statement matching on it fail to match, which is the documented behaviour for a
key with no value, so the absence is the enforcement rather than a gap in it.

One judgement. The principal key values list renders the role-session type both
as AssumedRole and, twice, as "Assumed role". The unspaced form is the one that
fits the vocabulary of every other value in that list, each a single word or
CamelCase, and it is the form AWS publishes machine-side, as CloudTrail's
userIdentity.type does.

aws:userid was already derived in full by resolveCallerUserId, for every
principal type including the EC2 and ECS session-name fallbacks, so that
derivation is now a shared sessionUserId rather than a second copy inside
resolveCallerArns: reporting one key two ways is how the two readers would
drift. CallerArns carries the three values so they come from the single lookup
its javadoc already required, two lookups being able to straddle a session's
expiry, and it writes them itself, so every context a request is evaluated
against describes the same principal and there is one place that decides which
keys a principal publishes. The enforcement filter builds one context per
resource the request names and, since #5576, one per transaction item, which is
what a policy scoped to dynamodb:LeadingKeys = ${aws:userid} will need. S3
builds one of its own when s3.enforce-auth has it evaluate a bucket policy
there and then, and that one carried aws:PrincipalArn alone, so an inverted
Condition on any of the three keys held against a caller that has them and
fired a Deny the policy meant to leave alone.

Three unit tests and four integration tests, one on the transaction-item path
and one in S3's own bucket-policy class, with the existing caller-ARN
assertions widened to pin the keys for the root, federated and user-minted
session principals they already covered. Each key probed by dropping it alone:
without aws:PrincipalType or aws:userid both enforcement tests fail, without
aws:username one does, and giving a role session a username it should not have
fails the test that asserts the absence. The two contexts outside the filter
are probed the same way, each reverted to aws:PrincipalArn alone, and each
fails its own test. 4489 tests pass at this commit, across all 277 IAM and
core/common classes, the shared enforcement fixtures, and the S3 policy,
enforcement, presigned and account-context ones, the shared filter and
CallerArns reaching all of them. Checkstyle and docs-check clean.
2026-10-13 22:28:47 -05:00
David Phillips 9ab820d7f7 fix(iam): preserve later policy writes during rollback (#5596)
* fix(iam): preserve later policy writes during rollback

* fix(iam): explain rollback ownership conflicts
2026-10-13 20:35:35 -04:00
David Phillips 1d8f65d231 fix(iam): enforce user and group inline policy quotas (#5590) 2026-10-13 19:31:32 -04:00
David Phillips 69bbd2242b fix(iam): check DynamoDB transaction item permissions (#5576)
* fix(iam): check DynamoDB transaction item permissions

* test(iam): cover transaction attribute and item permissions

* test(iam): cover transaction policy boundaries

* fix(iam): bind transaction permissions to the accessed table

* fix(dynamodb): preserve omitted transaction return values

* docs(iam): clarify transaction return-value conditions
2026-10-13 15:20:54 -04:00
David Phillips 367ae0b2db fix(iam): honor managed policy attachment conditions (#5578)
* fix(iam): honor managed policy attachment conditions

* test(iam): keep managed policy group tests isolated
2026-10-13 12:05:34 -04:00
Hector Ventura 1b7c79fd9e fix(signin): accept the cross-device redirect on each partition's sign-in host (#5557)
The cross-device redirect_uri was matched against the commercial
<region>.signin.aws.amazon.com only, so a login that resolved another
partition's Sign-In host was refused with invalid_request.

regen_partitions.py now reads botocore's signin endpoint ruleset and
vendors one signinHost per partition into aws/partitions.json. The
redirect is accepted on the Sign-In host of a region in the deployment's
partition, and another partition's host is refused. The device
authorization client ids keep their literals: the Sign-In model spells
them the same way in every partition.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
2026-10-13 07:47:19 -04:00
Priamo Germosen 5ea632cc13 feat(iam): change the calling user's console password (#5546)
ChangePassword was the last IAM operation held back for a reason that turned
out not to hold. It was tracked as blocked on disambiguating a shared Query
action name by Version, because Cognito publishes the name too. In fact IAM
sits second in inferServiceFromAction's chain and Cognito ninth, and Cognito's
form path answers UnsupportedOperation to every request, so adding the name to
IAM_ACTIONS routes it to IAM and costs Cognito nothing. A request carrying a
credential scope never reaches that chain at all.

The operation takes no UserName. The API reference says it changes the password
of the IAM user who is calling, and the CLI reference adds that it "can be
called by IAM users only. If this command is called using AWS account (root)
credentials, the command returns an InvalidUserType error", so a signing key
with no stored user behind it, which is Floci's stand-in for that caller,
answers InvalidUserType rather than reporting the key as missing. The resource
the request is evaluated against needed nothing new: ResourceArnBuilder already
resolves the signing user for an action whose UserName is absent, and the
vendored action map already authorizes ChangePassword against a user.

OldPassword is checked against the stored login profile before the new password
is held to the account password policy, so a caller who cannot prove the
current password learns nothing about what that policy requires. A mismatch is
the one refusal the reference leaves unnamed: every error it publishes for this
operation describes something else, so this answers InvalidParameterValue, the
common error type AWS publishes for a parameter value a service cannot accept.
A successful change clears PasswordResetRequired, which is what lets a user
whose password an administrator reset restore their own console access
programmatically, and it moves the password_last_changed the credential report
reads.

The passwordType shape check is now shared and names the member that failed,
because this operation has two password members and a caller told that
'password' failed would have to guess which. An absent member and an empty one
stay different answers.

Two things the login profile needed before a self-service change could be
trusted. The comparison and the write are one step under a new
loginProfileLock, which every login-profile writer takes: read apart from the
write, two requests presenting the same valid old password both pass the
comparison and both are told they set the password, while only the later write
survives, and a guard one writer skipped would leave a racing UpdateLoginProfile
free to overwrite a password a ChangePassword had just promised. And
PasswordReusePrevention is now enforced, on UpdateLoginProfile as well, the two
sharing one bounded history per profile: the reference defines the value as "the
number of previous passwords that IAM users are prevented from reusing" and
makes no window mean no prevention. The password the profile holds is refused
alongside the superseded ones, which the reference leaves open; read the other
way the smallest window the policy accepts would allow setting a password to the
value it already has, and would not refuse the change away and straight back
that the setting is for.

Twelve unit tests, one concurrency test and six integration tests, with each
guard probed by reverting it alone: dropping the old-password comparison, the
reset-flag clear, the policy check or the check order is caught by the test
written for it, and dropping the routing entry leaves the unsigned request
answered by Cognito, which is what the routing parity test says too. Dropping
the lock leaves five of twenty-four racing requests all told they succeeded with
one password stored, neutering the reuse check leaves both refusals silent, and
widening the window by one lets it reach a password that has left it. 1668
tests across all 98 IAM and query-routing classes pass at this commit.

docs/services/iam.md documents the operation, the judgements, and the one thing
Floci still does not model. AllowUsersToChangePassword is accepted and reported
but grants nothing:
the user guide says the option gives all users in the account access to
iam:ChangePassword for only their user and to iam:GetAccountPasswordPolicy,
applied at the account level rather than by attaching a policy, while Floci
authorizes both from identity policies alone, so under enforcement a caller
needs a policy naming their own user however the flag is set. The matrix row
moves 166 to 167.
2026-10-12 22:34:39 -05:00
Hector Ventura bcda5958e0 fix(signin): complete aws login --remote against an endpoint override (#5552)
The AWS CLI builds the cross-device redirect from the Sign-In endpoint
it resolved, so with --endpoint-url it sends Floci's own address plus
/v1/sessions/confirmation. Floci accepted only an https AWS sign-in host
there and served no confirmation page, so the authorize request was
refused and the remote login could not finish.

A cross-device redirect is now also accepted on the scheme, host and
port the authorize request arrived on, and GET /v1/sessions/confirmation
shows the verification code in the form the CLI decodes. Any other
origin is still refused.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
2026-10-12 23:09:28 -04:00
lex00 72a4cc5515 fix(iam): page ListRoles and ListPolicies through MaxItems and Marker (#5515)
Both actions returned every match in one response with IsTruncated false.
They now use the existing paginate helper, so an omitted MaxItems returns
100 items, a MaxItems outside 1 to 1000 is a ValidationError, and Marker
appears only on a truncated page. PathPrefix and Scope filter first.

Roles and customer managed policies are listed in name order so a marker
keeps pointing at the same place between calls.
2026-10-12 15:40:59 -04:00
David Phillips ea8da22226 fix(iam): match absent context keys with ForAllValues (#5482)
* fix(iam): match absent context keys with ForAllValues

* fix(iam): preserve condition guards for missing keys

* fix(iam): reject unsupported condition shortcuts

* docs(iam): clarify supported IfExists conditions

* fix(iam): enforce requested keys in set conditions

* docs(iam): clarify unresolved attribute conditions

* fix(iam): enforce requested S3 object tag keys

* fix(iam): scope object tag keys to the authorized action
2026-10-12 06:54:16 -04:00
Priamo Germosen 4e769484df feat(iam): generate and read the Organizations access report (#5467)
GenerateOrganizationsAccessReport and GetOrganizationsAccessReport answered
UnsupportedOperation, which is not a reply any SDK models. They are the Access
Advisor job shape over a different question, and everything the question needs
was already here: an Organizations tree with roots, OUs, accounts and SCPs, a
policy evaluator, and a job model whose report is fixed at generation time.

The report is the services the service control policies along an entity path
leave reachable. The path names the organization, its root, and the OUs or
account below it, and the SCPs attached to each of those are read from
Organizations and evaluated. Only SCP logic applies, which the reference is
explicit about: identity policies, resource policies, ACLs, permissions
boundaries and trust policies play no part in this data.

Attached SCPs are a union within one level and the levels are intersected, so a
service survives only where every level allows it. That cannot be answered a
namespace at a time, because a service is reachable only while some action in it
survives the whole chain: two levels allowing single disjoint actions,
s3:GetObject under s3:PutObject, leave no S3 action at all, and a Deny on the one
action a level allows leaves none either. What a namespace-wide reading got right
stays right. An SCP denying s3:DeleteBucket alone keeps S3 on the list, because
every other S3 action is still reachable, and a Deny carrying a Condition or
naming particular resources closes nothing: the region guardrail on * that most
organizations carry, and a deny scoped to one bucket, both leave the service
reachable by every request they do not cover, and reading them as total denials
would report an organization that reaches nothing.

This is still not the existing scpAllows asked once per namespace. That question
needs a concrete action, and a request action of s3:* would not match a statement
naming s3:GetObject, a pattern globbing against a request value and never the
other way round. The survivors are found by probing instead, with the actions the
policies themselves name and one stand-in action per wildcard, which decides the
patterns policies are written with exactly: a deny on s3:GetObject leaves the
service reachable where a deny on s3:Get* does not. A wildcard that is not a
trailing one is the limit of it, since the stand-in for s3:*Object misses the
s3:GetObject that s3:Get* would allow; such a pattern leaves the service on the
list rather than off it, which is the side the namespace reading was already on.

The management account is not limited by SCPs, so its report lists every service
and an OrganizationsPolicyId passed with it is ignored, both as documented.
Passing that ID otherwise narrows the report to the one SCP named, and it has to
name one: Organizations keeps tag, backup, chatbot and opt-out policies in the
same ID space, none of them carries statements, and evaluating one as a ceiling
would read as a level that constrains nothing and report every service there is.

The entity path has to be a path the organization actually has. The segments
below the root name a chain of parent and child, so the path is held to the one
Organizations reports for its last node rather than each segment being resolved
on its own. Resolving them one at a time accepts a path assembled from two
branches, or one that skips an OU, and reports the policies of a chain the
organization does not have; it also lets a path whose last segment is the
management account take the unlimited answer with an OU above it that does not
exist.

Floci records no service access, so every service in a report is one principals
are allowed but never reached. The reference's own example gives such a service
as a namespace and a zero count with no region, entity path or last-authenticated
time, so that is the shape here and NumberOfServicesNotAccessed equals
NumberOfServicesAccessible. ServiceName carries a display name Floci has no
mapping for, so the namespace stands in for it as it does on the last-accessed
reader. SortKey is validated against its four values: the namespace keys sort
the list and the time keys leave it in namespace order, since ordering on a
timestamp no entry carries would be ordering on nothing.

A caller who is not the management account gets AccessDenied 403. Neither
operation models a code for that, but a per-action error list is additive: the
reference's common error types "that this AWS service may return" apply to every
action and include the 403 permission denial, and the user guide names the code
for a denied IAM action outright in its AddRoleToInstanceProfile entry. That page
spells it AccessDeniedException where the user guide and the rest of this
service's surface spell it AccessDenied; the latter is used, so a caller sees one
spelling across IAM and STS.

Three things are inferences, and they are the same inference three times. The
docs say so. The generator models no error for an entity path that is well-formed
but resolves to nothing, nor for the prerequisite the reference states, that SCPs
be enabled for the organization root, nor for an OrganizationsPolicyId naming a
policy of some other type, so each produces a FAILED job carrying ErrorDetails:
InvalidEntityPath or the Organizations code for the entity in the first case,
PolicyTypeNotEnabled in the second, Organizations' InvalidInputException in the
third. That is read off the shape of the API rather than off a sentence: AWS
publishes both fields on this reader for failures the generator does not report
synchronously. The alternatives are worse. Letting Organizations' own error
escape unchanged puts another service's code on an IAM operation, a COMPLETED job
with an empty list cannot be told apart from an organization that reaches no
services, and ValidationError is for a shape violation, which a well-formed path,
a disabled policy type and an existing policy of the wrong type are not.

ReportGenerationLimitExceeded, the generator's only modeled error, reports
concurrent generations and stays unreachable: a job completes the moment it is
created, so two never overlap.

The generator also carries the access-report resource type, so it leaves
UNRESOLVED_TYPES and resolves from the request. The reference spells the type as
access-report/${EntityPath}, so the entity path goes into the ARN whole: its
slashes are the organization's tree, not an IAM path, which is why it does not
go through the minting the creates use.

Both actions join AwsQueryController.IAM_ACTIONS as well as the handler, without
which inferService would never route them. That list and the handler now hold
166 each, still exactly in step.

Validation runs before the lookup, as AWS rejects a request shape whether or not
the job exists: a SortKey outside the enum answers ValidationError even for a
job ID nothing holds, where validating it afterwards would answer NoSuchEntity.
A member the request carries is held to its shape whatever it carries, an empty
value included, since SortKey= and OrganizationsPolicyId= are a malformed enum
and a malformed id rather than a way of leaving an optional member out. The
entity path reports the constraint that failed rather than the regular
expression for every case, so a path over the maximum length reads as a length
violation, which is what every other validated IAM member does.

Only the one Organizations answer that means something about the caller becomes
AccessDenied. A read that fails for any other reason keeps its own error, rather
than reaching the caller as a permission problem they do not have.

Two things are shared rather than copied. The job registry both report
generators keep, an account-scoped store keyed by job ID that answers
NoSuchEntity for an ID it does not hold, moves into IamJobStore and
ServiceLastAccessedService reads it from there; the two had the same three
methods and the same message. The report's timestamps come from the injected
Clock, which IamService already takes, rather than from Instant.now(), so they
agree with every other time IAM decides. IamQueryHandlerTest builds the handler
itself rather than through injection, so it passes the new service along with
the dependencies it already does not use.

Fourteen unit tests cover the chain semantics, including the allow-list idiom of
allowing everything and denying all but one namespace, levels allowing disjoint
single actions, a deny on the only action allowed and on a pattern wider than it,
a conditional deny, a deny scoped to one bucket, a level with an unreadable
document, and a level with none. Twenty-one integration tests drive the pair over
an organization built through the Organizations API, on a management account of
their own so they never contend with the existing Organizations suites for one.
Two of them are the ones that hold the walk honest: the OU path, where the root
leaves S3 and DynamoDB and the OU leaves DynamoDB and IAM, so only a report
reading both levels answers DynamoDB alone, and the management account path,
which reports every service and ignores the policy ID passed with it even with a
ceiling attached to the root above it. With the tree read deliberately broken the
first SCP test returns all 456 namespaces instead of the one, and it is the only
test that notices. Two more tests mock the Organizations read, which is the one
failure a real organization cannot be made to produce.
2026-10-11 21:47:58 -05:00
Priamo Germosen 6d7d85f0f8 fix(lambda): enforce function policies on cross-account calls (#5476)
Under IAM enforcement, a caller whose own policy allowed lambda:InvokeFunction could invoke
another account's function by ARN even when that function's policy granted nothing, and
RotateSecret could be pointed at another account's function the same way. Three things combined:
there was no resource-policy provider for Lambda, so the call was judged as same-account; the
function name was cut at its first colon, so an ARN was evaluated as function:arn in the caller's
account, where no Allow or Deny written for the function could match; and the invoke followed the
account in the ARN.

- LambdaResourcePolicyProvider supplies a function's policy statements and the account its ARN
  names, also when the function has no policy, so a call to another account's function needs that
  function's policy to allow the caller as well as the caller's own policy. It is keyed on the
  ARN, so RotateSecret's check on its rotation function, made under the secretsmanager scope,
  sees it too.
- ResourceArnBuilder evaluates each call against the function it acts on. An invoke runs in the
  account and Region a full or partial ARN names, as the version or alias it names in the function
  name or in Qualifier, since Lambda authorizes a qualified call against the qualified ARN.
  GetFunction, GetFunctionConfiguration and ListDurableExecutionsByFunction read a qualified full
  ARN in the account it names, so they are evaluated there too, and a read of another account's
  function needs its policy as on AWS. Every other route acts on the caller's own function of that
  name, so it is evaluated against that function, unqualified because not all of their handlers
  act on the qualifier.
- An invoke by partial ARN runs in the account it names, as one by full ARN already did.
- RotateSecret looks its function up where the rotation runs it: in the ARN's account, and as the
  version or alias the ARN names.
2026-10-11 21:47:27 -05:00
Priamo Germosen d884d55c26 fix(iam): evaluate every IAM action against the resource it acts on (#5404)
Under enforcement, almost every IAM action reached the policy evaluator with
* as its resource, because ResourceArnBuilder named only the server-certificate
operations and everything else fell through to the wildcard. A statement naming
an IAM resource was therefore ignored, and wrongly in both directions, because
the evaluator globs the statement's pattern against the request's resource and
a resource of * is matched as that literal string. So a Deny on
arn:aws:iam::000000000000:user/bob did not stop DeleteUser for bob, while an
Allow scoped to that same user did not permit DeleteUser on anyone at all: a
least-privilege policy naming the resource it meant to grant refused the call.
Measured both ways by reverting this resolver to the wildcard, which turns the
permitted call in aResourceScopedAllowGrantsThatUserOnly into a 403 and the
refused call in aDenyNamingOneUserLeavesTheOthersAlone into a 200. Nothing
failed and nothing warned, which is the dangerous shape for an emulator people
test policies against.

The resource type each action is evaluated against now comes from AWS's own
authorization metadata for IAM, action by action. That is not the parameter an
action happens to take: AddUserToGroup and RemoveUserFromGroup are evaluated
against the group, AddRoleToInstanceProfile and RemoveRoleFromInstanceProfile
against the instance profile, and EnableMFADevice, DeactivateMFADevice and
ResyncMFADevice against the user rather than the device they name. Mapping those
from the request's parameters would have scoped them to the wrong resource and
let a deny on the right one pass.

An action acting on a resource that exists is checked against that resource's
stored ARN. The reference gives the formats as user/${UserNameWithPath},
group/${GroupNameWithPath} and so on, so the path is part of the ARN a policy
names, and only the store knows it; the stored ARN also carries the partition
the resource was created in, which re-minting from the caller's signing region
would get wrong. A create has nothing stored, so its ARN is minted from the
request's own Path: reading a stored path there would authorize a create into
/team/ against the root path.

A policy, MFA device, SAML provider, OIDC provider or principal is named by an
ARN the request already carries, so that is passed through rather than rebuilt
from parts. Only an ARN is: a hardware MFA device's SerialNumber is a bare
serial, and naming the request after it would produce a resource no policy could
be written against.

That table is read before the one keyed by resource type, so an action in both
would silently take its ARN parameter and the mistake would look like a resource
that never matches rather than like a bug. An attach is the case that makes it
worth pinning down: it carries both a user and a policy ARN, and the reference
gives it the user alone, so it stays out of that table and
iamNamesTheUserRatherThanThePolicyOnAnAttach is what holds it there.

UpdateUser and UpdateGroup join UpdateServerCertificate in naming both the old
resource and the one the request would produce. Both are documented, which the
certificate case was not: UpdateUser's reference says the requester "must have
appropriate permissions on both the source object and the target object", and
UpdateGroup's that a principal allowed to update the old group but not the new
one has the update fail.

Two actions name their role indirectly and are derived rather than looked up.
CreateServiceLinkedRole does not name the role it creates, so the check reads
the same ServiceLinkedRoles table the create reads and cannot name a different
role. GetServiceLinkedRoleDeletionStatus carries only a DeletionTaskId, and its
reference publishes that identifier's format as
task/aws-service-role/<service-principal-name>/<role-name>/<task-uuid>, which is
the role's own path and name with a prefix in front and a uuid behind; the role
is already deleted by the time the status is asked for, so there is no stored ARN
left to read either way. The /aws-service-role/ path moved to that class, so there is one copy of
it rather than a second in the builder. GetAccessKeyLastUsed names only a key,
and is evaluated against a user: the User Guide's own iam:*AccessKey* example
scopes exactly that set to user/${aws:username}, so the owner is resolved from
the key.

That covers all 130 of the IAM actions this emulator dispatches that AWS gives a
resource type, out of 164 in total. The remaining 34 have no resource type in the
reference, such as ListUsers, GetAccountSummary and SimulateCustomPolicy, so *
is the right answer for them. An action that names its target only by defaulting
to the calling user, such as GetUser or ChangePassword with no UserName, is
resolved from the credential instead, which the last paragraph here sets out.

Nine enforcement tests drive the whole path rather than the ARN the builder
returns, since the defect was invisible: a scoped statement was ignored, not
rejected. They cover a deny that must bind to one user and leave another alone,
the stored path being part of the ARN, the group and the instance profile being
the resource where two entities are named, a managed policy named by ARN, a
create authorized against the path it asks for, a rename refused on its
destination alone, and a scoped Allow granting one user only. Reverting the
mapping to the wildcard fails all nine.

The map is vendored rather than written out here, because a hand-written copy of
AWS's metadata is exactly what tools/aws exists to prevent.
regen_iam_action_resources.py generates src/main/resources/aws/iam-action-resources.json
from the same reference, 190 actions with the resource types each is authorized
against plus the ARN format of all 15 resource types, and it gates the file the
way regen_service_namespaces.py gates the namespace list: --check offline for
shape, --verify online against AWS. A type the file claims and AWS does not fails,
since that would authorize against a resource AWS does not use, which is the one
outcome worse than the wildcard. A type or an action AWS has added is reported
without failing, because being behind leaves that action on * and failing there
would break this build for someone else's launch. make
iam-action-resources-check runs per pull request beside the namespace check, and
make iam-action-resources-verify weekly in the drift workflow. Its unit tests need
no step of their own: make aws-data-test in that same job already runs every
generator's.

So no list of actions is written down here. What stays in code is the half that is
Floci's rather than AWS's: the parameter each resource type arrives in, the nine
creates and the name each spells, the actions whose request carries an ARN, the
three resolved from something other than a name, and the three resource types
that belong only to actions the handler does not dispatch. IamActionResourcesTest
checks the code against the data: every resource type AWS uses must be resolved
or declared unresolved, every create must have exactly one type to mint, and
every minted prefix must match the ARN format AWS publishes for that type. A
regeneration that brings in a new resource type then fails a test naming the
type, rather than quietly putting that action back on *, which is the permissive
answer and a silent one. The create check reads the resolver's own map rather
than restating it, so a create added there is checked too, and the minting falls
back to the wildcard instead of indexing an empty list: a create AWS authorizes
against no single type has no ARN to build, and a request should not fail on
what is a defect in this class.

The reason each declared-unresolved type gives is a claim about the handler, not
about the builder, so nothing inside the builder can check it, and getting it
wrong is silent and fail-open: dispatching such an action without teaching the
resolver its type leaves it evaluated against *, which is the gap this closes.
UnresolvedResourceTypesIntegrationTest therefore sends every action carrying one
of those types and holds it to answering UnsupportedOperation, naming the action
and what to do if it no longer does. No other vendored-data loader validates at class init
either, so the checks read the data the way AwsPartitions and
AwsServiceNamespaces do: parse, and let the gate and the tests have the opinion.

The nineteen user actions whose UserName the model marks optional act on the
user who signed the request, so that user is the resource they resolve to. The
access key id in the credential names the identity, which is the same lookup
GetAccessKeyLastUsed already makes on a key passed as a parameter, and the
stored ARN carries the path and partition as everywhere else here. The wildcard
still stands when the signer is not an IAM user, an account's root stand-in and
a session credential having no user record to name.

What stays at the wildcard is what AWS gives no resource type, 34 of the 164.

Closes #4979

The online gate verifies the ARN formats as well as the action mapping. A format
drifts invisibly otherwise: the offline check only asks whether it still looks
like an IAM ARN, and a changed one does, while the minting reads that string to
place the resource type. So a right-looking file could build a wrong ARN.

The resource types this class covers are worked out from its own tables rather
than restated in the test, so a type cannot be waved through by adding it to a
list in the test file. That is the check the earlier startup guard made.

The three actions whose resource the request carries in some other form hold
their own resolver, rather than being listed in one place and routed by name in
another. A list cannot then say an action is handled while the dispatch has
nothing for it, since adding a key means supplying the resolver that goes with
it.

The enforcement suite removes what it creates. The emulator is shared, so a user,
group, role, profile, policy or provider left behind turns up in the next class
to list one, and the shared fixture helper grew the prerequisites IAM enforces
before a delete: group memberships and attached policies for a user, inline and
managed policies for a role and a group. A rename leaves its destination name
behind rather than the name that was created, and the create test goes through
the enforced path, so both register their own removal.

The drift workflow stays one check, and make iam-data-verify is what keeps that
honest. Two sequential steps stop at the first failure: while the namespace list
was stale, the action resource check this change adds never ran at all, so the
gate arrived unexercised in CI. The target runs both regardless of the first
result and then fails, naming the file that drifted rather than leaving a reader
to guess from one message. The workflow file is renamed to match what it covers,
and the IAM targets it uses join .PHONY, which they should have done when they
were added.

That namespace check was red because AWS retired evidently and iotevents, and
the vendored list still claimed both. Regenerating it drops those two, picks up
end-user-messaging and startups, and leaves the count at 456. A retired
namespace only narrows wildcard expansion; a policy naming one literally is
still reported, since a namespace written out is kept whether or not the catalog
knows it.
2026-10-11 09:12:29 -05:00
Matheus Oliveira b2b083ee91 fix(iam): validate RoleName in every role action (#5391)
Every action whose RoleName is roleNameType now answers a bad name with ValidationError instead of NoSuchEntity, as CreateRole does.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
2026-10-10 17:58:43 -04:00