Issue any http requests when users view an openapi document and click on buttons
The sanitisation of a Swagger OpenAPI viewer did not exclude the `form` tag, allowing an attacker to embed a form in an OpenAPI document. When a user clicked the 'Try it out' and 'Execute' buttons, the form sent an arbitrary POST request to the server, potentially performing actions such as adding the attacker as an admin.
GitLab
Originally disclosed on GitLab
- Fixed in 6 months
- Disclosed after 6 months
HackerOne report #1563383 by yvvdwf on 2022-05-09, assigned to @kmorrison1:
Report | Attachments | How To Reproduce
Report
Summary
Hello,
The santization of a swagger openapi viewer does not exclude form tag. Consequently attackers may introduce a form which allows to send arbitrary POST requests to the server. PUT, DELETE, PATH requests can be achieved by setting value of_method field.
Steps to reproduce
- In an existing project or create a new one, add a file,
openapi-form.yml(you can change the basename but it needs to containopenapiword and the.ymlextension is important) with the following content:
openapi: 3.0.0
info:
title: Sample API
servers:
- url: /api/v4
paths:
/users/5212593:
put:
description: Click `Try it out` then `Execute` buttons to get bounty.
operationId: api
parameters:
- name: admin
value: true
- After committing the file, view it and click on
Try it outthenExecutebuttons. You will see a POST request to/api/v4/users/5212593. This is an example to escalate my account as Admin.
Impact
Attackers may trick users to perform unattended actions, such as (1) add attackers to Admin or a private group, (2) add attackers' SSH key, etc.
Examples
This example is in private mode, please tell me if you cannot access: https://gitlab.com/yvvdwf/xss/-/blob/master/openapi-form.yml#/default/api
What is the current bug behavior?
The sanitization does not exclude form tag
What is the expected correct behavior?
The form tag should be excluded
Output of checks
This bug happens on GitLab.com
Impact
Attackers may trick users to perform unattended actions, such as (1) add attackers to Admin or a private group, (2) add attackers' SSH key, etc.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
How To Reproduce
Please add reproducibility information to this section:
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 sanitiser used by the OpenAPI viewer did not strip the `form` HTML tag, allowing arbitrary form submissions.
Impact
Attackers could trick users into performing unintended actions such as adding the attacker to an admin or private group, or adding the attacker's SSH key.
What the attacker needed
Victim views a crafted OpenAPI file; victim clicks 'Try it out' and 'Execute'
The fix
The `form` tag should be excluded from the sanitiser.
How it was found
- Create or use an existing project and add a file named with 'openapi' and a .yml extension containing a crafted OpenAPI definition.
- Commit the file and view it in the OpenAPI viewer.
- Click the 'Try it out' button, then the 'Execute' button.
- Observe a POST request being sent to the server (e.g., to /api/v4/users/5212593).
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.
An OpenAPI document describes an API and can be viewed in a special viewer that lets you try out requests. The viewer failed to remove a dangerous HTML tag called `form`, which can send data to a server. An attacker could put a form in the document so that when someone clicks buttons in the viewer, their browser sends a request the attacker chose, like adding the attacker as an admin.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.