Back to skill

Security audit

Phy Large Codebase Workflow

Security checks for vulnerabilities and agentic risk

Overview

This is a documentation-only Claude Code workflow guide, with some powerful but disclosed examples users should run deliberately.

Install only if you intentionally want Claude Code large-repository workflow advice. Treat the batch-edit, commit, PR, CI, and resume examples as actions requiring deliberate approval, especially for private repositories or code that should not be sent to an external Claude account.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (8)

External Model or Provider Selection

High
Category
Excessive Agency
Content
### Auto-Generate Codemap (One-Time)

```bash
claude -p "Analyze this codebase and create a comprehensive codemap.
Output to .claude/codemaps/architecture.md. Include:
- Entry points
- Module responsibilities
Confidence
90% confidence
Finding
Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.

External Model or Provider Selection

High
Category
Excessive Agency
Content
```bash
# After major refactors, regenerate
claude -p "Update .claude/codemaps/architecture.md based on current codebase structure"
```

---
Confidence
90% confidence
Finding
Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.

External Model or Provider Selection

High
Category
Excessive Agency
Content
```bash
# Batch migrate files
for file in $(cat files.txt); do
  claude -p "Migrate $file from React to Vue. Return OK or FAIL." \
    --allowedTools "Edit,Bash(git commit:*)"
done
Confidence
90% confidence
Finding
Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.

External Model or Provider Selection

High
Category
Excessive Agency
Content
done

# CI integration
claude -p "Analyze this PR for security issues" --output-format json
```

---
Confidence
90% confidence
Finding
Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.

External Model or Provider Selection

High
Category
Excessive Agency
Content
git worktree + multiple claude sessions

# Generate/update codemap
claude -p "Create codemap for this project → .claude/codemaps/"
```

## Context Budget Rule of Thumb
Confidence
90% confidence
Finding
Skill selects an external model or provider that may use a different account or billing plan than the operator expects. Undisclosed model switches can cause unexpected cost or quota consumption.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The skill explicitly instructs the agent to 'commit with descriptive message and open a PR' without requiring an explicit user confirmation step or warning that this will modify repository state and potentially publish changes remotely. In an automation-oriented workflow skill, normalizing autonomous commits/PRs increases the chance of unintended code publication or persistence of unsafe changes.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The batch automation example permits Edit plus Bash access scoped to 'git commit:*' inside a loop, enabling repeated repository-modifying actions across many files with no confirmation or review checkpoint. In batch mode, mistakes scale quickly and can create many unwanted commits or mass changes that are hard to audit or revert.

Session Persistence

Medium
Category
Rogue Agent
Content
/compact "Focus on API changes"  # At 70%
/clear                           # Between tasks

# Resume previous session (preserve context)
claude --continue                # Resume last session
claude --resume                  # Pick from history
Confidence
55% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Static analysis

No suspicious patterns detected.