Skip to content

fix: Harden Claude GitHub workflows#5408

Merged
chtruong814 merged 8 commits into
NVIDIA:mainfrom
chtruong814:chtruong/claude-action
Jul 22, 2026
Merged

fix: Harden Claude GitHub workflows#5408
chtruong814 merged 8 commits into
NVIDIA:mainfrom
chtruong814:chtruong/claude-action

Conversation

@chtruong814

@chtruong814 chtruong814 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR hardens the Claude-enabled GitHub workflows while preserving their intended maintainer-only behavior.

Changes:

  • Split the Claude complexity label workflow into a read-only Claude analysis job and a deterministic label-application job.
    • Claude no longer receives secrets.PAT.
    • Claude no longer has gh pr edit access.
    • The write step validates Claude's output against an allowlist before applying labels with the scoped workflow token.
  • Split the Claude copy-to-main workflow into deterministic authorization/publish jobs and a read-scoped Claude conflict-resolution job.
    • The PAT remains available only to deterministic steps that need the service-user identity.
    • Claude receives the scoped workflow token and produces a patch artifact instead of directly publishing with the PAT.
    • Commits produced by the workflow continue to be signed off.
  • Harden the Claude review workflow.
    • Removed id-token: write from the Claude review jobs.
    • Passed the scoped workflow token explicitly to avoid the Claude action's OIDC GitHub App token exchange path.
    • Removed full Claude output logging.
    • Removed direct gh pr comment access from Claude's allowed tools.
  • Harden the nightly sync Claude workflow.
    • Reduced the built-in GITHUB_TOKEN to read-only.
    • Removed id-token: write.
    • Removed full Claude output logging.

Why

The Claude workflows are already gated so they do not run for actors without write access to the repository. That means these workflows are not intended to be externally triggerable by arbitrary contributors.

Example workflow that does not run for truly external user:
https://github.com/NVIDIA/Megatron-LM/actions/runs/27874311676/job/82491146034?pr=5407

The hardening is still necessary because the workflows process PR content and comments as agent context after a trusted actor triggers them. If a trusted maintainer invokes Claude on a PR containing prompt-injected content, any credentials or write capabilities available to the Claude step become part of the blast radius. These changes apply least privilege to the Claude steps themselves: Claude gets only the access it needs for analysis or conflict resolution, while deterministic workflow steps perform privileged writes after validation.

Testing

  • YAML parse check passed for modified workflows.
  • Verified the Claude action source behavior for github_token and OIDC: when github_token is supplied, the action uses the provided token instead of requesting a GitHub OIDC token for app-token exchange.

No runtime workflow execution was performed locally.

Signed-off-by: Charlie Truong <chtruong@nvidia.com>
Signed-off-by: Charlie Truong <chtruong@nvidia.com>
Signed-off-by: Charlie Truong <chtruong@nvidia.com>
Signed-off-by: Charlie Truong <chtruong@nvidia.com>
Signed-off-by: Charlie Truong <chtruong@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@chtruong814
chtruong814 marked this pull request as ready for review June 20, 2026 14:43
@chtruong814
chtruong814 requested a review from a team as a code owner June 20, 2026 14:43
@chtruong814 chtruong814 changed the title Harden Claude GitHub workflows fix: Harden Claude GitHub workflows Jun 20, 2026
Signed-off-by: Charlie Truong <chtruong@nvidia.com>
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the Approved All necessary approvals have been made label Jun 24, 2026
@chtruong814
chtruong814 enabled auto-merge June 25, 2026 03:04
@chtruong814
chtruong814 added this pull request to the merge queue Jun 25, 2026
@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/28144084178

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 25, 2026
Signed-off-by: Charlie Truong <chtruong@nvidia.com>

# Conflicts:
#	.github/workflows/claude-complexity-label.yml
#	.github/workflows/claude-copy-to-main.yml
#	.github/workflows/claude_review.yml
Signed-off-by: Charlie Truong <chtruong@nvidia.com>
@chtruong814
chtruong814 merged commit ddaa315 into NVIDIA:main Jul 22, 2026
32 checks passed
@chtruong814
chtruong814 deleted the chtruong/claude-action branch July 22, 2026 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved All necessary approvals have been made complexity: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants