Repository navigation
Description
IAMPlugin dispatches 52 operations; neither SimulatePrincipalPolicy nor SimulateCustomPolicy is among them, so both return InvalidAction.
These are the only AWS APIs that answer "may this principal do X to Y" without doing X to Y. Any tool that checks its own permissions before it starts mutating is built on SimulatePrincipalPolicy, and against substrate that check is currently untestable — which means the code path that decides whether to proceed at all is the one path with no coverage.
The alternative for a caller is to attempt the operation and interpret the failure, which for a mutating operation means the check and the action are the same event. That is exactly what the API exists to avoid.
What is needed
SimulatePrincipalPolicy, given a PolicySourceArn (user or role) plus ActionNames and ResourceArns, returns per-action EvalDecision of allowed, explicitDeny, or implicitDeny.
The three-way distinction is the whole value. explicitDeny and implicitDeny are different remediations — a Deny statement somewhere in the effective policy set versus simply no grant — and a tool that collapses them tells the operator to request a permission that a boundary or SCP will refuse anyway. A simulator that only returned allowed/denied would be worse than none, because it would look like coverage.
Worth having, in rough priority order:
- The three decisions, evaluated against the principal's attached managed and inline policies.
authz.goalready has a policy evaluator, so this may largely be exposing what exists over the wire rather than new evaluation logic. MatchedStatements— which statement produced the decision. This is what makes a remediation message specific enough to act on.- Permissions boundaries and SCPs in the evaluation, if they are modelled. An
allowedthat ignores a boundary is a false negative on the one case where the operator most needs the truth. ContextEntriesfor condition keys, particularlyaws:RequestTag/*andaws:ResourceTag/*— the keysauthz.goalready builds. A simulate call that ignores context silently reportsallowedfor a grant that is conditional in practice.SimulateCustomPolicyfor evaluating a policy document that is not yet attached. Lower priority than the principal form but the same machinery.
The API is paginated (IsTruncated / Marker) and caps at 25 actions per call, worth reproducing if List* pagination is being taken seriously elsewhere.
Context
automat's preflight is entirely SimulatePrincipalPolicy: before it touches an organization it establishes which of three permission states the caller is in and, when the answer is "not enough", names the action, the resource, and the grant that would fix it. That reporting is a headline feature rather than logging, so its tests are among the most load-bearing in the project — and they cannot run against substrate today.
Happy to contribute this or to review a design. If SCP and boundary evaluation are out of scope for a first pass, the three decisions plus MatchedStatements over identity policies alone would already be usable; documenting what is not in the evaluation matters as much as what is, since an unexplained allowed is a wrong answer a caller will trust.
Activity
scttfrdmn commentedon Aug 14, 2026
Scheduled for v0.100.0 ("a tool can ask before it acts"). Verified the issue's shape
against the botocore IAM model (
2010-05-08/service-2.json) and theSimulatePrincipalPolicy
/ SimulateCustomPolicy
references before planning. Four corrections, then the accepted scope.
1. There is no 25-action cap. The issue proposes refusing more than 25 actions per
call. No such limit exists:
MaxItems"defaults to 100" with "Valid Range: Minimum valueof 1. Maximum value of 1000", and no action-count limit appears anywhere in either
reference or in the model's shapes. Modelling one would refuse requests AWS accepts —
exactly the failure mode substrate's error fidelity exists to avoid. Pagination will
follow
MaxItemsdefaulting to 100, valid 1–1000.2. Group support is a prerequisite, not an extra. The reference is explicit: "If you
specify a user, then the simulation also includes all of the policies that are attached to
groups that the user belongs to." Substrate cannot do this today for two independent
reasons:
loadPoliciesForPrincipal(emulator/authz.go:187-258) reads<kind>_policies:and<kind>_inline*:only. The word "group" does not appear inauthz.go.iam_plugin.goroutes 53operations including
CreateGroup/GetGroup/DeleteGroup/ListGroups, and none ofAddUserToGroup,RemoveUserFromGroup,AttachGroupPolicy,ListAttachedGroupPolicies,PutGroupPolicy,GetGroupPolicy,ListGroupPolicies,ListGroupsForUser.GetGroupreturns
iamUserListXML(nil), so a group is observably always empty.A user simulation without group policies is wrong rather than partial — it would answer
implicitDenyfor an action the user is in fact allowed. So v0.100.0 ships the groupoperations first, teaches
loadPoliciesForPrincipalabout them, and only then builds thesimulator on top. That widens
CheckAccesstoo, which is the correct direction: AWSapplies group policies to every request a user makes.
3.
MatchedStatementsneeds the AWSStatementshape. Substrate'sEvaluationResult.MatchedStatementsis a[]stringof Sids (emulator/iam_eval.go:26).AWS's
Statementis{SourcePolicyId, SourcePolicyType, StartPosition{Line,Column}, EndPosition{Line,Column}}. The plan adds aSourcedPolicyDocument+EvaluateSourcedso
Evaluatelearns which document a statement came from without changing its signaturefor existing callers.
StartPosition/EndPositionare deliberately omitted: they are offsets into thepolicy document as submitted, and substrate stores a parsed
PolicyDocument, so theoriginal text is gone and any offset would be fabricated. The reference's own sample shows
an empty
<MatchedStatements/>forimplicitDeny, so absence is a shape callers alreadyhandle. This will be stated in
docs/services.md.One provenance note found while checking this: the model's
PolicySourceTypeenum isuser/group/role/aws-managed/user-managed/resource/none, but both sampleresponses on the reference page emit
<SourcePolicyType>IAM Policy</SourcePolicyType>andResource Policy. The doc values are what an SDK actually receives, so those are whatsubstrate will emit. Likewise
SourcePolicyIdis the policy name in the samples(
AmazonS3ReadOnlyAccess,PolicyInputList.1), not an ARN.4. Substrate already advertises permission for these operations.
iam_managed.gogrants
iam:SimulateCustomPolicyandiam:SimulatePrincipalPolicyin its bundledpolicies — so an authorized caller is told it may perform an operation that answers
InvalidAction.Prerequisite: #639
Neither operation is reachable over the wire until #639 lands.
server.go:583-589rebuilds
req.Bodyasjson.Marshal(req.Params)andreq.Paramsis amap[string]string, so an SDK sendingActionNames.member.1=s3:GetObjectproduces a JSONbody with a key literally named
"ActionNames.member.1", and every[]stringfieldunmarshals to nil. Every parameter these two operations take is a
.member.Nlist. Filedseparately because it is a shipped defect in its own right — it silently breaks
TagUser/UntagUser/TagRole/UntagRoletoday.Accepted scope
In: the three-way decision (
allowed/explicitDeny/implicitDeny— this maps 1:1 ontosubstrate's existing
DecisionAllow/DecisionDeny/DecisionImplicitDeny, and the issueis right that collapsing it would be worse than nothing), identity policies (managed +
inline + group), the permissions boundary,
MissingContextValuesfromContextEntries,ResourceArnsdefaulting to*,CallerArndefaulting toPolicySourceArn, andNoSuchEntity404 /InvalidInput400 per the model —SimulateCustomPolicycorrectly has noNoSuchEntity, since it resolves no entity.Out, and documented in
docs/services.mdwith the reason for each:SERVICE_CONTROL_POLICYappears only inorganizations_*.go;authz.gonever consults it, so
CheckAccessdoes not enforce an SCP either. Simulating themwould report a bound the emulator itself ignores.
OrganizationsDecisionDetailstaysabsent rather than wrong.
ResourceHandlingOption,PolicyExclusionList,EvalDecisionDetailsandResourceSpecificResults— cross-account constructs; the reference notesEvalDecisionDetails"is returned, but the response is empty" for a same-accountsimulation with a resource ARN.
feat(iam): groups have an observable effect (#579) (#641)
fix(iam): decode query-protocol scalar parameters (#642) (#643)
feat(iam): a tool can ask before it acts (#579) (#644)