swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Markdown descriptions of API calls allows for XSS

Open joevennix opened this issue 10 years ago • 2 comments

To reproduce, insert a <script> into the description of a method in the JSON schema. An example sinatra server is attached. To reproduce, go to the URL:

http://swaggerhost/index.html?url=http://localhost:4567/swagger.json#!/pet/getPetById

And you will see an alert().

The sinatra server script can be downloaded here:

https://gist.github.com/joevennix/effa381d5fa520662b07

joevennix avatar Jan 12 '16 22:01 joevennix

It would be a good idea to move any inline <script> tags into their own files, and add a CSP <meta> tag that prevents inline scripts from running. That would prevent most of these reflected XSS vulns.

joevennix avatar Jan 12 '16 22:01 joevennix

Fixed in https://github.com/swagger-api/swagger-ui/commit/a906cffea4550eaa5369e4933a50753213cf09df

fehguy avatar Aug 23 '16 23:08 fehguy