Cybersecurity

AI Coding Agent Security Checklist: Claude Code, Cursor and Beyond

Python Docker Prompt Injection MCP AI Agents Cybersecurity Network Security Git GitHub AWS Databases Rust Credentials Hashing HTTPS
1,868 words Includes Code

AI Coding Agent Security Checklist: Claude Code, Cursor and Beyond

🔑 Key Takeaway

AI coding agents require careful security configuration. Whether you use terminal agents like Claude Code or AI IDEs like Cursor, both have access to your filesystem, shell, Git, and potentially your secrets. This checklist covers 8 critical security areas every developer should address.

⚠️ No Tool Is Automatically Secure

Both terminal agents and AI IDEs can execute code, modify files, and access your system. Security depends on your configuration, not just the tool itself.

AI Coding Agent Security Checklist comparing terminal agents and AI IDEs

Security Comparison Matrix

Security comparison matrix for terminal agents vs AI IDEs

Both terminal agents and AI IDEs share common security concerns, but the attack surface differs:

Feature Terminal Agents AI IDEs
Filesystem Access Direct, unrestricted by default Via editor, often restricted to workspace
Shell Access Full shell, direct command execution Integrated terminal, similar capability
Git Operations Direct CLI, can commit/push Built-in Git UI, visual review
Network Access Unrestricted (curl, pip, etc.) Via extensions, potentially restricted
Secrets Exposure Environment variables accessible Config files, settings accessible
Sandboxing None by default Limited, extension-dependent

Area 1: Filesystem Security

📁 Filesystem Controls

✓
Restrict to project directory
Agents should only access the current project, not your entire home directory
✓
Block sensitive directories
Prevent access to ~/.ssh, ~/.aws, ~/.env, credential stores
✓
Read-only where possible
Grant write access only when explicitly needed
✓
Audit file changes
Review all file modifications before committing
# Example: Restricting filesystem access
# For terminal agents, use a dedicated workspace

$ mkdir ~/secure-workspace
$ cd ~/secure-workspace
$ git clone https://github.com/your/project.git

# Set restrictive permissions
$ chmod 700 ~/.ssh  # Protect SSH keys
$ chmod 600 ~/.env  # Protect environment files

# For Claude Code, use project-scoped configuration
# .claude/settings.json:
{
    "allowedDirectories": ["./"],
    "blockedPaths": [
        "~/.ssh",
        "~/.aws",
        "~/.env*"
    ]
}

Area 2: Shell Access Security

🖥️ Shell Controls

✓
Require confirmation for shell commands
Never allow automatic execution of destructive commands
✓
Block high-risk commands
Prevent rm -rf, sudo, curl to unknown endpoints
✓
Use sandboxed environments
Run in Docker containers with limited capabilities
✓
Log all commands
Maintain audit trail of executed commands
Command Type Risk Level Recommendation
Read-only (ls, cat, git status) 🟢 Low Allow with logging
Build (npm install, pip install) 🟡 Medium Confirm before execution
Network (curl, wget) 🟡 Medium Allowlist endpoints
Write (rm, mv, mkdir) 🔴 High Require confirmation
Privileged (sudo, chmod 777) 🔴 High Block or require approval

Area 3: Git Security

📂 Git Controls

✓
Review all diffs before commit
Never let an agent auto-commit without review
✓
Protect main/master branch
Require PR reviews for production branches
✓
Verify commit authorship
Ensure agent commits are clearly labeled
✓
Block force push
Never allow agent to force push to shared branches
# Example: Safe Git workflow with AI agent

# 1. Agent creates changes
$ git diff  # Review what changed

# 2. You review the diff
$ git diff --stat  # See affected files
$ git diff src/  # Review actual changes

# 3. You approve and commit
$ git add -A
$ git commit -m "Fix: Resolve auth bug (agent-assisted)"

# 4. Never auto-push
$ git push  # Only after you review

# Protection rules:
# - Branch protection on main/master
# - Required PR reviews
# - Status checks before merge

Area 4: Network Security

🌐 Network Controls

✓
Allowlist domains
Only allow connections to known, trusted endpoints
✓
Block outbound data exfiltration
Monitor for unexpected network requests
✓
Use private registries
Control which package sources are accessible
✓
Log all network requests
Record connections for audit

Area 5: Secrets Management

🔐 Secrets Controls

