High severityC#Authentication & SecretsMEDIUM confidence
Hardcoded Credentials
A credential (password, API key, secret, or private key) is assigned to a string literal (CWE-798).
Standards mapping
- OWASP ASVS
- V6.4.1 (L2)V2.10.4 (L2)
Vulnerable vs. safe
Flagged by this check
var apiKey = "AKIAIOSFODNN7EXAMPLE_realish_value";Passes - the safe pattern
var apiKey = Environment.GetEnvironmentVariable("API_KEY");Why it matters & how to fix it
A credential (password, API key, secret, or private key) is assigned to a string literal (CWE-798). Hard-coded secrets leak through source control and binaries and cannot be rotated without a code change. Load them at runtime from configuration/environment or a secrets manager (Azure Key Vault, AWS Secrets Manager), and rotate any value that was committed.
References
Rule ID integsec.csharp.auth.hardcoded-credentials - 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 - Authentication & SecretsHardcoded JWT Secret
- JavaScript / TypeScript - Authentication & SecretsHardcoded Secret
- JavaScript / TypeScript - Authentication & SecretsInsecure Cookie Flags
- JavaScript / TypeScript - Authentication & SecretsJWT Algorithm None
- JavaScript / TypeScript - Authentication & SecretsJWT Decode Without Verify
- JavaScript / TypeScript - Authentication & SecretsTLS Verification Disabled