-
Notifications
You must be signed in to change notification settings - Fork 508
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
Feature - Provide docker image sha for failed pinned dependencies #967
Comments
Seems like a good idea to me. |
Good idea. Here are additional thoughts:
|
Stale issue message |
I'd like to pick this feature up and I have a good grasp on how to do this the easy way with crane. |
@spencerschrock Thank you! |
The only concern I have with |
Sure. I had mentioned |
Cool! Thanks |
There is also https://github.com/sethvargo/ratchet @varunsh-coder is there an API you support that we could call? |
We don't as of now for Dockerfiles, but can easily add it. There is already code that gets SHA for a docker image and tag (for GitHub Action workflows). We can repurpose it for Dockerfiles. Should this have a UI that you will point to, similar to what we have for workflows? Or do you plan to call the API directly from scorecard? |
I suppose we could do both. @spencerschrock Wdut? |
If I'm understanding the issue correctly, just having an API directly callable from scorecard would be enough to populate the Personally, I think the generated diffs would be small enough where they could be included in scorecard's existing results without flooding the output. The UI certainly looks better though. I'd be curious in other peoples' opinions. |
We don't always know if users will run scorecard in some more locked down environment (network disabled besides GitHub, etc), so a backup plan when connection fails would also be useful, I think: first try to get the sha, else provide a link to the StepSecurity website. Wdut?
+1 on remediation. We have done it for some results in #1850. |
Exploring the Docker path? Or using the StepSecurity API if it were created?
That seems like a reasonable backup to me. Or a link to the existing remediation markdown if no UI is created (essentially current behavior) |
@varunsh-coder would you consider an API for us to get the result sha as well? If this fails, we could fall back to providing the URL like we did for pinned permission check |
Yes, sure. These are the tracking issues. I will come back with a draft API definition and we can iterate over it before deciding on the final one. |
This could be a classic supply chain issue if I don't see a reason to use an external API. |
By API we meant REST API. We do recommend StepSecurity already, so this would not change the trust, correct? |
Recommending is different from actually providing the solution( providing the SHA). If a malicious user attacks StepSecurity and if we automate based on that one API it becomes almost like Stuxnet( Supply chain security issue) Scorecard should be cautious. What is the specific reason for using the API when docker/crane provides this functionality? I am trying to understand. |
Stepping back for a moment. The risk here is a hash is changed. This allows an attacker to perform a rollback attack pointing to a 1) older genuine container or 2) an non-existent image, but not achieve more than that. So an attacker could use this to push a previously vulnerable image that they can exploit or perform a DoS, but not direct RCE. It would say it's low risk. But feel free to disagree.
+1
To be clear, I'm not against using an API from a dependency we already use. The reason I asked about the remote API is because we already provide a link to their solution in the remediation section + it lets us outsource some remediation logic / maintenance and focus on other things Scorecard can do. In this case, remediation is simple and we can do it ourselves, but long-term we will need to spin up / rely on other services to do that for more complicated remediation logic. I'm totally fine with using an API from a dependency we already use. |
I've included a draft PR that shows my current changes. I still need to fix the test I broke, and introduce a new one, but wanted to get some visibility if I'm on the right path for the issue. I also thought I did experiment with One issue I can see is identifying the correct hash for a Dockerfile. There are different hashes for |
+1. Customized remediation is a recent code addition. Currently it's just used sparsely in pinned and permission checks. To make it work:
#1874 (comment) is proposing making the remediation results also available in cron / CLI output in the future |
@spencerschrock this is an interesting issue. I had not thought about it until I looked at your PR. I am trying to understand this based on a real scenario. If you see this Dockerfile as an example, it is used to build multi architecture images. This is one of the workflow runs. For this, the base image Do you know what the Interestingly I do not see that hash on DockerHub for this image: https://hub.docker.com/layers/unbound/madnuttah/unbound/openssl-buildenv-latest/images/sha256-2e38fa5026c578fe0f44d90845895e5ec22382b600f99b8f7fddbb877f0ac664?context=explore |
TL:DR: My understanding is the same as yours: there is some hash which is platform independent. I think we can just use universal hash I've been experimenting and observed the following behavior from I have the following Dockerfile for an example: FROM golang AS base
CMD go version When pinned to
On the other hand, if I grab a platform specific hash (either from Docker Hub or For example if I try to use the
|
Thanks @spencerschrock for all the info and the experimentation! I ran
and got the same hash as was in the build log - I am still curious about how this hash is generated. Because we might be missing some edge case and if developers update the Dockerfile based on this recommendation, and it fails, we will not have a good answer. So, I am wondering if we can find some documentation, or someone who can explain about this platform independent hash and how it is calculated, and so on... |
So it's due to a Manifest List. It's optional, so I'd be curious to see what the
The hash is actually passed as a header value, which is why I wasn't seeing it unless I opted for verbose output
|
Wanted to update that the UI for this is available now on app.stepsecurity.io. Here are couple of examples: The expected format is: Source code is here: If you want, the remediation section in Scorecard can be updated to also include such a link. It can be put below the current remediation suggestion to replace the value with the hash value. The UI might make it easier and help in cases where there are multiple images to be pinned in a single Dockerfile. |
cool, do you want to send a PR to update it? This is the file https://github.com/ossf/scorecard/blob/main/remediation/remediations.go |
Will do. |
Is your feature request related to a problem? Please describe.
Right now scorecard provides a warning message for
Warn: unpinned dependency detected in Dockerfile: ' alpine:3.14
when the docker file does not have a pinned SHA.Describe the solution you'd like
Instead of just providing the warning it would be helpful to provide the actual SHA that would have to be used to address this issue.
This can be achieved by using https://github.com/google/go-containerregistry/tree/main/cmd/crane and running something like
crane digest alpine:3.14
which provides the SHAsha256:e1c082e3d3c45cccac829840a25941e679c25d438cc8412c2fa221cf1a824e6a
The text was updated successfully, but these errors were encountered: