Skip to content

AAK-SECRET-002: OpenAI API key exposed

Severity
CRITICAL
Category
Secret Exposure (secret-exposure)
Scanner
agent_audit_kit/scanners/secret_exposure.py
Auto-fixable
No.
SARIF name
OpenaiApiKeyExposed

What it detects

An OpenAI API key was found in a project file: a legacy user key (sk-*), or a project (sk-proj-*), service-account (sk-svcacct-*) or admin (sk-admin-*) key.

How to fix

Remove key, rotate immediately, use environment variables.

To confirm the finding is gone, report only this rule:

agent-audit-kit scan . --rules AAK-SECRET-002

Limitations

Looks for the sk- shapes OpenAI issues: legacy user keys and the sk-proj-, sk-svcacct- and sk-admin- families. A key with no such prefix is not recognised, so an Azure OpenAI key, which is 32 hexadecimal characters, is not reported, although an sk-proj- key in the same place is. In Markdown, a key shaped like a documentation stand-in (one repeated character after the prefix, a run of x, or REPLACE, YOUR, EXAMPLE, PLACEHOLDER or CHANGEME in it) is skipped. A file over 1,000,000 bytes is not read.

References


All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-SECRET-002.md: the page then shows that text, with the registry reference appended under it.