Security review

From bradygaster/squad · View interactive version

Security review is an AI agent skill from the GitHub repository bradygaster/squad. How to review PRs for security — credentials, injection, workflow permissions, supply chain, git operation safety

How to use this skill

Skill file

Context

Every PR that touches authentication, credentials, environment variables, file system operations, child process execution, user input handling, GitHub API calls, or workflow files must be reviewed for security. This skill provides a systematic checklist for catching security issues before they reach production.

Use this skill when a PR includes any of:

Patterns

1. Secrets and Credentials

No secrets in source code — ever.

Review checklist:

Watch for disguised secrets:

2. Personal Data in Committed Files

Personal data (especially email addresses) must never be written to committed files.

Squad-specific rule: git config user.email is explicitly banned from being written to any file that gets committed. This prevents PII leakage into the repository.

Review checklist:

3. Environment Variable Safety

Review checklist:

4. File System Safety

Path traversal prevention:

Arbitrary file write prevention:

5. Child Process Safety

Shell injection prevention:

Review checklist for gh CLI wrappers:

6. GitHub Actions Workflow Security

pull_request_target safety:

Token scope minimization:

Recursion safety:

Secrets in workflows:

7. Git Operation Safety

These rules are from the project's mandatory Git Safety guidelines:

Staging safety:

Push safety:

If a PR adds git operations (e.g., in a script, workflow, or agent action), verify every git add, git commit, and git push command follows these rules.

8. Export/Import Integrity

Typos in export names cause silent runtime failures — the export resolves to undefined instead of throwing.

Review checklist:

9. Dependency Supply Chain

New npm dependencies should be audited:

Squad-specific: Protected bootstrap files must use ONLY node:* built-in modules. New dependencies in these files are a critical finding.

10. Multi-Account Auth Isolation

When the gh CLI is used in contexts where multiple GitHub accounts might be active:

Examples

Example 1: Critical — Shell injection in git command

PR adds:
  exec(`git commit -m "${commitMessage}"`)

Finding: [critical] Shell injection — commitMessage is user-controlled.
A message containing "; rm -rf /" would execute arbitrary commands.
Fix: Use execFile('git', ['commit', '-m', commitMessage]) instead.

Example 2: Critical — pull_request_target with checkout

PR adds workflow:
  on: pull_request_target
  steps:
    - uses: actions/checkout@v4
      with:
        ref: ${{ github.event.pull_request.head.ref }}
    - run: npm test

Finding: [critical] pull_request_target + PR head checkout = untrusted
code execution with write token. An attacker can modify package.json
scripts in their fork to exfiltrate GITHUB_TOKEN.
Fix: Use 'pull_request' trigger instead, or do not checkout PR code.

Example 3: High — Email written to committed file

PR adds to init.ts:
  const email = execSync('git config user.email').toString().trim();
  fs.writeFileSync('.squad/config.json', JSON.stringify({ author: email }));

Finding: [high] Personal data (email) written to committed file.
This violates the PII-in-source rule. Squad config files are committed
to the repo and shared across contributors.
Fix: Read email at runtime only, never persist to committed files.

Example 4: Medium — Overly broad workflow permissions

PR adds workflow with no permissions block (inherits default write-all):
  on: push
  jobs:
    deploy:
      runs-on: ubuntu-latest

Finding: [medium] No explicit permissions block. Workflow inherits
default permissions which may be overly broad.
Fix: Add 'permissions:' block with minimum required scopes.

Example 5: Medium — New dependency when built-in exists

PR adds to package.json:
  "dependencies": { "mkdirp": "^3.0.0" }

Finding: [medium] mkdirp is unnecessary — Node.js built-in
fs.mkdirSync(path, { recursive: true }) provides the same functionality.
Fix: Use node:fs built-in instead of adding a new dependency.

Example 6: Low — Missing environment variable validation

PR uses process.env.SQUAD_API_KEY without checking if it's defined:
  const apiKey = process.env.SQUAD_API_KEY;
  fetch(url, { headers: { Authorization: `Bearer ${apiKey}` } });

Finding: [low] No validation that SQUAD_API_KEY is defined.
If undefined, the Bearer token will be "Bearer undefined" which
may produce confusing auth errors.
Fix: Check for undefined and throw a descriptive error early.

Review Output Format

Structure your security review with severity levels:

## Security Review

**Verdict:** APPROVE | APPROVE WITH NOTES | REQUEST CHANGES | REJECT

### Findings

1. [severity: critical] — description
   - File(s): path/to/file.ts:L42
   - Risk: what could go wrong
   - Fix: specific remediation

2. [severity: high] — ...

3. [severity: medium] — ...

4. [severity: low] — ...

### Severity Guide
- **Critical:** Exploitable vulnerability, credential exposure, or code execution risk. Must fix before merge.
- **High:** Security design flaw that could lead to exploitation. Must fix before merge.
- **Medium:** Security best practice violation. Should fix before merge.
- **Low:** Minor hardening opportunity. Can fix in a follow-up PR.

### Summary
Brief overview of security posture and required actions.

Anti-Patterns

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.