Relationships
#5159 swamp serve: run steps under the calling CI job's own cloud role (GitLab/GitHub OIDC)
Opened by universam · 11/27/2026
Summary
Our CI grants each project its own IAM role per ref type, and AWS only lets a
job assume the role matching its GitLab OIDC identity. When swamp serve
acts on a job's behalf, it can neither verify that identity nor use that role,
so it would need the union of every project's permissions. We ask serve to
accept CI OIDC tokens as principals and to run each job's steps with
credentials from the job's own role (AssumeRoleWithWebIdentity), so AWS
keeps enforcing the boundary and serve holds no standing cloud permissions.
This also improves serve's own security posture. AssumeRoleWithWebIdentity
is an unsigned STS call, so serve needs no AWS credentials or IAM permissions
at all to run steps; its only AWS access is to its datastore, if that is in
AWS. A compromised serve can then act only with tokens of jobs currently
calling it, within those jobs' own permissions and token lifetime, instead of
holding the union of every project's permissions.
Problem
Our CI follows strict least privilege. Each GitLab project gets its own AWS IAM roles, one per ref type, per target account:
git@oidc.<project-id>.p: protected refs (main, release tags)git@oidc.<project-id>.u: unprotected refs (merge requests)
Each role trusts only the GitLab OIDC issuer, and only a token whose sub is
exactly project_path:<group>/<project>:ref_protected:<true|false>. The
permissions are defined in one central repository and generated from it.
AWS enforces the boundary: an MR pipeline of project X cannot act with X's
release permissions, nor with any permission of project Y.
swamp serve breaks this model as soon as it acts on a job's behalf:
- Serve cannot authenticate a CI job by its OIDC identity.
--auth-modeistokenoroauth(swamp-club), and principals areuser,workerorservice. - Steps that run on serve use serve's host credentials. Your access-control design says provider CLIs "use the host's credentials" and are not bounded by grants.
So serve would need a role that is the union of every project's permissions, and the per-project, per-ref boundary would move from AWS into swamp grants. That is a weaker boundary than we have today, and a second place where permissions must be maintained.
Proposed feature
Two parts, independently useful:
CI OIDC as a principal. An auth mode that accepts a GitLab CI (or GitHub Actions)
id_token, verifies it against the issuer's JWKS,audand expiry, and maps claims to a principal, e.g.ci:gitlab.example.org/<project_path>:protected. Grants can then name it, so the swamp grants can be generated from the same central definition as the IAM roles.Act on behalf with the caller's role. For a run started by such a principal, serve exchanges the caller's token for credentials and gives only those to the run's steps:
- AWS: the caller names the roles in the run request, one per target
account (e.g.
--assume-role prod=arn:aws:iam::<account>:role/<name>), and serve callssts:AssumeRoleWithWebIdentityfor each with the forwardedid_token. Steps pick a credential by its name, like an AWS profile. - Serve does not validate the role or the forwarded token, and needs no
role naming convention. It passes the token to STS unchanged; AWS
checks the token's signature and the role's trust policy, and refuses
any role the token is not trusted for. Because
AssumeRoleWithWebIdentityneeds no AWS credentials, serve holds none. - One ID token is enough: serve verifies it for login (part 1) and forwards
the same token to STS. Serve should therefore accept a configured
audience such as
sts.amazonaws.com. A job may optionally send a second token with serve's own audience for login, as audience-separation hygiene; it adds little here, because serve must receive the AWS token anyway. - The credentials are short-lived, never written to the datastore, and replace the host credential chain for that run, including for steps on workers.
With (2), serve needs no standing cloud permissions of its own. AWS keeps enforcing the per-project, per-ref boundary, because serve can only assume a role that trusts the caller's token.
- AWS: the caller names the roles in the run request, one per target
account (e.g.
Related: #4931 (collective OIDC for human sign-in) covers people, not CI jobs.
Open
No activity in this phase yet.
Sign in to post a ripple.