| 1 |
## Output |
| 2 |
|
| 3 |
```text |
| 4 |
Potentially sensitive data should not be used in the ARG or ENV commands |
| 5 |
``` |
| 6 |
|
| 7 |
## Description |
| 8 |
|
| 9 |
While it is common to pass secrets to running processes |
| 10 |
through environment variables during local development, |
| 11 |
setting secrets in a Dockerfile using `ENV` or `ARG` |
| 12 |
is insecure because they persist in the final image. |
| 13 |
This rule reports violations where `ENV` and `ARG` keys |
| 14 |
indicate that they contain sensitive data. |
| 15 |
|
| 16 |
Instead of `ARG` or `ENV`, you should use secret mounts, |
| 17 |
which expose secrets to your builds in a secure manner, |
| 18 |
and do not persist in the final image or its metadata. |
| 19 |
See [Build secrets](https://docs.docker.com/build/building/secrets/). |
| 20 |
|
| 21 |
## Examples |
| 22 |
|
| 23 |
❌ Bad: `AWS_SECRET_ACCESS_KEY` is a secret value. |
| 24 |
|
| 25 |
```dockerfile |
| 26 |
FROM scratch |
| 27 |
ARG AWS_SECRET_ACCESS_KEY |
| 28 |
``` |