Secret written to a log
Secret written to a log. Logs something that looks secret (console.log("token", token). Logs are read by more people and tools than the database.
This is how the comment reads inline, under the flagged line.
Why it matters
Credentials in logs end up in log search, vendor dashboards and support tickets, with weaker access control than the secret store.
What to do
Log an id or a fingerprint, never the value.
Examples
logger.info("auth", { token });logger.info("auth", { userId });What it catches
It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript, Python. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
console.log("token", token);src/app.py
logging.info('password=%s', pw)
Left alone
console.log(user.id);
console.log(tokenCount);
Research
Passwords, tokens or keys written to logs. Logs and error trackers keep the secret and share it widely.
- skill: code-review
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"secret-in-log"
],
"severity": {
"secret-in-log": "low"
}
}
}