Rules › Any language

Private key or keypair in the source

highAny languageRule any-private-key

A hex private key or a Solana keypair array is committed in the code; anyone with the repo controls that account.

Why it matters

A private key or Solana keypair committed to a repository is compromised: it's in the history forever, in every clone and fork, and bots scan public repositories for keys within minutes. Load keys from a hardware wallet, an encrypted keystore (cast wallet import), or an environment variable that isn't committed, and rotate any key that was ever committed.

Vulnerable

const PRIVATE_KEY = "0x4c0883a6...";
const wallet = new Wallet(PRIVATE_KEY, provider);

Fixed

// forge script ... --account deployer  (an encrypted keystore)
const wallet = new Wallet(process.env.DEPLOYER_KEY!, provider); // .env is git-ignored

Check your code

Paste a contract into the in-browser checker, or let the Claude Code plugin scan before every deploy. The quick check for this rule is a pattern match: treat a hit as "look here", and a miss as no guarantee.

Static analysis finds known bug classes; it can't prove code is safe and isn't an audit. Get a professional audit before deploying code that will hold value.