Skip to content

OCPBUGS-100279: isolate Claude from push credentials in PR workflows - #9214

Merged
celebdor merged 1 commit into
openshift:mainfrom
bryan-cox:OCPBUGS-100279
Aug 4, 2026
Merged

OCPBUGS-100279: isolate Claude from push credentials in PR workflows#9214
celebdor merged 1 commit into
openshift:mainfrom
bryan-cox:OCPBUGS-100279

Conversation

@bryan-cox

@bryan-cox bryan-cox commented Aug 4, 2026

Copy link
Copy Markdown
Member

What this PR does / why we need it:

Hardens the reusable-claude-on-pr.yaml GitHub Actions workflow against context file injection and credential exposure when operating on fork PRs.

The workflow previously checked out fork PR content with persist-credentials: true and passed GH_TOKEN (a write-scoped token) to the Claude step's environment. An external PR author could craft malicious CLAUDE.md/AGENTS.md files or pre-commit hooks that Claude would load and execute with Bash access, gaining access to the repo write token and GCP WIF credentials.

Changes:

  • Add --bare to the Claude invocation — prevents loading CLAUDE.md/AGENTS.md from the fork checkout and skips hooks, eliminating context file and pre-commit hook injection vectors. Skills still resolve via /skill-name so /restructure-commits continues to work.
  • Set persist-credentials: false — prevents the checkout action from storing the write token in .git/config.
  • Remove GH_TOKEN from the Claude step's env — Claude no longer has access to a write-scoped token during execution.
  • Add a dedicated post-Claude push step — acquires the token only at push time and handles push failures with a PR comment.
  • Update caller prompts (rebase.yaml, restructure-commits.yaml) — remove push instructions from Claude prompts since the workflow now handles pushing.

Which issue(s) this PR fixes:

Fixes https://redhat.atlassian.net/browse/OCPBUGS-100279

Special notes for your reviewer:

The severity was reassessed to CVSS 4.2 / Medium (down from 8.0 / High) — see the detailed assessment. This is CI tooling, not product code.

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Always review AI generated responses prior to use.
Generated with Claude Code via openshift-developer plugin

Summary by CodeRabbit

  • Chores
    • Improved automated pull request maintenance workflows.
    • Branch updates are now handled more reliably through centralized automation.
    • Reduced the risk of duplicate or conflicting pushes during automated rebasing and commit restructuring.
    • Added clearer failure handling when automated changes cannot be applied.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 4, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@bryan-cox: This pull request references Jira Issue OCPBUGS-100279, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

What this PR does / why we need it:

Hardens the reusable-claude-on-pr.yaml GitHub Actions workflow against context file injection and credential exposure when operating on fork PRs.

The workflow previously checked out fork PR content with persist-credentials: true and passed GH_TOKEN (a write-scoped token) to the Claude step's environment. An external PR author could craft malicious CLAUDE.md/AGENTS.md files or pre-commit hooks that Claude would load and execute with Bash access, gaining access to the repo write token and GCP WIF credentials.

Changes:

  • Add --bare to the Claude invocation — prevents loading CLAUDE.md/AGENTS.md from the fork checkout and skips hooks, eliminating context file and pre-commit hook injection vectors. Skills still resolve via /skill-name so /restructure-commits continues to work.
  • Set persist-credentials: false — prevents the checkout action from storing the write token in .git/config.
  • Remove GH_TOKEN from the Claude step's env — Claude no longer has access to a write-scoped token during execution.
  • Add a dedicated post-Claude push step — acquires the token only at push time and handles push failures with a PR comment.
  • Update caller prompts (rebase.yaml, restructure-commits.yaml) — remove push instructions from Claude prompts since the workflow now handles pushing.

Which issue(s) this PR fixes:

Fixes https://redhat.atlassian.net/browse/OCPBUGS-100279

Special notes for your reviewer:

The severity was reassessed to CVSS 4.2 / Medium (down from 8.0 / High) — see the detailed assessment. This is CI tooling, not product code.

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Always review AI generated responses prior to use.
Generated with Claude Code via openshift-developer plugin

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: f59dae79-58d1-42cc-b314-474b6a0bd378

📥 Commits

Reviewing files that changed from the base of the PR and between 0f82a27 and 6be67a5.

📒 Files selected for processing (3)
  • .github/workflows/rebase.yaml
  • .github/workflows/restructure-commits.yaml
  • .github/workflows/reusable-claude-on-pr.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/restructure-commits.yaml
  • .github/workflows/rebase.yaml
  • .github/workflows/reusable-claude-on-pr.yaml

