← Java / Spring · Contents

JAVA-045 / Beginner

Hardcoded passwords or keys

A07:2021 Identification and Authentication Failures · CWE-798 Hard-coded Credentials

Why is this a problem?

Anyone with repository access obtains production credentials.

How to fix it

java
@Value("${app.db.password}") private String password;   // Environment variable or Vault

Further reading