Skip to content
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

FS config scan MISCONF DS018 ("the alias is not defined in previous stages") is not valid when using COPY --from=external-image #1621

Closed
daliborfilus opened this issue Jan 25, 2022 · 2 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@daliborfilus
Copy link

Description

The validation for https://avd.aquasec.com/appshield/ds018/ is invalid, since having a reference to external image is valid and supported, see https://docs.docker.com/develop/develop-images/multistage-build/#use-an-external-image-as-a-stage

Trivy could check if the COPY --from= argument refers to an existing image and skip this check,
OR it could decrease the severity from HIGH to MEDIUM (or even lower),
OR it could just stop checking for this, if it's not possible to differentiate between references to regular images and build stages.

Buildah also supports references to external images "as stages" via this syntax.

What did you expect to happen?

I don't expect this Dockerfile to raise DS018:

FROM ubuntu:20.04
ENV JAVA_HOME=/opt/java/openjdk
COPY --from=eclipse-temurin:17-jdk-focal $JAVA_HOME $JAVA_HOME

but it does.

What happened instead?

Got the error DS018.

Output of run with -debug:

Dockerfile (dockerfile)
=======================
Tests: 17 (SUCCESSES: 15, FAILURES: 2, EXCEPTIONS: 0)
Failures: 2 (HIGH: 2, CRITICAL: 0)
+---------------------------+------------+------------------------------------------+----------+------------------------------------------+
|           TYPE            | MISCONF ID |                  CHECK                   | SEVERITY |                 MESSAGE                  |
+---------------------------+------------+------------------------------------------+----------+------------------------------------------+
| Dockerfile Security Check |   DS002    | root user                                |   HIGH   | Last USER command in                     |
|                           |            |                                          |          | Dockerfile should not be 'root'          |
|                           |            |                                          |          | -->avd.aquasec.com/appshield/ds002       |
+                           +------------+------------------------------------------+          +------------------------------------------+
|                           |   DS018    | 'COPY --from' refers to alias not        |          | The alias                                |
|                           |            | defined previously                       |          | '--from=eclipse-temurin:17-jdk-focal'    |
|                           |            |                                          |          | is not defined in the previous stages    |
|                           |            |                                          |          | -->avd.aquasec.com/appshield/ds018       |
+---------------------------+------------+------------------------------------------+----------+------------------------------------------+

Output of trivy -v:

Version: 0.22.0

Additional details (base image name, container registry info...):

The output is from trivy docker image docker.io/aquasec/trivy:latest (sha256:c6f6e688)

@daliborfilus daliborfilus added the kind/bug Categorizes issue or PR as related to a bug. label Jan 25, 2022
@daliborfilus daliborfilus changed the title Docker DS018 () is invalid Docker DS018 ("the alias xyz is not defined in previous stages") is not valid when using COPY --from=some-external-image Jan 25, 2022
@daliborfilus daliborfilus changed the title Docker DS018 ("the alias xyz is not defined in previous stages") is not valid when using COPY --from=some-external-image FS config scan MISCONF DS018 ("the alias is not defined in previous stages") is not valid when using COPY --from=external-image Jan 25, 2022
@knqyf263
Copy link
Collaborator

Thanks for raising an issue! Could you raise the issue in AppShield repository?

For suggestions or issues regarding policy content, please open an issue under AppShield, tfsec or cfsec repository.

https://aquasecurity.github.io/trivy/v0.22.0/misconfiguration/policy/builtin/

@daliborfilus
Copy link
Author

No problem, created as aquasecurity/appshield#146.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

2 participants