Replies: 2 comments 4 replies
-
@afdesk Can you please take a look? |
Beta Was this translation helpful? Give feedback.
1 reply
-
@bnevis-i thanks for your report! my steps are next:
$ ssh-keygen -f key1 -N ""
FROM alpine:3.18.0
COPY key1 /pr/key1
$ docker build -t demo:4638 .
Sending build context to Docker daemon 7.168kB
Step 1/2 : FROM alpine:3.18.0
---> 5e2b554c1c45
Step 2/2 : COPY key1 /pr/key1
---> be502e4497a7
Successfully built be502e4497a7
Successfully tagged demo:4638
$ trivy i --clear-cache && trivy -d i --scanners secret demo:4638
...
/pr/key1 (secrets)
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)
HIGH: AsymmetricPrivateKey (private-key)
══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Asymmetric Private Key
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
/pr/key1:1 (added by 'COPY file:75061f588f08ddcf167e0e815ed4a7')
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 [ -----BEGIN OPENSSH PRIVATE KEY-----*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************-----END OPENSSH PRIVATE KEY-----
2
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
$ trivy i --clear-cache && trivy -d i --scanners secret --input demo.tar
2023-06-15T22:56:12.346+0600 INFO Removing artifact caches...
2023-06-15T22:56:13.041+0600 DEBUG Severities: ["UNKNOWN" "LOW" "MEDIUM" "HIGH" "CRITICAL"]
...
/pr/key1 (secrets)
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)
HIGH: AsymmetricPrivateKey (private-key)
══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
Asymmetric Private Key
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
/pr/key1:1 (added by 'COPY file:75061f588f08ddcf167e0e815ed4a7')
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 [ -----BEGIN OPENSSH PRIVATE KEY-----*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************-----END OPENSSH PRIVATE KEY-----
2
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
I am trying to get secret scanning on docker images working. I have gone so far as to clone the github repo and do some step-by-step debugging.
What I did was to create a docker image with an RSA private key in it.
I the did a "docker save" to export a tarball, and then scan it with
trivy image --input image.tar
What I noticed was that in the following code in
pkg/fanal/artifact/image/image.go
That
missingLayers
is empty and it doesn't run the parallel secret scanning task. If I putlayerKeyMap
instead ofmissingLayers
then I get debug messages aboutMissing diff ID in cache
.I don't quite understand yet the internal logic of what the code is doing, but it seems to me that it isn't scanning the image layers at all and that secret scanning of images is completely broken. (fs scanning seems to work)
I am wondering if there is a test case that the developers run to feed a known secret-infested image into trivy and get a known output, so that I can compare the known result with my own.
Desired Behavior
I expect secret scanning to output known secrets that I have seeded into the docker image.
Actual Behavior
No secrets are reported.
Reproduction Steps
1. Use openssl to generate an RSA keypair 2. Create Dockerfile that copies the private key into the image 3. Build the image 4. Export the image to a tar file using docker save 5. Run `trivy image --debug --scanners secret --input image.tar` 6. No secrets detected ...
Target
Container Image
Scanner
Secret
Output Format
None
Mode
Standalone
Debug Output
After
trivy image --reset
the output is slightly different but still does not find the private key:(Also deleted a trivy-secret.yaml that had an aggressive wildcard rule that suddenly started producing false positives after the reset).
Operating System
Ubuntu 22.04 x86_64
Version
Checklist
trivy --reset
Beta Was this translation helpful? Give feedback.
All reactions