diff --git a/base-action/src/parse-sdk-options.ts b/base-action/src/parse-sdk-options.ts index 35df281d2..5576117b7 100644 --- a/base-action/src/parse-sdk-options.ts +++ b/base-action/src/parse-sdk-options.ts @@ -215,6 +215,12 @@ export function parseSdkOptions(options: ClaudeOptions): ParsedSdkOptions { // Set the entrypoint for Claude Code to identify this as the GitHub Action env.CLAUDE_CODE_ENTRYPOINT = "claude-code-github-action"; + // Remove OIDC token request variables so Claude cannot mint new tokens. + // These are only needed by the action itself (via @actions/core.getIDToken()), + // not by the Claude session. + delete env.ACTIONS_ID_TOKEN_REQUEST_URL; + delete env.ACTIONS_ID_TOKEN_REQUEST_TOKEN; + // Build system prompt option - default to claude_code preset let systemPrompt: SdkOptions["systemPrompt"]; if (options.systemPrompt) { diff --git a/base-action/test/parse-sdk-options.test.ts b/base-action/test/parse-sdk-options.test.ts index 9c1095cef..e76e66c27 100644 --- a/base-action/test/parse-sdk-options.test.ts +++ b/base-action/test/parse-sdk-options.test.ts @@ -366,5 +366,26 @@ describe("parseSdkOptions", () => { "claude-code-github-action", ); }); + + test("should strip ACTIONS_ID_TOKEN_REQUEST_URL and ACTIONS_ID_TOKEN_REQUEST_TOKEN from env", () => { + const originalEnv = { ...process.env }; + process.env.ACTIONS_ID_TOKEN_REQUEST_URL = + "https://token.actions.githubusercontent.com"; + process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN = "secret-token-value"; + + try { + const options: ClaudeOptions = {}; + const result = parseSdkOptions(options); + + expect( + result.sdkOptions.env?.ACTIONS_ID_TOKEN_REQUEST_URL, + ).toBeUndefined(); + expect( + result.sdkOptions.env?.ACTIONS_ID_TOKEN_REQUEST_TOKEN, + ).toBeUndefined(); + } finally { + process.env = originalEnv; + } + }); }); });