✓
Use secret managers
Never hardcode credentials in agent context
✓
Scope environment variables
Only expose necessary secrets to the agent
✓
Prevent secret logging
Filter sensitive data from agent output
✓
Rotate credentials regularly
Don't let agents have long-lived access
# Example: Secure secrets configuration
# BAD: Exposing all environment variables
$ export $(cat .env)  # Agent gets everything

# BETTER: Scoped secrets
$ export API_KEY="limited-scope-key"
$ export DATABASE_URL=""  # Don't expose DB credentials

# BEST: Use secret manager with scoped access
$ vault read -field=key secret/agent/api-key

# For Claude Code, use project-level .env
# with only necessary secrets

Area 6: Permissions Management

🔑 Permissions Controls

✓
Apply least privilege
Grant minimum necessary permissions
✓
Use separate accounts
Don't run agents as admin/root
✓
Limit tool access
Only enable tools the agent actually needs
✓
Review permissions regularly
Audit what the agent can access

Area 7: Sandboxing

🔒 Sandboxing Controls

✓
Use containers for development
Docker containers provide process isolation
✓
Restrict container capabilities
--network none, --read-only, --memory limits
✓
Use dev containers
VS Code Dev Containers for isolated environments
✓
Monitor resource usage
Detect unusual CPU/memory/network patterns
# Example: Sandboxed agent environment
# Docker container with restricted capabilities

$ docker run --rm -it \
    --name agent-sandbox \
    --network none \  # No network access
    --read-only \  # Read-only filesystem
    --memory 512m \  # Memory limit
    --cpus 1.0 \  # CPU limit
    --user 1000:1000 \  # Non-root user
    -v $(pwd):/workspace:ro \  # Read-only mount
    python:3.12-slim

# Agent runs in sandbox with minimal access

Area 8: Human Approval

👤 Human Approval Controls

✓
Require approval for high-risk actions
Never let agents auto-execute destructive commands
✓
Review all code changes
Inspect diffs before committing
✓
Validate test results
Don't trust agent-reported test outcomes
✓
Maintain override capability
Always be able to stop or revert agent actions
Action Risk Approval Required
Read files Low Optional (logging recommended)
Edit source code Medium Review diff before commit
Install packages Medium Confirm package names and versions
Run tests Low Review test results
Git commit Medium Review message and changes
Git push High Always require approval
Deploy Critical Always require approval

Complete Security Checklist

✅ 25-Point AI Coding Agent Security Checklist

✓
Filesystem: Restrict to project directory
✓
Filesystem: Block sensitive directories
✓
Shell: Require confirmation for commands
✓
Shell: Block destructive commands
✓
Shell: Log all executed commands
✓
Git: Review all diffs before commit
✓
Git: Protect main/master branch
✓
Git: Block force push by agent
✓
Network: Allowlist domains
✓
Network: Monitor outbound requests
✓
Secrets: Use secret managers
✓
Secrets: Scope environment variables
✓
Secrets: Prevent secret logging
✓
Permissions: Apply least privilege
✓
Permissions: Use non-root user
✓
Permissions: Limit tool access
✓
Sandbox: Use containers for development
✓
Sandbox: Restrict container capabilities
✓
Sandbox: Set resource limits
✓
Human: Require approval for high-risk actions
✓
Human: Review all code changes
✓
Human: Validate test results
✓
Human: Maintain override capability
✓
Audit: Log all agent interactions
✓
Audit: Monitor for anomalies

Related BestWordz Resources

Conclusion

AI coding agents are powerful tools that require careful security configuration. Neither terminal agents nor AI IDEs are automatically secure.

Key principles:

  • Apply least privilege to all agent capabilities
  • Require human approval for high-risk actions
  • Use sandboxing for untrusted or experimental work
  • Log and monitor all agent interactions
  • Review all changes before committing

Security is a configuration choice, not a tool feature. Take the time to configure your AI coding agent securely.

Continue Learning: AI Security

Secure your AI applications and data

  1. The 8-Stage Cybersecurity Roadmap
  2. Why MCP Security Matters
  3. The 15 AI Security Domains
  4. What Is Prompt Engineering?
  5. AI Coding Agent Security Checklist: Claude Code, Cursor and Beyond (this article)

💬 Discuss on BestWordz Community

Join the conversation about Python, Docker, Prompt Injection on the BestWordz Community forum.

Visit Forum →