CAS-005 · Question #318
An enterprise is deploying APIs that utilize a private key and a public key to ensure the connection string is protected. To connect to the API, customers must use the private key. Which of the follow
The correct answer is D. Utilize HMAC for the keys. To securely connect a REST API to a database without hard-coding connection strings, using HMAC (Hash-based Message Authentication Code) for keys provides message integrity and authenticity for API requests.
Question
An enterprise is deploying APIs that utilize a private key and a public key to ensure the connection string is protected. To connect to the API, customers must use the private key. Which of the following would best secure the REST API connection to the database while preventing the use of a hard-coded string in the request string?
Options
- AImplement a VPN for all APIs
- BSign the key with DSA
- CDeploy MFA for the service accounts
- DUtilize HMAC for the keys
How the community answered
(30 responses)- A13% (4)
- B7% (2)
- C3% (1)
- D77% (23)
Why each option
To securely connect a REST API to a database without hard-coding connection strings, using HMAC (Hash-based Message Authentication Code) for keys provides message integrity and authenticity for API requests.
Implementing a VPN for all APIs provides secure communication channels, but it doesn't directly address the method of authenticating API requests or preventing hard-coded strings within the application layer for database access.
Signing a key with DSA (Digital Signature Algorithm) provides authenticity and non-repudiation for the key itself, but HMAC is more commonly used for authenticating messages or requests in an API context to protect against tampering and unauthorized use.
Deploying MFA (Multi-Factor Authentication) is for human user accounts, not typically for service accounts connecting an API to a database; API key management and message authentication are the relevant controls here.
HMAC (Hash-based Message Authentication Code) uses a cryptographic hash function and a secret key to generate a message authentication code. When used with API keys, it ensures the integrity and authenticity of the API requests, preventing tampering and unauthorized access without exposing the raw private key in transit, thus securing the connection to the database and avoiding hard-coded strings.
Concept tested: API security, secure key management, message authentication
Source: https://owasp.org/www-project-api-security/
Community Discussion
No community discussion yet for this question.