High severityGoHardcoded SecretsHIGH confidence
Hardcoded Crypto Key
A symmetric cipher or HMAC is keyed with a hardcoded literal key (CWE-798/CWE-321).
Standards mapping
- OWASP Top 10
- A02:2021 - Cryptographic Failures
- OWASP ASVS
- V6.4.1 (L2)
Vulnerable vs. safe
Flagged by this check
_, _ = aes.NewCipher([]byte("0123456789abcdef"))Passes - the safe pattern
_, _ = aes.NewCipher(keyFromEnv)Why it matters & how to fix it
A symmetric cipher or HMAC is keyed with a hardcoded literal key (CWE-798/CWE-321). A key baked into source can be extracted from the binary and cannot be rotated, defeating the encryption/authentication. Derive the key from a secret loaded at runtime (env var / KMS / secrets manager) and, for password-derived keys, use a KDF (argon2/scrypt/PBKDF2) with a random salt.
References
Rule ID integsec-go-hardcoded-crypto-key - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- JavaScript / TypeScript - Hardcoded SecretsBasic Auth Credentials In URL
- JavaScript / TypeScript - Hardcoded SecretsDB Connection String With Credentials
- JavaScript / TypeScript - Hardcoded SecretsHardcoded Credential String
- JavaScript / TypeScript - Hardcoded SecretsHardcoded Crypto Key Or IV
- Python - Hardcoded SecretsBasic Auth Credentials In URL
- Python - Hardcoded SecretsDB Connection String Credentials