CI/CD Hardening Checklist
1. Workspace Trust & Input Safety (Highest Priority)
Never auto‑trust workspaces in CI
- Require explicit trust configuration for any repo contents before loading configs or env files.
- Mandatory for AI agents running in headless mode (e.g., Gemini CLI).
Treat forks, PRs, issues, and comments as untrusted
- Especially dangerous when pipelines run on
pull_request_target. - Never load
.env,.gemini/, or agent config from untrusted inputs.
- Especially dangerous when pipelines run on
Block configuration discovery
- Disable recursive discovery of agent configs unless explicitly allow‑listed.
2. AI Agent–Specific Controls (Gemini CLI, Claude Code, etc.)
Upgrade all agent tools
- Gemini CLI ≥ 0.39.1
run-gemini-cliAction ≥ 0.1.22
Disable unrestricted execution modes
- Avoid
--yoloor equivalent autonomous modes. - If required, enforce strict command allowlists.
- Avoid
Separate “analysis” from “execution”
- Let agents review or suggest changes.
- Require a human gate or isolated job for command execution.
No agent runs with contributor‑level privileges
- AI agents should never hold the same rights as a trusted developer.
- AI agents should never hold the same rights as a trusted developer.
3. Tool Allowlisting & Command Execution
Explicit command allowlists
- Allow only exact binaries + arguments.
- No wildcards (
*, shell expansion, pipes).
Disable shell by default
- Prefer structured tools over
run_shell_command.
- Prefer structured tools over
Fail closed
- Any unknown or malformed command should hard‑fail the job.
4. Secrets & Credential Protection
Do not expose secrets to untrusted workflows
- Especially on fork PRs and external contributions.
- Especially on fork PRs and external contributions.
Use short‑lived, scoped credentials
- Replace static tokens with OIDC or ephemeral secrets.
Automatic secret revocation
- Rotate credentials after any compromised run or failed trust check.
- Rotate credentials after any compromised run or failed trust check.
5. Execution Environment Isolation
Ephemeral CI runners
- Destroy runners after each job.
- No shared disk or persistent state.
Network egress restrictions
- Default‑deny outbound access.
- Block data exfiltration paths.
Filesystem sandboxing
- Read‑only source directories.
- Writable temp directories only.
6. Dependency & Action Supply‑Chain Security
Pin all GitHub Actions
- Use SHA commits, not tags.
Enable Dependabot / Renovate
- Monitor toolchain and agent dependencies for security advisories.
- Monitor toolchain and agent dependencies for security advisories.
Review AI agent updates as breaking changes
- Treat behavior changes (trust, sandboxing) as security‑impacting.
- Treat behavior changes (trust, sandboxing) as security‑impacting.
7. Pipeline Logic & Permissions
Principle of least privilege
- Separate jobs for:
- Lint / analysis
- Build
- Deployment
- Agent activity
- Separate jobs for:
No deployment from untrusted branches
- Require protected branches + manual approval.
Explicit environment protection rules
- Require reviewers for prod‑level secrets.
8. Logging, Detection & Audit
Log every executed command
- Include AI‑initiated commands.
- Include AI‑initiated commands.
Preserve artifacts for forensic review
- Capture workspace snapshots for suspicious runs.
Alert on abnormal behavior
- Unexpected network calls
- Config discovery
- Shell execution attempts
9. Incident Readiness
Pre‑define a CI incident playbook
- Credential rotation
- Runner teardown
- Repository lock‑down
Assume compromise if RCE occurs
- Treat CI runners as fully breached.
- Treat CI runners as fully breached.
10. Governance & Policy
Document agent trust policy
- When agents may execute
- What inputs are considered safe
Train developers
- AI agents are code execution systems, not just chat assistants.
.png)