fix(security): pull_request_target vulnerabilities and expression injection - #7
Merged
Merged
Conversation
…ction Multiple workflows are vulnerable to the "pwn request" attack documented by StepSecurity (https://www.stepsecurity.io/blog/hackerbot-claw-github-actions-exploitation). CRITICAL - adapter-code-coverage.yml and semgrep.yml: Both use pull_request_target and check out fork PR code via head.ref + head.repo.full_name, then execute it (go test, semgrep, actions/github-script loading JS from the PR). This grants attackers write access to the repo token, enabling full repository takeover. Fix: Switch to pull_request trigger, pin checkout to head.sha instead of head.ref, and add fork-detection conditions to skip write operations (coverage push, PR comments) for fork PRs where the token is read-only. LOW - cross-repo-issue.yml: Uses pull_request_target legitimately (needs secrets, only fires on merged PRs) but has expression injection: github.event.pull_request.title used directly in a run: block. A malicious PR title could execute arbitrary commands. Fix: Move PR title and other event data to env vars. Add permissions block. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pull_request_targetwithpull_requestinadapter-code-coverage.ymlandsemgrep.yml(CRITICAL)cross-repo-issue.ymlby moving attacker-controlled inputs to env varspermissionsblocks for least-privilegeVulnerabilities Fixed
CRITICAL: adapter-code-coverage.yml and semgrep.yml
Both workflows use
pull_request_targetand check out the fork PR code:Then execute untrusted code:
adapter-code-coverage.yml: Runsgo test, loads JS viarequire()from PR code, hascontents: write+pull-requests: writesemgrep.yml: Runs semgrep, loads JS viarequire()from PR code, haspull-requests: writeAn attacker can modify
.github/workflows/helpers/pull-request-utils.jsin their fork PR to exfiltrate the write-access GITHUB_TOKEN, enabling full repository takeover.LOW: cross-repo-issue.yml (expression injection)
${{ github.event.pull_request.title }}used directly in arun:block without sanitization. A malicious PR title could execute arbitrary shell commands. This only fires on merged PRs (requiring maintainer approval), but is still a defense-in-depth issue.Reference
This is the exact attack vector exploited by hackerbot-claw as documented by StepSecurity.
Changes
adapter-code-coverage.ymlpull_request_target->pull_request, pin tohead.sha, fork-check on write opssemgrep.ymlpull_request_target->pull_request, pin tohead.sha, fork-check on write opscross-repo-issue.ymlpull_request.titleto env var, addpermissionsblockBehavioral changes
pull_request_target(necessary for secrets access on merged PRs), but expression injection is fixedTest plan
adapters/adapters/🤖 Generated with Claude Code