ci-agent-hardening
БесплатноЗапускает вложенные скриптыНе проверенAudit and harden GitHub Actions workflows against prompt injection, pull_request_target exploits (Pwn Requests), expression injection, cache poisoning…
от stacklok★ 27 звёзд на GitHubОб этом скилле
CI Agent Hardening
Audit and fix security vulnerabilities in GitHub Actions workflows, with emphasis on AI-powered CI/CD. Based on two major 2026 incidents:
- Clinejection — Prompt injection in AI triage bot led to cache poisoning, credential theft, malicious npm publish (~4,000 developers affected)
- hackerbot-claw — Autonomous AI bot exploited 7 repos (Microsoft, DataDog, CNCF, Aqua Trivy), achieving full repo compromise on Trivy (25k+ stars) via PAT theft
Prerequisites
- Repository with
.github/workflows/directory bashavailable for running the audit script
Instructions
For background and exploit details on any pattern below, see references/ATTACK-PATTERNS.md.
Step 1: Run the Automated Audit
Run from the repository root:
bash <skill-path>/scripts/audit-workflows.sh .github/workflows
Review [CRIT] findings first (exploitable now), then [WARN] (defense gaps).
Step 2: Fix pull_request_target + Fork Checkout (CRITICAL)
This is the #1 attack vector. 4 of 7 hackerbot-claw attacks exploited it. Check every pull_request_target workflow:
# DANGEROUS — runs fork code with your secrets
on: pull_request_target
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }} # ATTACKER'S CODE
# SAFE — use pull_request trigger instead (no secret access)
on: pull_request
# SAFE — if pull_request_target needed, checkout base only
on: pull_request_target
steps:
- uses: actions/checkout@v4 # defaults to base branch
If the workflow needs both secrets AND fork code (e.g., comment on PR), split into two workflows: one that runs untrusted code (no secrets) and one that consumes artifacts (with secrets).
Step 3: Eliminate Expression Injection in run: Blocks
Any ${{ }} expression referencing user-controlled values inside a run: block is a shell injection. Branch names, filenames, PR titles, commit messages are all vectors.
# VULNERABLE — branch name is shell-evaluated
- run: echo "${{ github.event.pull_request.head.ref }}"
# SAFE — environment variable (properly quoted by runner)
- run: echo "$PR_HEAD_REF"
env:
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
Check ALL run: blocks for these user-controlled fields:
github.event.issue.title/.bodygithub.event.pull_request.title/.body/.head.refgithub.event.comment.bodygithub.event.discussion.title/.bodygithub.event.review.bodygithub.event.head_commit.message
Step 4: Secure Slash Commands
Any issue_comment-triggered workflow that runs code must check author_association:
# VULNERABLE — any GitHub user can trigger
if: contains(github.event.comment.body, '/deploy')
# SAFE — restrict to maintainers
if: >-
contains(github.event.comment.body, '/deploy') &&
(github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'OWNER')
Step 5: Harden AI Agent Workflows
- Minimize tools — Triage/review bots need
Readat most. NEVER grantBashto workflows triggered by external users. - Remove wildcard users — Delete
allowed_non_write_users: "*". Scope to known collaborators. - Restrict permissions — AI workflows should have
contents: readat most. - Protect CLAUDE.md — Add to
CODEOWNERSrequiring maintainer review. Validate against expected schema in CI. - Never checkout fork code for AI review — use base branch checkout only.
Step 6: Set Least-Privilege Permissions
Every workflow must have an explicit permissions: block:
permissions:
contents: read
pull-requests: read # or write only if needed
A quality check script does NOT need contents: write. A GITHUB_TOKEN with write access, if stolen, allows pushing commits and merging PRs.
Step 7: Harden Credential Management
- Use OIDC provenance —
npm publish --provenance, PyPI trusted publishers. Eliminates static tokens. - Prefer
GITHUB_TOKENover PATs — auto-scoped, expires after workflow. - If PAT required — use fine-grained PATs with minimal scope, stored in GitHub Environments with protection rules.
- Separate nightly/production credentials — different tokens, scopes, and workflows.
- Verify rotation — test-publish a canary after rotating to confirm old token is revoked.
Step 8: Eliminate Cache Attack Surface
- Remove
actions/cachefrom release workflows — install dependencies fresh. - If cache required — use workflow-specific key prefixes that cannot be written by other workflows.
- Monitor for anomalies — cache size >10GB, sudden miss rate spikes.
Step 9: Network Egress Monitoring
Every attack in the hackerbot-claw campaign depended on curl to hackmoltrepeat.com. Consider:
- StepSecurity Harden-Runner for network egress allowlisting
- Alert on outbound calls to unknown domains during CI
- Block
curl/wgetto
Установить ci-agent-hardening в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл ci-agent-hardening?
Audit and harden GitHub Actions workflows against prompt injection, pull_request_target exploits (Pwn Requests), expression injection, cache poisoning, credential theft, and supply chain attacks. Based on Clinejection and hackerbot-claw campaigns. Use when reviewing CI/CD security, securing AI agent workflows, hardening publishing pipelines, or checking for GitHub Actions misconfigurations. Also covers slash command authorization, CLAUDE.md protection, and network egress. NOT for general CI/CD optimization or non-security workflow issues.
Как установить скилл ci-agent-hardening?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ci-agent-hardening запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
ci-review
The scan that the plugin's GitHub Action runs.
от Anthropicazure-static-web-apps
Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
от GitHubai-ready
Make any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
от GitHubaws-cdk-python-setup
Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…
от GitHub