AG-007: Hardcoded Secret / Credential
What this rule means
A secret (API key, token, private key, credential) was found hardcoded in agent source code. Detection uses exact-format regexes for known providers (OpenAI, Anthropic, AWS, GitHub, etc.) and a Shannon entropy fallback for unknown formats in secret-named variables (entropy > 4.5 bits/char, len ≥ 16).
Why it matters
Hardcoded secrets are the most common cause of credential leaks. Every git commit that contains the secret is a permanent record — even after deletion, the history remains. The Galaxy incident (July 2026) involved an agent with unrestricted API access; hardcoded credentials would have made it worse.
How to fix it
Move the secret to an environment variable:
api_key = os.environ['OPENAI_API_KEY'] # not hardcoded
Or use a secrets manager (AWS Secrets Manager, HashiCorp Vault, etc.).
Rotate the secret immediately if it was ever committed to git.
Detect it
pip install lucin
lucin scan . # all rules
lucin explain AG-007 # this rule, in your terminal
Findings carry a file:line and, where the rule supports it, a witness
path showing the flow that triggered it. Precision and recall for the whole rule set,
with the commands that regenerate them, are on the
benchmarks page — and the gaps are on
limits.