Want to Add XSS (Cross Site Scripting ) in Flask API for a new level! #41
Closed
viralvaghela
started this conversation in
New Level Proposals
Replies: 1 comment 4 replies
-
Fantastic idea @viralvaghela! Go for it and slack to me or our community anytime at #secure-code-game for help or questions! |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello 👋, I would like to contribute to XSS (Reflected Cross Site Scripting ) Vulnerability in Flask API where not properly sanitizing user input will cause XSS.
Scenario:
We will create a simple REST API using Flask that is vulnerable to reflected XSS attacks. The API will have an endpoint that takes a parameter and echoes it back in the response without proper sanitization, allowing malicious JavaScript code to be executed in the user's browser.
the /getPlanetInfo endpoint of the Flask API takes a query parameter named planet in the GET request. The value of the planet parameter is used to fetch the corresponding planet information from the planet_data dictionary. However, if the provided planet name is not found in the dictionary, the API responds with an HTML string containing an XSS payload that executes a JavaScript alert.
For example, if an attacker passes the following URL:
http://localhost:5000/getPlanetInfo?planet=<script>alert('XSS Attack')</script>
the JavaScript code will be executed in the victim's browser.
Please do let me know what you think about this. or if you have any feedback/improvements please share :)
Beta Was this translation helpful? Give feedback.
All reactions