Remediating Hard-Coded Credentials Found by SAST
Short answer
D Integrate secrets management so hard-coded credentials are replaced by vault-stored secrets injected at runtime, enabling rotation and revocation.
Question
Key Takeaways
Remediating a SAST finding for hard-coded credentials means moving the secret out of source code, and integrating secrets management is the correct fix because it stores the value in a vault and injects it at runtime, enabling rotation and revocation. PAM addresses privileged human access, SSO addresses interactive user logins, and obfuscation fails because the application must be able to reverse it, so an attacker can too.
Expert Analysis
Hard-coded passwords, API keys, and tokens leak to anyone with the repository, build artifact, or backup; a secrets-management platform stores them in a vault and injects them at runtime, enabling rotation and revocation.
The deciding mechanism here is where the credential lives at runtime. A SAST finding for hard-coded credentials means the secret is committed in source, so it travels with every clone of the repository, every build artifact, and every backup derived from it. The remediation must therefore move the secret out of the code and into a vault that injects it when the application runs, which is exactly what option D, integrate secrets management, prescribes. Once the value sits in a vault, the team gains the two properties the hard-coded form cannot offer: rotation without a code change, and revocation the moment the value is suspected of exposure.
Option A, implement a privileged access management solution, addresses a different population. PAM governs who may hold and use privileged human or service accounts, typically through session recording, just-in-time elevation and credential checkout for administrators. It does not change the fact that a password or API key is embedded in the application source, so the SAST finding would persist unchanged after a PAM deployment.
Option B, enable single sign-on, also fails to touch the finding. SSO consolidates interactive user authentication through an identity provider, removing repeated password prompts for people. It does nothing for machine-to-machine credentials baked into application code; the hard-coded value remains readable in the repository and in build artifacts.
Option C, obfuscate application programming interface keys, is the trap. Any application that must legitimately use a key has to be able to recover the original value at runtime, so an attacker holding the same binary or source can run the same reversal. Obfuscation raises effort slightly but provides no confidentiality, and a SAST scanner typically still flags the pattern. That is why the explanation dismisses it on reversibility grounds rather than on style.
One mechanism this scenario relies on but does not spell out: SAST tools flag hard-coded secrets by pattern-matching credential-shaped literals and assignment statements, and those scanners commonly ignore line length or file exclusion rules that a developer might use to hide a value. The analyst's recommendation must survive a re-scan, and only removing the literal from the source does — a vault reference such as an environment variable or a runtime injection call leaves nothing for the pattern matcher to catch, whereas PAM, SSO and obfuscation all leave the literal in place. The concrete win for the application team is that rotation becomes an operational action in the vault rather than a pull request plus rebuild.
Official Reference
https://owasp.org/www-community/vulnerabilities/Use_of_hard-coded_password
This link opens the official vendor documentation in a new tab.
Exam Strategy
When a scan finding names an embedded secret, look for the option that changes where the credential lives at runtime, not how people authenticate to systems. Eliminate answers that govern humans (PAM, SSO) or merely disguise the value (obfuscation), since the scanner re-flag or reversible logic defeats them. On CS0-004, treat "rotate and revoke without a code change" as the signature of the intended secrets-management remedy.
Related Analysis
Practice All CS0-004 Questions
Access 101 questions with complete answers and detailed explanations.
View Full CS0-004 Practice Test →