Description
The console's Delete user and Delete role handlers drop the deleted principal's cached credentials, policies, boundary and tags, but not its cached creation time. The management API handlers drop that too. A user or role that is deleted and then created again with the same name can therefore be evaluated with the old principal's creation time for up to auth.cache.ttl_seconds (60 s by default).
Mechanism
The creation time is an input to the principal's aws:userid (crates/auth/src/policy/principal_id.rs) and is read through the user_created_at and role_created_at caches (crates/server/src/authorization.rs:104, :206).
On main (2287d17):
management/iam_user.rs:212callsinvalidate_user_created_at, andmanagement/iam_role.rs:174callsinvalidate_role_created_at, after the delete.console/pages/user_pages.rsdelete_user(invalidations at lines 359-379) andconsole/pages/role_pages.rsdelete_role(lines 316-337) call every other invalidation but not these two.
So after a console delete, a same-name principal created within the TTL gets the deleted principal's aws:userid, and a policy condition on aws:userid written for the old principal matches the new one until the entry expires.
Reproduction
- Create user
uwith an access key, and make one request with it so the creation time is cached. - Delete
uin the console, createuagain through the management API, and give it an access key. - Within 60 s, make a request that is decided by an
aws:useridcondition. It is evaluated with the old user's id. After the TTL, or with the delete done through the management API, it uses the new id.
Expected
The console delete handlers drop the creation-time entry, as the management handlers do.
Found while writing #786.
Activity
docs(security-model): describe the credential and policy caches
docs(security-model): describe the credential and policy caches (Exte…