TruffleHog Version
trufflehog 3.95.5 (brew)
Trace Output
https://gist.github.com/Archer36/67d13077055a68131b7306d0e7ddcacd
Expected Behavior
The presence of a sibling directory should not affect whether another sibling directory is traversed and scanned.
Given:
trufflehog-repro/
├── blue-team/
│ └── project-notes.txt
└── blue-team-deprecated/
└── AWSCredentials.txt
TruffleHog should traverse and scan blue-team-deprecated/AWSCredentials.txt regardless of whether blue-team exists.
Actual Behavior
When a sibling directory named blue-team exists, TruffleHog discovers the directory blue-team-deprecated but does not descend into it.
As a result:
AWSCredentials.txt is never enumerated.
AWSCredentials.txt is never scanned.
- No findings are produced.
If blue-team is renamed to blue-team2, TruffleHog immediately traverses into blue-team-deprecated, scans AWSCredentials.txt, and reports the expected AWS finding.
Removing blue-team entirely produces the same result.
Steps to Reproduce
- Create the following directory structure:
trufflehog-repro/
├── blue-team/
│ └── project-notes.txt
└── blue-team-deprecated/
└── AWSCredentials.txt
- Populate
AWSCredentials.txt with fake AWS credentials:
AWS_ACCESS_KEY_ID=AKIA7QW9K2M4X8N5R3TZ
AWS_SECRET_ACCESS_KEY=Vw8rL3qP9zNxY2mK7cTfH5sJ1aBdE6uQ4gWpR0xZ
- Run:
trufflehog filesystem trufflehog-repro --log-level=5
-
Observe:
- No findings are reported.
- Trace output shows
blue-team-deprecated being discovered but not traversed.
-
Rename:
mv trufflehog-repro/blue-team trufflehog-repro/blue-team2
- Run the same scan again:
trufflehog filesystem trufflehog-repro --log-level=5
-
Observe:
AWSCredentials.txt is enumerated and scanned.
- An AWS finding is reported.
-
Rename the directory back to blue-team.
-
Run the scan again.
-
Observe that the finding disappears.
Environment
- OS: macOS 15.5
- TruffleHog Version: 3.95.5
Additional Context
This issue was originally encountered while scanning a SharePoint export, but was reduced to a minimal reproduction that does not require SharePoint data or real credentials.
The issue appears to be related to directory traversal rather than detector behavior.
The key observation from the trace logs is:
Failing case (blue-team exists):
Entry found is a directory
path:"trufflehog-repro/blue-team"
Entry found is a file
path:"trufflehog-repro/blue-team/project-notes.txt"
Entry found is a directory
path:"trufflehog-repro/blue-team-deprecated"
At this point traversal stops. The scanner never enters blue-team-deprecated and never enumerates AWSCredentials.txt.
Successful case (blue-team2 exists):
Entry found is a directory
path:"trufflehog-repro/blue-team-deprecated"
Entry found is a file
path:"trufflehog-repro/blue-team-deprecated/AWSCredentials.txt"
scanning file
path:"trufflehog-repro/blue-team-deprecated/AWSCredentials.txt"
The scanner traverses into the directory, scans the file, and reports the expected finding.
The behavior appears deterministic:
| Layout |
Findings |
blue-team + blue-team-deprecated |
0 |
blue-team2 + blue-team-deprecated |
1 |
blue-team-deprecated only |
1 |
This suggests that the existence of a sibling directory whose name is a prefix of another sibling directory may affect filesystem traversal.
References
None currently.
I attached a bash script to help create the test environment.
th-bug.sh
TruffleHog Version
trufflehog 3.95.5 (brew)
Trace Output
https://gist.github.com/Archer36/67d13077055a68131b7306d0e7ddcacd
Expected Behavior
The presence of a sibling directory should not affect whether another sibling directory is traversed and scanned.
Given:
TruffleHog should traverse and scan
blue-team-deprecated/AWSCredentials.txtregardless of whetherblue-teamexists.Actual Behavior
When a sibling directory named
blue-teamexists, TruffleHog discovers the directoryblue-team-deprecatedbut does not descend into it.As a result:
AWSCredentials.txtis never enumerated.AWSCredentials.txtis never scanned.If
blue-teamis renamed toblue-team2, TruffleHog immediately traverses intoblue-team-deprecated, scansAWSCredentials.txt, and reports the expected AWS finding.Removing
blue-teamentirely produces the same result.Steps to Reproduce
AWSCredentials.txtwith fake AWS credentials:Observe:
blue-team-deprecatedbeing discovered but not traversed.Rename:
Observe:
AWSCredentials.txtis enumerated and scanned.Rename the directory back to
blue-team.Run the scan again.
Observe that the finding disappears.
Environment
Additional Context
This issue was originally encountered while scanning a SharePoint export, but was reduced to a minimal reproduction that does not require SharePoint data or real credentials.
The issue appears to be related to directory traversal rather than detector behavior.
The key observation from the trace logs is:
Failing case (
blue-teamexists):At this point traversal stops. The scanner never enters
blue-team-deprecatedand never enumeratesAWSCredentials.txt.Successful case (
blue-team2exists):The scanner traverses into the directory, scans the file, and reports the expected finding.
The behavior appears deterministic:
blue-team+blue-team-deprecatedblue-team2+blue-team-deprecatedblue-team-deprecatedonlyThis suggests that the existence of a sibling directory whose name is a prefix of another sibling directory may affect filesystem traversal.
References
None currently.
I attached a bash script to help create the test environment.
th-bug.sh