mirror of
https://github.com/floci-io/floci.git
synced 2026-11-26 07:11:11 -05:00
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.