Cloud security AWS STS 4 min read
What is AWS STS?
A build pipeline deploys to AWS on every merge. If its credentials leak in a log one day, how long should they keep working?
-
Assume a role, get credentials that expire
Instead of an access key saved in the pipeline’s settings, the job asks STS to assume
deploy-role. STS checks the role’s trust policy: is this pipeline allowed to?If it is, STS returns temporary credentials. They carry the role’s permissions, work like an access key, and stop working on their own, here after an hour.
The deploy job asks STS to assume deploy-role. STS checks the trust policy and returns credentials that last one hour. The job uploads the build to S3. Two hours later the same credentials are refused.
No long-lived key anywhere in the pipeline. In short A leaked temporary credential has a short life.
-
What comes back
STS returns three secrets and an expiry. The key ID starts with
ASIA, where long-lived keys start withAKIA, a quick way to tell them apart in logs. The secret signs each request. The session token must travel with every request, or the other two are refused.AssumeRole gives one hour by default, and the role sets the maximum.
Ask, get a short-lived key, use it, and it expires by itself. In short They work like an access key, until the clock runs out.
What “temporary” doesn’t mean
Temporary limits the window; it doesn’t close it. Credentials with 50 minutes left, printed in a public build log, work in full for those 50 minutes.
Revoke the role’s active sessions straight away, which blocks every credential issued before that moment. Keep sessions short and trust policies tight.
Keep this
Assume a role, get credentials that expire. No long-lived key to leak.
Temporary still means usable until expiry. Keep sessions short, trust policies tight, and revoke sessions if they leak.- Assume a role
- Ask STS for the role’s permissions.
- Trust policy
- Decides who may assume the role.
- Temporary
- Key ID, secret and session token that expire.
- Limit
- They work until they expire unless revoked.
Questions worth carrying
What decides who can assume a role?
The role’s trust policy. It names which accounts, services or identity providers may assume it, and under what conditions.
Can a pipeline get STS credentials without any stored secret?
Yes. Many CI systems sign in to AWS with OIDC: AWS trusts the CI provider’s identity token and issues temporary credentials.