Real-life OIDC Security (III): CRLF Injections
GitLab and Bitbucket failed to sanitise the access_token from an OIDC identity provider before using it in HTTP headers, allowing a malicious identity provider to inject CRLF sequences. In GitLab this led to HTTP request splitting and potential SSRF to internal hosts; in Bitbucket it caused log injection and spoofed log entries.
security.lauritz-holtmann.de
Published on security.lauritz-holtmann.de
This is the third post of a series on Single Sign-On and OpenID Connect 1.0 security. In this post, a more common CRLF injection in the context of OIDC is discussed in detail.
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 write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the applications did not strip CRLF sequences from the access_token before including it in HTTP headers.
Impact
A malicious identity provider could perform HTTP request splitting to send arbitrary requests to internal hosts, potentially leading to remote code execution if a Redis instance is present; in Bitbucket, it could inject log entries and trigger notification emails.
What the attacker needed
Victim uses a malicious identity provider; attacker controls the identity provider; victim application uses OIDC for login
The fix
Implementations should strip characters not allowed in bearer tokens (as per RFC6750) before using the access_token in HTTP headers.
How it was found
- Configure GitLab to use an external OpenID Connect login provider.
- As a malicious identity provider, return an access_token containing CRLF sequences.
- GitLab uses this token in the UserInfo request header without sanitisation.
- The CRLF sequences split the HTTP request, allowing arbitrary requests to internal hosts.
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 write-up has not been written yet. The Original tab links to the source.
When you log in with an external identity provider, the provider sends a token that the application uses to fetch your profile. If the application puts that token directly into an HTTP header without cleaning it, an attacker who controls the identity provider can insert special newline characters (CRLF) to add extra headers or even split the request. This can make the application send requests to internal systems or write fake entries in logs.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.