Sensitive information in source code - API Key
Description
The encryption key is stored in the source code in plain text and is not obtained from a secure source that guarantees its confidentiality.
Impact
- Generate an elaborate brute-force attack on the applications encrypted messages.
- Open easily information of a company, web and API security to sensitive data exposure.
Recommendation
It is recommended to load encryption keys from:
- A key vault service.
- A configuration file that is properly encrypted.
- Administrative environment variables.
Threat
Unauthorized user obtaining the encryption key directly from the application repository or an application file.
Expected Remediation Time
⌚ 45 minutes.
Score
Default score using CVSS 3.1. It may change depending on the context of the vulnerability.
Base
- Attack vector: N
- Attack complexity: H
- Privileges required: L
- User interaction: N
- Scope: U
- Confidentiality: L
- Integrity: N
- Availability: N
Temporal
- Exploit code madurity: P
- Remediation level: O
- Report confidence: C
Result
- Vector string: CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:N/A:N/E:P/RL:O/RC:C
- Score:
- Base: 3.1
- Temporal: 2.8
- Severity:
- Base: Low
- Temporal: Low
Code Examples
Compliant code
API Keys and sensitive information are stored as encrypted values
//Store API_KEY as a secret encrypted
const key = Buffer.from(keyString.substring(0, 8), "utf8");
function getInformation(userInput){
const info = fetch("url", key);
//Return information
}
Non compliant code
The API jeys are stored in plain text value inside the code
const API_KEY = "KEY_inplaneText";
function getInformation(userInput) {
const info = fetch("url", API_KEY);
//Return information
}
Requirements
- 145. Protect system cryptographic keys
- 156. Source code without sensitive information
- 266. Disable insecure functionalities
Search for vulnerabilities in your apps for free with our automated security testing! Start your 21-day free trial and discover the benefits of our Continuous Hacking Machine Plan. If you prefer a full service that includes the expertise of our ethical hackers, don't hesitate to contact us for our Continuous Hacking Squad Plan.