← Java / Spring · Contents

JAVA-055 / Beginner

Plaintext secrets in configuration files (application.yml)

A07:2021 · CWE-798 Hard-coded Credentials · CWE-256

Why is this a problem?

Once committed, the entire repository history exposes them.

How to fix it

yaml
spring.datasource.password: ${DB_PASSWORD}   # Inject through an environment variable or Vault

Further reading