fix : prevent reflected XSS by encoding var_export() output#623
Open
g0w6y wants to merge 1 commit intogoogle:mainfrom
Open
fix : prevent reflected XSS by encoding var_export() output#623g0w6y wants to merge 1 commit intogoogle:mainfrom
g0w6y wants to merge 1 commit intogoogle:mainfrom
Conversation
Contributor
|
I don't have tests that run the demos (yet... I suppose I really should set up an e2e suite) so l will need to test this locally before merging. |
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.
All 6 example files reflect unsanitized POST data and response objects
directly into HTML via
var_export()with no encoding, allowing reflectedXSS via the
g-recaptcha-responseparameter.PoC :
Root cause:
var_export($_POST)andvar_export($resp)write user-controlled data intoHTML with zero encoding. No
htmlspecialchars()exists anywhere in examples/.The
</pre>in the payload breaks out of the tag and the browser executesthe injected script.
Fix:
Replaced all
var_export()calls with:htmlspecialchars(print_r(..., true), ENT_QUOTES | ENT_HTML5, 'UTF-8')across 6 files, 18 lines total. No logic changes.
Files changed:
These files are actively deployed on recaptcha-demo.appspot.com and widely
copied by developers into production insecure patterns here propagate
directly into real applications.