Fix reflected XSS in server PHP endpoints - #2
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Conversation
Escape user-controlled request parameters with htmlspecialchars before echoing them into HTML responses. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.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:
|
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
Security scan of the repo. The only server-side attack surface is
server/*.php; the rest is static tutorial content and a client-side helper library. This PR fixes the critical, unambiguous issues found: reflected XSS in the two PHP endpoints that echo request parameters straight into HTML.Fixed (critical — reflected XSS):
server/profile.php—$_POST['name']/$_GET['name']were concatenated into the HTML response unescaped. Now wrapped:?name=<script>alert(1)</script>executed in the victim's browser.server/about.php—echo "ABOUT PAGE ".$_GET['p']now escapespwithhtmlspecialchars(..., ENT_QUOTES, 'UTF-8').Findings not changed here (reported, not fixed)
asset/jquery.jsis jQuery 3.2.1, affected by CVE-2019-11358 (prototype pollution) and CVE-2020-11022/11023 (XSS, fixed in 3.5.0). Recommend bumping to a current 3.x (e.g. 3.7.1). Left out of this PR since it's a vendored minified file and could affect the tutorial behavior — happy to do it in a follow-up.tokenvalues throughoutcode/andpage/are demo values generated by_randomStr(...), not real credentials.server/json.phpreturns a static mock (status_login:false, id_user:12) — demo data, not a real auth endpoint.No PHP linter available in the environment; edits are minimal
htmlspecialcharswraps around existing string concatenation.Link to Devin session: https://app.devin.ai/sessions/74b1ccef57234e81ab5e85dbbdd6a08e
Requested by: @lamhotsimamora