GHSL-2023-114: SSRF vulnerability in the Bitbucket Push and Pull Request Jenkins Plugin - CVE-2023-41937
The Bitbucket Push and Pull Request Jenkins plugin allows an attacker to send a crafted webhook payload that causes the Jenkins server to make an outbound request to an arbitrary URL, including the configured Bitbucket credentials in the Authorization header. This can lead to credential leakage.
Originally disclosed on GitHub Security Lab
Bitbucket Push and Pull Request Plugin provides a webhook endpoint at /bitbucket-hook/ that can be used to trigger builds of jobs configured to use a specified repository.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The plugin takes a URL from the webhook payload without validating it and uses it to make an authenticated request, sending credentials to an attacker-controlled destination.
What the attacker needed
Jenkins with the Bitbucket plugin installed; A job configured with a Bitbucket SCM trigger; Network access to the Jenkins webhook endpoint
The fix
The vulnerability was fixed in version 2.8.4 of the plugin, which validates the URL before making requests.
How it was found
- Send a POST request to the /bitbucket-hook/ endpoint with a crafted JSON payload.
- Include a malicious URL in the repository.project.links.self.href field of the payload.
- Ensure the X-Event-Key header is set to repo:refs_changed.
- The plugin processes the webhook and triggers a build if conditions are met.
- During the build, the plugin sends a status notification to the malicious URL, including the Bitbucket credentials in the Authorization header.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This is a server-side request forgery (SSRF) bug. The Jenkins plugin receives webhook data from Bitbucket and uses a URL from that data to send a status update back to Bitbucket. An attacker can send a fake webhook with a URL pointing to their own server, and Jenkins will send a request to that server, including the secret Bitbucket credentials in a header. This lets the attacker steal those credentials.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.