Find, verify, and analyze leaked credentials
Jenkins Source
Overview
The Jenkins source lets TruffleHog scan the console output of Jenkins build logs for secrets, credentials, and sensitive data. It walks a Jenkins instance's jobs and folders through the Jenkins API, then downloads and scans the build log of every build it finds.
Jenkins Fundamentals
What does this source scan?
This source asks the Jenkins API for the list of jobs and folders at a given Jenkins URL, walks into folders recursively, and for every job it finds, downloads the plain text console output of every build and scans it.
Key Jenkins Terminology
| Term | Description |
|---|---|
| Job | A single configured build task in Jenkins, such as a Freestyle project or a Pipeline |
| Folder | A container that groups jobs and can hold other folders |
| Build | One run of a job, numbered in order |
| Console Output | The full text log produced while a build ran, available as a plain text page |
Features
- Folder Traversal: Recursively walks Jenkins folders to find every job underneath them
- Multiple Authentication Methods: Username and password, a custom header, or unauthenticated
- Self Signed Certificate Support: Can skip TLS certificate verification for instances using one
Configuration
Authentication Methods
1. Username and Password
CLI Usage:
trufflehog jenkins --url https://jenkins.example.com --username my-username --password my-password
YAML Configuration:
sources:
- connection:
'@type': type.googleapis.com/sources.Jenkins
endpoint: https://jenkins.example.com
basic_auth:
username: my-username
password: my-password
name: jenkins-scan
type: SOURCE_TYPE_JENKINS
verify: true
On the CLI, the URL, username, and password can also be set with the JENKINS_URL, JENKINS_USERNAME, and JENKINS_PASSWORD environment variables instead of the matching flags. This does not apply to a YAML config file, since TruffleHog does not read environment variables while loading YAML.
2. Custom Header
Sends a fixed header, such as an API token header, with every request. This method is only available in the YAML config, not the CLI.
YAML Configuration:
sources:
- connection:
'@type': type.googleapis.com/sources.Jenkins
endpoint: https://jenkins.example.com
header:
key: "Authorization"
value: "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
name: jenkins-scan
type: SOURCE_TYPE_JENKINS
verify: true
3. Unauthenticated
CLI Usage:
Leave out --username and --password to scan without authentication. This is also what happens if only one of the two is given, since the CLI only uses basic auth when both are set together.
trufflehog jenkins --url https://jenkins.example.com
YAML Configuration:
In the YAML config, this must be set explicitly. Leaving out the credential entirely is rejected.
sources:
- connection:
'@type': type.googleapis.com/sources.Jenkins
endpoint: https://jenkins.example.com
unauthenticated: {}
name: jenkins-scan
type: SOURCE_TYPE_JENKINS
verify: true
Self Signed Certificates
trufflehog jenkins --url https://jenkins.example.com --username my-username --password my-password --insecure-skip-verify-tls
On the CLI, this can also be set with the JENKINS_INSECURE_SKIP_VERIFY_TLS environment variable.
How Scanning Works
Scanning Process
- Job Listing: Asks the Jenkins API for the jobs directly under the given URL
- Folder Traversal: For every folder found, repeats the job listing inside that folder, continuing until every nested folder has been walked
- Build Listing: For every job that is a Freestyle project or a Pipeline, lists all of its builds
- Build Log Scanning: Downloads the console output of every build and scans its text for secrets
- Progress Tracking: Reports progress as each job is processed, so a scan can be monitored while it runs
What Gets Scanned
- The console output of every build of every Freestyle project and Pipeline job found underneath the given URL, including jobs inside nested folders
What Doesn't Get Scanned
- Job types other than a Freestyle project or a Pipeline, such as a Multi-configuration project (in the Jenkins API this is the
hudson.matrix.MatrixProjectclass) - Anything whose Jenkins API class is not recognized as a plain folder or as one of the two scannable job types, including any job container that is not the plain Jenkins folder type
- Anything outside the build's console output, such as artifacts, build parameters, or job configuration
There is no concurrency for this source: jobs, builds, and their console output are all fetched and scanned one at a time, and there is no flag to change that.
Usage Examples
Scanning with Username and Password
trufflehog jenkins --url https://jenkins.example.com --username my-username --password my-password
Scanning Without Authentication
trufflehog jenkins --url https://jenkins.example.com
Scanning an Instance with a Self Signed Certificate
trufflehog jenkins --url https://jenkins.example.com --username my-username --password my-password --insecure-skip-verify-tls
Debug Logs
With debug on for this source (debug: true in the config), the scan logs:
V(1):initialized Jenkins sourcewith the auth method (never the credentials), the endpoint with any password redacted, and whether TLS verification is skipped, then the number of jobs found.V(2):got buildsfor each job, with its build count.V(3): the objects listed in each folder, each object as it is processed, andchunking buildfor each build.V(4): each Jenkins API page request,Skipping objectwith areasonfor objects that are not a supported job type, and each retry of a request.V(5): each HTTP request with its auth type, and each response status code.
Lines carry job_name, build_number and the other job and build fields where they apply. Failures to get a job's builds or a build log are logged as errors at the default level.
Troubleshooting
Common Issues
Issue: Authentication failures when connecting to Jenkins Solution: Check that the username and password, or the custom header, are correct and have permission to read the target jobs and builds.
Issue: A username was given but the scan still ran unauthenticated
Solution: On the CLI, both --username and --password must be set together for basic authentication to be used. If either one is missing, the scan falls back to unauthenticated without an error.
Issue: Received non-200 status from get jenkins jobs request
Solution: Check the Jenkins URL is correct and reachable, and that the credentials have permission to list jobs at that URL.
Issue: Certificate errors when connecting to a self managed Jenkins instance
Solution: Pass --insecure-skip-verify-tls if the instance uses a self signed certificate.
Issue: Some jobs are missing from the scan
Solution: TruffleHog only scans Freestyle projects and Pipeline jobs, and only recurses into the plain Jenkins folder type. A job of another type, or one nested inside a different kind of container, is skipped. With debug on, the scan logs Skipping object for each one.