📝 Walkthrough

Walkthrough

The workflows now instruct Claude not to push changes. The reusable workflow disables persisted checkout credentials, removes GH_TOKEN from Claude, and runs Claude in bare mode. A later CI step authenticates the PR repository, force-pushes the current HEAD to the PR branch, and comments on the PR when the push fails.

Sequence Diagram(s)

sequenceDiagram
  participant GitHubActions
  participant Claude
  participant PRRepository
  participant PRComment
  GitHubActions->>Claude: Run in bare mode
  Claude-->>GitHubActions: Return changes without pushing
  GitHubActions->>PRRepository: Authenticate and force-push HEAD
  GitHubActions->>PRComment: Report push failure when push fails
Loading

Suggested reviewers: jparrill, muraee


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error The Push changes step embeds PUSH_TOKEN in a git remote URL (line 148) and redirects stderr to stdout (line 149), risking token exposure in error logs if push fails. Use git credential helpers or environment variables instead of embedding tokens in URLs. Suppress error output containing credentials or use GIT_TRACE=0 to disable git logging.
✅ Passed checks (10 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary security change: isolating Claude from push credentials in pull request workflows.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed PR modifies only GitHub Actions workflow YAML files; no Go test files or Ginkgo test definitions were changed. Check is not applicable.
Test Structure And Quality ✅ Passed PR modifies GitHub Actions workflow YAML files, not Ginkgo test code. Custom check for Ginkgo test quality is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed This PR modifies only GitHub Actions workflow YAML files, not Kubernetes deployment manifests, operator code, or controllers. The check is not applicable to CI/CD automation configuration.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR modifies only GitHub Actions workflows (.yaml files). No Ginkgo e2e tests are added, so the IPv6/disconnected network check does not apply.
No-Weak-Crypto ✅ Passed The PR contains only GitHub Actions workflow YAML changes with no weak cryptographic algorithms (MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB), custom crypto implementations, or unsafe secret comparisons.
Container-Privileges ✅ Passed The PR modifies GitHub Actions workflow files only, not container or Kubernetes manifests. The files contain no privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, or allowPrivilegeEscalation con...
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@openshift-ci
openshift-ci Bot requested review from jparrill and muraee August 4, 2026 13:58
@openshift-ci openshift-ci Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release and removed do-not-merge/needs-area labels Aug 4, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/reusable-claude-on-pr.yaml:
- Around line 137-152: Separate the Claude execution from the credentialed push:
run Claude in an uncredentialed workspace, export only its changes as a patch
artifact, and remove shared workspace access to PUSH_TOKEN. Replace the current
Push changes step with a dependent fresh job that checks out the target branch,
applies the patch, disables Git hooks, and performs the existing push and
failure-comment flow using PUSH_TOKEN.

In
`@control-plane-operator/hostedclusterconfigoperator/controllers/globalps/globalps_test.go`:
- Around line 519-521: Update the test setup around runtime.NewScheme in the
globalps test to check the errors returned by corev1.AddToScheme and
appsv1.AddToScheme, failing the test immediately with the registration error
instead of discarding it. Keep the existing scheme registration order and
fake-client setup unchanged.

In
`@control-plane-operator/hostedclusterconfigoperator/controllers/globalps/globalps.go`:
- Around line 182-185: The DaemonSet no-op check in globalps.go must not rely
only on config seed and volume count; compare all controller-managed fields or
allow CreateOrUpdate to detect differences, including rolling-update strategy
and readiness probe. In
control-plane-operator/hostedclusterconfigoperator/controllers/globalps/globalps.go
lines 182-185, remove or expand the early return accordingly. In
control-plane-operator/hostedclusterconfigoperator/controllers/globalps/globalps_test.go
lines 542-555, add a legacy DaemonSet fixture with matching seed and volumes but
missing the new fields, and assert reconciliation invokes CreateOrUpdate.
- Around line 181-188: The Get call in the existing daemon set lookup must not
suppress unexpected errors. Update the error handling around c.Get in the global
pull-secret reconciliation flow to continue on apierrors.IsNotFound(err), but
return a wrapped error for all other errors; preserve the existing early return
when the fetched object matches the expected labels and volume count.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 30825d57-641d-415c-86d3-14e3009b7c68

📥 Commits

Reviewing files that changed from the base of the PR and between 2204ef8 and 0f82a27.

📒 Files selected for processing (7)
  • .github/workflows/rebase.yaml
  • .github/workflows/restructure-commits.yaml
  • .github/workflows/reusable-claude-on-pr.yaml
  • control-plane-operator/hostedclusterconfigoperator/controllers/globalps/globalps.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/globalps/globalps_test.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/globalps/setup.go
  • control-plane-operator/hostedclusterconfigoperator/controllers/globalps/setup_test.go

Comment thread .github/workflows/reusable-claude-on-pr.yaml
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.96%. Comparing base (2204ef8) to head (0f82a27).

⚠️ Current head 0f82a27 differs from pull request most recent head 6be67a5

Please upload reports for the commit 6be67a5 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9214      +/-   ##
==========================================
+ Coverage   44.95%   44.96%   +0.01%     
==========================================
  Files         778      778              
  Lines       97434    97467      +33     
==========================================
+ Hits        43797    43830      +33     
  Misses      50615    50615              
  Partials     3022     3022              
Files with missing lines Coverage Δ
...terconfigoperator/controllers/globalps/globalps.go 87.91% <100.00%> (+1.03%) ⬆️
...lusterconfigoperator/controllers/globalps/setup.go 17.64% <100.00%> (+7.39%) ⬆️
Flag Coverage Δ
cmd-support 38.62% <ø> (ø)
cpo-hostedcontrolplane 47.28% <ø> (ø)
cpo-other 45.80% <100.00%> (+0.13%) ⬆️
hypershift-operator 54.95% <ø> (ø)
other 34.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add --bare to the Claude invocation to prevent loading CLAUDE.md,
AGENTS.md, and pre-commit hooks from fork checkouts, eliminating
context file and hook injection vectors. Separate Claude execution
from push credentials by setting persist-credentials: false, removing
GH_TOKEN from the Claude step, and adding a dedicated post-Claude push
step. Update caller prompts to remove push instructions since the
workflow now handles pushing.

OCPBUGS-100279

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@bryan-cox: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@celebdor celebdor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@celebdor
celebdor merged commit 6cd5628 into openshift:main Aug 4, 2026
19 of 20 checks passed
@openshift-ci-robot

Copy link
Copy Markdown

@bryan-cox: Jira Issue OCPBUGS-100279: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-100279 has been moved to the MODIFIED state.

Details

In response to this:

What this PR does / why we need it:

Hardens the reusable-claude-on-pr.yaml GitHub Actions workflow against context file injection and credential exposure when operating on fork PRs.

The workflow previously checked out fork PR content with persist-credentials: true and passed GH_TOKEN (a write-scoped token) to the Claude step's environment. An external PR author could craft malicious CLAUDE.md/AGENTS.md files or pre-commit hooks that Claude would load and execute with Bash access, gaining access to the repo write token and GCP WIF credentials.

Changes:

  • Add --bare to the Claude invocation — prevents loading CLAUDE.md/AGENTS.md from the fork checkout and skips hooks, eliminating context file and pre-commit hook injection vectors. Skills still resolve via /skill-name so /restructure-commits continues to work.
  • Set persist-credentials: false — prevents the checkout action from storing the write token in .git/config.
  • Remove GH_TOKEN from the Claude step's env — Claude no longer has access to a write-scoped token during execution.
  • Add a dedicated post-Claude push step — acquires the token only at push time and handles push failures with a PR comment.
  • Update caller prompts (rebase.yaml, restructure-commits.yaml) — remove push instructions from Claude prompts since the workflow now handles pushing.

Which issue(s) this PR fixes:

Fixes https://redhat.atlassian.net/browse/OCPBUGS-100279

Special notes for your reviewer:

The severity was reassessed to CVSS 4.2 / Medium (down from 8.0 / High) — see the detailed assessment. This is CI tooling, not product code.

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Always review AI generated responses prior to use.
Generated with Claude Code via openshift-developer plugin

Summary by CodeRabbit

  • Chores
  • Improved automated pull request maintenance workflows.
  • Branch updates are now handled more reliably through centralized automation.
  • Reduced the risk of duplicate or conflicting pushes during automated rebasing and commit restructuring.
  • Added clearer failure handling when automated changes cannot be applied.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@bryan-cox
bryan-cox deleted the OCPBUGS-100279 branch August 4, 2026 16:10
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 4, 2026
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bryan-cox, celebdor

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/control-plane-operator Indicates the PR includes changes for the control plane operator - in an OCP release jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants