-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
trufflehog 3.68.2 does not detect a github PAT detected by 3.63.4 #2515
Comments
Is the PAT the old format or the new one with the prefix ( |
new limited scope format with |
wonder if this could relate to https://github.com/trufflesecurity/trufflehog/pull/2324/files ?? |
Are you able to reproduce this locally (i.e., not on GitHub Actions)? If so, it should be easy to determine which commit caused the issue with |
i can reproduce locally using dockerized trufflehog - do you have any additional info or guide on this tool? do i need to install golang (it's been a while) so i can compile and run each version? thanks |
You could try to do it with Docker. Steps (This will likely require some tweaks to get working.)
# Write the script
cat << 'EOF' > /tmp/bisect.sh
#!/usr/bin/env bash
# an exit code of 125 asks "git bisect" to "skip" the current commit
IMAGE=$(docker buildx build --platform=linux/amd64 -q . || exit 125)
# run the application and check that it produces good output
docker run --rm -v "$REPO_PATH":/tmp -w /tmp -it "$IMAGE" git file:///tmp/ --since-commit ${base_commit:-''} --branch ${head_commit:-''} --fail --no-update --github-actions --only-verified
if [ $? -eq 183 ]; then
exit 0
else
exit 1
fi
EOF
# Make the script executable
chmod +x /tmp/bisect.sh
git clone {your_repo}
export REPO_PATH="/your/path"
git clone https://github.com/trufflesecurity/trufflehog.git
cd trufflehog
git bisect start
# Marks the last known 'good' commit as v3.63.4 (https://github.com/trufflesecurity/trufflehog/releases/tag/v3.63.4)
git bisect good b0fab16ad4b5cc42c38ee4e2ee362aa3c47dea24
# Marks the current HEAD as bad.
git bisect bad
git bisect run /tmp/bisect.sh |
wow, thanks @rgmz, that's an amazing tool. assuming i did this right the result is:
(I can post the whole thing if you want) this seems to be #2356 From this I glean i could possibly apply the What are the other next steps? Thank you! |
Ok, I have verified that adding that flag does indeed cause my results to appear with the latest version... I did have the same secret in a couple of different files, so perhaps this is the intended effect? But they are the same detector, not overlapping detectors... doesn't seem like a very good feature imho... I guess it's up to you what to do with this information; thank you for the help and for now I will add this flag. |
FYI @ahrav @dustin-decker |
@jingles if you run the latest version without the |
No, they do not, @rosecodym |
Then we've got a real mystery on our hands. #2356 is supposed to disable verification if a secret is flagged by multiple detectors, but that doesn't sound like what you're experiencing here, since you're only seeing one detector flag this secret. @ahrav I wonder if there's a bug in the implementation that's causing this secret to get dropped unnecessarily. |
oh I should tag @zricethezav too |
@jingles @rgmz we have a blog post out now covering why this feature was introduced: https://trufflesecurity.com/blog/contributor-spotlight-helena-rosenzweig-and-assetnote-team
There is likely some bug in the implementation. Do you have a sample file or repo we can test with? If you provide some sample fake secrets we can replace them with our own real secrets to be verified. |
Just adding here that I am also seeing the same bug also not using verification - the detector worked when the secret was prefixed with A fake secret that should be detected but isn't: Edit: it's interesting because I can see that the above secret is a match for the regex specified here, but it does not work when running the trufflehog scan on my computer. |
I'll take a closer at this today. Thank you @jingles for opening the issues and @philipfoo for the example. |
hey @philipfoo would it be possible for you to share the file or directory you put the fake secret in? Testing that secret locally it appears to be detected, there might be additional context in the other data that could be causing us to drop the secret, but it's hard to tell. If you are unable to share the file, could you maybe move the secret to a different file and test it there. Thanks a lot. |
TruffleHog Version
3.68.2
Trace Output
https://gist.github.com/jingles/262a42a6edaf0647cf723ceb6ce09f51
Expected Behavior
Should have detected verified Github result
Actual Behavior
no results found
Steps to Reproduce
see gist, these are private repos
Environment
Additional Context
I was intentionally testing exposure of a Github PAT in github actions and trufflehog failed to detect it. locally it worked. Eventually I realized my local docker container was behind the latest pulled in the actions build. Updated my image locally and the same command failed to detect.
The text was updated successfully, but these errors were encountered: