Skip to content

Strip OIDC token request env vars from Claude session environment#1029

Open
MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
MaxwellCalkin:fix/strip-oidc-env-vars
Open

Strip OIDC token request env vars from Claude session environment#1029
MaxwellCalkin wants to merge 1 commit intoanthropics:mainfrom
MaxwellCalkin:fix/strip-oidc-env-vars

Conversation

@MaxwellCalkin
Copy link

Summary

Fixes #1010

The Claude session environment is built by spreading process.env in parseSdkOptions() (base-action/src/parse-sdk-options.ts). When the workflow has id-token: write permission, this includes:

  • ACTIONS_ID_TOKEN_REQUEST_URL — the GitHub OIDC token endpoint
  • ACTIONS_ID_TOKEN_REQUEST_TOKEN — the bearer token to call that endpoint
  • ACTIONS_RUNTIME_TOKEN — the Actions runtime authentication token

These variables allow the Claude session to mint arbitrary OIDC tokens, which can be exchanged for credentials to cloud providers (AWS, GCP, Azure) configured to trust the repository's OIDC identity. This is a privilege escalation — the id-token: write permission is intended for the action's own authentication (in src/github/token.ts), not for the Claude session.

Changes

  • base-action/src/parse-sdk-options.ts: Delete ACTIONS_ID_TOKEN_REQUEST_URL, ACTIONS_ID_TOKEN_REQUEST_TOKEN, and ACTIONS_RUNTIME_TOKEN from the env object after spreading process.env, before passing it to the SDK.
  • base-action/test/parse-sdk-options.test.ts: Add test verifying these variables are stripped from sdkOptions.env.

Test plan

  • Existing tests pass (no env vars relied on these being present in the Claude session)
  • New test confirms all three variables are stripped from sdkOptions.env even when set in process.env
  • Workflows using OIDC auth (Bedrock, Vertex, Foundry) continue to work — the action's own token exchange in token.ts reads from process.env directly, before parseSdkOptions() is called

The Claude session inherits the full process.env, which includes
ACTIONS_ID_TOKEN_REQUEST_URL, ACTIONS_ID_TOKEN_REQUEST_TOKEN, and
ACTIONS_RUNTIME_TOKEN when the workflow has `id-token: write` permission.

This allows the Claude session to call GitHub's OIDC token endpoint and
mint arbitrary tokens, escalating privileges beyond what was intended.

These variables are only needed by the action itself (in token.ts for
initial authentication) and should never be passed to the Claude SDK
session.

Fixes anthropics#1010
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude session has access to OIDC token request environment variables, allowing it to mint new tokens

1 participant