GHSL-2023-061: Cross-Site Request Forgery (CSRF) and Server-Side Request Forgery (SSRF) in jenkinsci/blueocean-plugin - CVE-2023-40341
The BlueOcean plugin's GitHub SCM endpoint did not validate the apiUrl parameter, allowing an attacker to craft a link that, when visited by a victim, would send the victim's GitHub credentials to an attacker-controlled server and enable SSRF to internal hosts. The attacker could leak sensitive credentials and read responses from arbitrary hosts.
Originally disclosed on GitHub Security Lab
A CSRF/SSRF vulnerability in jenkinsci/blueocean-plugin allows the leak of sensitive credentials (including GitHub credentials) to an attacker-controlled server. The issue arises from a lack of proper input validation/sanitization of the apiUrl parameter in the GithubScm#getRepository method.
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 GithubScm#getRepository method did not validate or sanitize the apiUrl parameter, allowing an attacker to control the URL used in a server-side HTTP request that included the victim's credentials.
Impact
An attacker could leak any credential stored in the BlueOcean domain, including the victim's GitHub credentials, to an attacker-controlled server, and could send requests to arbitrary hosts/paths within internal networks and read their responses.
What the attacker needed
A BlueOcean pipeline using GitHub as SCM; Victim clicks a crafted link; Victim is authenticated to Jenkins
The fix
The Blue Ocean Plugin was fixed in version 1.27.5.1 to use the configured SCM URL instead of a user-specified URL provided as a parameter to the HTTP endpoint.
How it was found
- Ensure a BlueOcean pipeline exists that uses GitHub as the SCM.
- Send a crafted link to the victim that includes a jobName and an apiUrl pointing to an attacker-controlled server.
- When the victim visits the link, their browser sends a request to the Jenkins endpoint.
- The Jenkins server makes a request to the attacker's server, including the victim's GitHub credentials in the Authorization header.
- The response to the original request includes the forged request's response as part of an error message.
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 report describes a flaw in a Jenkins plugin that lets an attacker trick a logged-in user into clicking a link. When the user clicks, their browser sends a request to the Jenkins server, which then forwards the user's GitHub token to a server the attacker controls. The same flaw also lets the attacker make the Jenkins server send requests to internal systems and read the replies.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.