Skip to main content

☑️ Prevent exposed Vault secrets in objects

Kubernetes objects may need to use secret data in their configs such as passwords/tokens/etc. Providing such sensitive data in plain-text is risky and highly unrecommended, as it can be stolen and used maliciously.
Different tools have different secrets, each with its own convention and format.

The gitleaks project aggregates such tools and stays up-to-date with their secret data format.

Targeted objects by this rule (types of kind): All

Enabled by default? True

Policy as code identifier: ALL_EXPOSED_SECRET_VAULT


This rule will fail

If a Vault batch token and/or service token are present anywhere in the config:

BATCH_TOKEN: hvb.pehm8c_dqgtzfp9nlgj55the9epkubbyyvr3hcqksrytd5sxpdspxgkedgapgcykmx1ao-5f2hshknklvpuf49cuoovi_v61ssbto_ztwd8ps1dbmkeb_-f5vd_tln5gu8k0cczqeb06neqf0m-u7qrk
SERVIVE_TOKEN: hvs.aiky6mstgd0g9r-epdtfcghy32mzi6cm83z02emx80-1-m5bntqc9xf3e9qjcaw24vd1how4ptt0lssm7e637nox8skbz

Rule output in the CLI

$ datree test *.yaml

>> File: failExample.yaml
❌ Prevent exposed Vault secrets in objects [1 occurrence]
💡 Secret data found in config - keep your sensitive data elsewhere to prevent it from being stolen

How to fix this failure

Do not put sensitive data in any config. Kubernetes offers the handy Secret object to handle this.
If you do not wish to use Secrets, take a look at these available alternatives.


Read more