IH-CRED-006highCredentials

Hard-coded environment fallback

A credential used as the default of an environment-variable lookup is shipped in the package. os.getenv, os.environ.get, getenv(...) or, process.env || or ??, and ${VAR:-...} count, including when the call is split across lines. A known key prefix of length at least 16 is enough in a code file. Other literals need Shannon entropy of at least 3.5, length at least 20, and a secret-like variable name. A 42-character 0x address is not a secret. Markdown is not scanned, so transaction hashes there are ignored. An env var falling back to another env var is not this rule.

What does IH-CRED-006 flag?

Flags a real-looking credential used as the default when an environment variable is missing, which means the key ships inside the skill.

  • os.getenv, os.environ.get, getenv(...) or, process.env || or ??, and ${VAR:-...} with a literal default, including calls split across lines.
  • A known key prefix (AIza, sk-, ghp_, AKIA and others) of length 16 or more, or a random-looking literal with a secret-like variable name.

Why it matters

The author meant to read the key from the environment, but the fallback puts a working key in every copy of the skill. Anyone who downloads it can use or abuse that account.

Examples

Illustrative shapes with placeholders in angle brackets. They show what the rule looks at; they are not runnable and not taken from real malware.

Python fallback key
Flagged
os.getenv("GOOGLE_API_KEY", "AIza<fake key>")
Shell default
Flagged
${OPENAI_API_KEY:-sk-<fake key>}
Placeholder default
Not flagged
os.getenv("API_KEY", "your-api-key-here")

Can IH-CRED-006 fire on a safe skill?

  • A long test value with a secret-like name that is not a real key.

How do I fix an IH-CRED-006 finding?

  • Remove the fallback secret and rotate it.
  • Read the environment variable with no default and fail clearly when it is missing.

CLI guidance: Remove the fallback secret, rotate it, and read the environment variable with no default.

How do I tune or allow IH-CRED-006?

For a known fake value in a fixture, exclude that file with ignoreGlobs rather than turning the rule off.

{
  "ignoreGlobs": [
    "docs/known-example.md"
  ]
}

Every key is described in Configuration. To print this rule from the CLI, run ironheights rules show IH-CRED-006.

What can IH-CRED-006 miss?

  • Markdown, which this rule does not scan.
  • Defaults loaded from a separate config file.

No finding means no rule matched. It is not proof of safety. Files larger than 1 MiB are skipped without being read; the verdict is then incomplete, not no findings, but the file is still not checked. See Limitations.

Scores and thresholds shown are the CLI defaults; your config can change them. List every rule from the terminal with ironheights rules list.

All 44 rules