IH-CRED-004mediumCredentials

Credential file readable by others

A token, key, or session file written without owner-only permissions (mode 600 / umask 077) is created 644 under the usual umask 022, so other local users and processes can read it. Saving through a temp file and rename resets an earlier chmod 600, and backup archives of ~/.openclaw or credentials made without umask 077 are world-readable.

What does IH-CRED-004 flag?

Flags a skill that writes a token, key or session file without owner-only permissions, so other users and processes on the machine can read it.

  • Opening a token, key or session path for writing without mode 600 or umask 077.
  • Saving through a temp file and rename, which resets an earlier chmod 600.
  • Backup archives of ~/.openclaw or credentials made without umask 077.

Why it matters

With the usual umask 022 a new file is created readable by everyone. On a shared machine, or with any other local process, that is enough to copy the token. Backups of ~/.openclaw made the same way leak every credential at once.

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.

Token cache written with default mode
Flagged
with open(TOKEN_CACHE, "w") as f:
Key echoed into a file
Flagged
echo "$API_KEY" > ~/.config/tool/token
Owner-only write
Not flagged
writeFile(CONFIG_FILE, data, { mode: 0o600 })

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

  • A file named like a token that holds no secret.
  • Code that sets permissions in a helper function the rule does not follow.

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

  • Create the file owner-only: os.open with 0o600, writeFile with { mode: 0o600 }, plus chmod for files that already exist.
  • Use umask 077 in shell scripts and mkstemp before an atomic rename.

CLI guidance: Create the file owner-only: os.open(path, O_CREAT|O_WRONLY, 0o600) or writeFile(path, data, { mode: 0o600 }) plus chmod for existing files, umask 077 in shell scripts, and mkstemp before an atomic rename.

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

If permissions are set elsewhere, exclude that file with ignoreGlobs or lower the rule with ruleOverrides.

{
  "ignoreGlobs": [
    "docs/known-example.md"
  ],
  "ruleOverrides": {
    "IH-CRED-004": {
      "severity": "low"
    }
  }
}

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

What can IH-CRED-004 miss?

  • Permissions changed later by another tool.
  • Windows ACLs, which this rule does not model.

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