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

Scanning ubuntu:22.04 failed #220

Closed
dtfans opened this issue Feb 13, 2023 · 7 comments
Closed

Scanning ubuntu:22.04 failed #220

dtfans opened this issue Feb 13, 2023 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@dtfans
Copy link

dtfans commented Feb 13, 2023

I scanned ubuntu:22.04 and got

FATAL   - CIS-DI-0009: Use COPY instead of ADD in Dockerfile
        * Use COPY : /bin/sh -c #(nop) ADD file:18e71f049606f6339ce7a995839623f50e6ec6474bfd0a3a7ca799db726f47f6 in /

This problem does not occur in ubuntu:jammy-20221130, even though it also has a "ADD file ... in /" layer.

IMAGE          CREATED        CREATED BY                                      SIZE      COMMENT
6b7dfa7e8fdb   2 months ago   /bin/sh -c #(nop)  CMD ["bash"]                 0B
<missing>      2 months ago   /bin/sh -c #(nop) ADD file:481dd2da6de715252…   77.8MB

But there were some new layers added to the latest ubuntu:22.04 image build (a.k.a ubuntu:jammy-20230126),
then we got CIS-DI-0009 from dockle.

IMAGE          CREATED       CREATED BY                                      SIZE      COMMENT
58db3edaf2be   2 weeks ago   /bin/sh -c #(nop)  CMD ["/bin/bash"]            0B
<missing>      2 weeks ago   /bin/sh -c #(nop) ADD file:18e71f049606f6339…   77.8MB
<missing>      2 weeks ago   /bin/sh -c #(nop)  LABEL org.opencontainers.…   0B
<missing>      2 weeks ago   /bin/sh -c #(nop)  LABEL org.opencontainers.…   0B
<missing>      2 weeks ago   /bin/sh -c #(nop)  ARG LAUNCHPAD_BUILD_ARCH     0B
<missing>      2 weeks ago   /bin/sh -c #(nop)  ARG RELEASE                  0B

It looks like a false alarm to me, since those "ARG" and "LABEL" layers are unlikely cause security issues, aren't them?

@dtfans dtfans added the question Further information is requested label Feb 13, 2023
@tomoyamachi
Copy link
Collaborator

@dtfans Thank you for the report.
You're right. Dockle only ignores ADD in the first line now.

if index != 0 && useADDstatement(cmdSlices) {

I will fix it.

@tomoyamachi tomoyamachi added bug Something isn't working and removed question Further information is requested labels Feb 13, 2023
@tomoyamachi tomoyamachi self-assigned this Feb 13, 2023
@loganmarchione
Copy link

Just had the same issue.

 FATAL	- CIS-DI-0009: Use COPY instead of ADD in Dockerfile
	* Use COPY : /bin/sh -c #(nop) ADD file:18e71f049606f6339ce7a995839623f50e6ec6474bfd0a3a7ca799db726f47f6 in / 

@lior-orca
Copy link
Contributor

@tomoyamachi are you going to address it soon?

@lior-orca
Copy link
Contributor

@tomoyamachi we can probably have a similar logic to trivy -
https://github.com/aquasecurity/trivy/blob/3987a679f9520259a1b1474e81704b8aedce2ef7/pkg/fanal/artifact/image/image.go#L496

@tomoyamachi
Copy link
Collaborator

tomoyamachi commented Apr 9, 2023

@dtfans @lior-orca @loganmarchione
After considering the matter, I think the current logic is acceptable.
The reason for this is that current ubuntu image is not built in accordance with best practices.

Trivy has the same problem as dockle.
Below is the Dockerfile for Ubuntu.

FROM scratch
ADD @@TARBALL@@ /
CMD ["bash"]

We can see that after the base image(scratch), a tar file is added using the ADD command.
I think it is up to the users to decide whether or not this tar file can be trusted.

Dockle does not understand whether a container image is official or not, and it only evaluates based on whether the container image is built according to best practices.

@lior-orca
Copy link
Contributor

@tomoyamachi what prevents us from "guessing" the base layer, similar to trivy, which will resolve the issue

Trivy has similar issues opened, and I'm sure they will handle it over time

@tomoyamachi
Copy link
Collaborator

@lior-orca I'm sorry. I was wrong.
This issue has been fixed in version 0.4.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants