[Security] Fix CodeQL alert #41: Reflected server-side cross-site scripting#59
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
[Security] Fix CodeQL alert #41: Reflected server-side cross-site scripting#59devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…pting Co-Authored-By: cfried123 <cfried123@yahoo.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes reflected server-side cross-site scripting in the
/fetchendpoint ofvulnerable_ssrf.py(CodeQL alert #41, CWE-079).The
fetch_url()function returnsresponse.textdirectly to the client. If the fetched URL serves HTML/JS content, it is reflected verbatim — enabling XSS via a crafted URL parameter.Fix: Escape the response text using
markupsafe.escape()before returning it.Scope: This PR only addresses the reflected XSS on line 13. The underlying SSRF vulnerability (user-controlled URL) and other unescaped return values in this file are tracked under separate alerts.
Review & Testing Checklist for Human
markupsafeis importable in the runtime — it's a transitive dependency of Flask/Jinja2 but is not explicitly declared inPipfile<script>alert(1)</script>results in escaped HTML entities in the response, not executable JSstr(escape(response.text))should just beescape(response.text)— the outerstr()strips theMarkuptype but doesn't change the escaped content; Flask accepts bothNotes
/fetchendpoint is patched. Other endpoints in the same file (/proxy,/image,/metadata) also return unescaped content and are tracked as separate CodeQL alerts.Link to Devin session: https://app.devin.ai/sessions/b1e0e08d72aa4bb7a4c7b4d5f86ba798
Requested by: @colin-d-fried