-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(checks): add secrets leak check in Dockerfile #265
Conversation
10be9ce
to
15b0818
Compare
@simar7 Do we need to create two separate checks for secret checking and password detection? |
# avd_id: AVD-DS-0031 | ||
# severity: CRITICAL | ||
# short_code: do-not-pass-secrets | ||
# recommended_action: Use secret mount if secrets are needed during image build. Use volume mount if secret files are needed during container runtime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# recommended_action: Use secret mount if secrets are needed during image build. Use volume mount if secret files are needed during container runtime. | |
# recommended_action: Use secret mount if secrets are needed during image build. Use volume mount if secured files are needed during container runtime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why “secured”?
rules.Reset() | ||
rego.LoadAndRegister() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only loads Rego checks.
checks/docker/leaked_secrets.rego
Outdated
# TODO: Should arguments be checked? | ||
is_arg_or_env(cmd) if { | ||
check_args | ||
cmd == "arg" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's a case that you are thinking to check the args for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made it enabled by default 9fc294b
Signed-off-by: Nikita Pivkin <[email protected]>
Signed-off-by: Nikita Pivkin <[email protected]>
Signed-off-by: Nikita Pivkin <[email protected]>
Signed-off-by: Nikita Pivkin <[email protected]>
Signed-off-by: Nikita Pivkin <[email protected]>
Signed-off-by: Nikita Pivkin <[email protected]>
Signed-off-by: Nikita Pivkin <[email protected]>
Signed-off-by: Nikita Pivkin <[email protected]>
Signed-off-by: Nikita Pivkin <[email protected]>
Signed-off-by: Nikita Pivkin <[email protected]>
Signed-off-by: Nikita Pivkin <[email protected]>
8708001
to
178c621
Compare
Signed-off-by: Nikita Pivkin <[email protected]>
@simar7 I added the ability to add custom environment variables to easily extend the check. ❯ cat my-envs.yaml
ds031:
included_envs: ["MY_SECRET"]
❯ cat Dockerfile.custom
from alpine
arg MY_SECRET
❯ trivy conf -d Dockerfile.custom --config-data my-envs.yaml
CRITICAL: Possible exposure of secret env "MY_SECRET" in ARG
═══════════════════════════════════════════════════════════════════════════════════════════════════════════
Passing secrets via `build-args` or envs or copying secret files can leak them out
See https://avd.aquasec.com/misconfig/ds031
───────────────────────────────────────────────────────────────────────────────────────────────────────────
Dockerfile.custom:3
───────────────────────────────────────────────────────────────────────────────────────────────────────────
3 [ arg MY_SECRET
─────────────────────────────────────────────────────────────────────────────────────────────────────────── This can also be implemented for secret tokens if there is a need. |
We just got However, the URL it suggests to visit for more information, returns a 404: https://avd.aquasec.com/misconfig/ds031. Is that a separate issue? |
Close aquasecurity/trivy#7639
The check is triggered in the following cases:
Dockerfile:
Output:
Dockerfile:
Output:
Or
Dockerfile:
Output:
This ignores the instructions that the secret mount uses: