High severityC#Hardcoded SecretsHIGH confidence
Hardcoded Key To Crypto Call
A cryptographic key or salt passed to an HMAC/KDF/cipher call is a hard-coded literal (CWE-321).
Standards mapping
- OWASP Top 10
- A02:2021 - Cryptographic Failures
- OWASP ASVS
- V6.4.1 (L2)
Vulnerable vs. safe
Flagged by this check
var hmac = new HMACSHA256(Encoding.UTF8.GetBytes("hardcoded-hmac-key-000001"));Passes - the safe pattern
var hmac = new HMACSHA256(key);Why it matters & how to fix it
A cryptographic key or salt passed to an HMAC/KDF/cipher call is a hard-coded literal (CWE-321). Embedded key material can be extracted from source or binaries, defeating the construction. Load keys from a secrets manager/KMS, derive per-purpose keys with a KDF, and use a fresh random salt per credential.
References
Rule ID integsec.csharp.secrets.hardcoded-key-to-crypto-call - 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