[LEGIT] Fix - Endpoints should not be vulnerable to reflected cross-site scripting (XSS) attacks#99
Open
legit-app-ci[bot] wants to merge 1 commit into
Open
[LEGIT] Fix - Endpoints should not be vulnerable to reflected cross-site scripting (XSS) attacks#99legit-app-ci[bot] wants to merge 1 commit into
legit-app-ci[bot] wants to merge 1 commit into
Conversation
…ite scripting (XSS) attacks
|
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.



🔍 The problem
Change this code to not reflect user-controlled data.
See issue in Legit
🔒 Fix Details
Fixed a Server-Side Request Forgery (SSRF) vulnerability combined with reflected Cross-Site Scripting (XSS). The code previously accepted arbitrary URLs from user input (
req.query.url) and fetched them server-side without validation, then reflected the response body directly into the HTML response without encoding.The fix implements two defenses: (1) an allowlist of trusted base URLs that validates
req.query.urlbefore making the request, rejecting any URL that doesn't start with an approved domain, and (2) HTML entity encoding using thehelibrary on the fetched response body before writing it to the response. This prevents attackers from accessing internal resources via SSRF and from injecting malicious scripts via reflected content.