critical severitysecurity

    API Keys & Personal Paths Leaked in .cursorrules or CLAUDE.md — Remediation Checklist

    Critical Leak (S6 / S7): Hardcoded token pattern or personal /Users/<name> path detected inside committed agent rules.

    Direct-Answer Fix Summary

    Never paste real API keys, bearer tokens, staging DB URLs, or personal /Users/<name> home paths into CLAUDE.md, AGENTS.md, or .cursorrules. Once pushed, rotate the exposed credential immediately, scrub it from Git history, replace it with an environment variable name (process.env.STRIPE_API_KEY), add .env and CLAUDE.local.md to .gitignore (S1 / C5), and enable CI secret scanning (S3).

    Broken vs. Fixed Configuration

    Leaked: Live token & personal macOS path in CLAUDE.md
    # Local Debugging
    Test API with:
    curl -H "Authorization: Bearer <TOKEN>" https://api.acme.dev/v1
    Local fixtures live at /Users/<dev>/work/secrets/fixtures.json
    Safe: Environment variable reference + repo-relative fixture path
    # Local Debugging
    Load credentials from .env (gitignored; see .env.example).
    Test API with:
    curl -H "Authorization: Bearer $ACME_API_TOKEN" "$ACME_API_URL/v1"
    Fixtures live at tests/fixtures/sample.json

    Why This Happens

    Developers paste working curl commands or local debug snippets into CLAUDE.md so the AI can reproduce bugs — forgetting that CLAUDE.md is committed to public or company-wide Git history.

    Step-by-Step Fix

    1. 01
      Rotate the leaked credential first

      Assume any token committed to Git (even briefly) is compromised — revoke and issue a fresh secret immediately.

    2. 02
      Replace inline values with env-var references

      Document only variable names (e.g. set STRIPE_SECRET_KEY in .env) and verify .env + CLAUDE.local.md are in .gitignore.

    3. 03
      Remove personal home paths (/Users/...)

      Use repo-relative paths or $HOME so rules work identically for teammates and CI runners.

    4. 04
      Gate PRs with AgentLint S1, S3, S6 & S7

      Run agentlint check in pre-commit and GitHub Actions so leaked tokens or personal paths never reach main.

    Automated AgentLint Checks That Catch This

    Frequently Asked Questions

    Where should I put machine-specific overrides or personal Claude notes?

    Put personal, machine-specific instructions inside CLAUDE.local.md and ensure CLAUDE.local.md is listed in .gitignore (AgentLint rule C5).

    Does AgentLint's online scanner send my pasted text to a server?

    No. Secret and path detection runs 100% locally in your browser with zero upload.

    Related Troubleshooting Guides