-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Autocomplete: fix XSS in JSONP demo #1747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -2,7 +2,7 @@ | |||
|
|||
sleep( 2 ); | |||
// no term passed - just exit early with no response | |||
if (empty($_GET['term'])) exit ; | |||
if (!isset($_GET["term"]) || empty($_GET['term'])) exit ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isset()
is duplicative of the empty()
check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed. Fixed.
remove redundant isset() check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the isset() check. Thanks for the pointer!
This is too restrictive; it would reject many valid callback function names. Properly validating the callback name is too complex and there's no actual attack vector to worry about here. |
I respectfully disagree.
|
Tons and tons of unicode characters are missing.
The JavaScript code being an array, which does nothing. How is that a classic XSS vector? |
GitHub ate the script tag in my URL. Try this: |
So this is about linking directly to |
htmlspecialchars() would also work, however I personally prefer the validation approach over escaping here, since a callback name with (for instance) angle brackets should lead to nothing being returned. The proposed fix works for the sample code. If someone is changing the example, e.g. by using a callback name with unicode characters, it's probably their responsibility to adapt the PHP script, as well. If you wish, I could amend the PR to use htmlspecialchars() despite my reservations. Anyway, this must be fixed asap, since the same file is also residing on the jqueryui.com domain. |
fixes #15048