Repository navigation
Description
Every other account-scoped plugin in substrate partitions its state keys by account — "table:" + reqCtx.AccountID + "/" + name (emulator/dynamodb_plugin.go), "instance:" + accountID + "/" (emulator/ec2_plugin.go), and so on. IAM does not: a user is stored under "user:" + name, a role under "role:" + name, a policy under its ARN, with no account anywhere in the key (emulator/iam_plugin.go).
The consequence is that resolveIAMEntity (emulator/authz.go) resolves a principal by name regardless of which account the request is attributed to. Two accounts on one substrate process cannot both have a role called deploy: the second CreateRole answers EntityAlreadyExists, and if it did not, one account's policies would evaluate the other's.
This has always been true, and until #734 it was invisible: substrate resolved one of two accounts from the shape of the access key, so the account was not something a test could hold fixed and vary. #734 made the account a single configurable value that a credentials entry or an STS session can override, which is what makes this reachable — and #734's own tests deliberately left it alone, because sweeping IAM's key layout is a much larger change than the one that release was for.
Why it "works by accident" today
IAM's own operations are consistent with themselves: CreateUser writes user:alice and GetUser reads user:alice, so a single-account consumer sees nothing wrong. The authorization chain is consistent too, for the same reason. The bug only surfaces when two accounts are in play, which requires a CredentialRegistry — and the only way to get one today is in-process (see #736).
Acceptance criteria
- IAM state keys carry the account, following the convention the other plugins use
-
resolveIAMEntityscopes its lookup to the request's account - Account-scoped uniqueness: two accounts can each hold a role of the same name, and each
GetRoleanswers with its own - A cross-account policy evaluation is asserted to consult the caller's entity, not a same-named one in another account
- The migration cost is stated: account-prefixing a state key makes persisted SQLite state written under the old layout unreachable, the same compatibility note iam: CreateUser mints ARNs under account 000000000000 while authorization uses 123456789012 #734 carried
Activity
fix(parser,config): one server serves one account (#734) (#740)
fix(iam): an IAM entity belongs to an account, not to the emulator (#737
fix(iam): publish the caller's unique ID and tags as condition keys (#…