-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
XSS in data-target attribute #20184
Comments
I guess the fix for this specific issue could be changing return $(target) to: return $(document.querySelector(target)) but it seems the same problem is present in other places too. Here is another example: <a href="<img src=x onerror=alert(0)>" data-dismiss="alert">Test</a> |
@cvrebert: how do you think we should address this? |
I don't think that's a viable option compatibility-wise. Bootstrap 3 supports IE8, and its CSS selector support differs from jQuery's: http://caniuse.com/#feat=queryselector Based on https://bugs.jquery.com/ticket/11290, I guess we could try something like: if (/\s*</.test(target)) {
return $()
} @dmethvin Sorry to trouble you, but does this sound like a good workaround? (It's a shame jQuery doesn't have an "only interpret this as a selector, never as HTML" API.) |
You could use How is this cross-site? Where does the HTML come from and how does the attacker control it? |
This was found in an application where data-target was based on user input and only passed through standard HTML entities encoding. There is no reason why data-target should interpret HTML so while not impacting many applications it should be fixed in my opinion. |
Bootstrap 3 is no longer being officially developed or supported. All work has moved onto our next major release, v4. As such, this issue or pull request is being closed as a "won't fix." For additional help and support, we recommend utilizing our community resources. Thanks for your understanding, and see you on the other side of v4! <3, |
* collapse-multiple-target: Use $(document).find(selector) to avoid case in twbs#20184 Muti-target support for collapse plugin make getTargets to always return a JQuery to avoid calling JQuery on the same element further down Add a dropdown test case for twbs#21328 Simplify targets.length test Simplify null check when possible Rework getSelectorFromElement to not rely on regex # Conflicts: # js/src/alert.js # js/src/dropdown.js # js/tests/unit/collapse.js
I know this one's closed, but what's the status for v4? I can see that it is still affected by this vulnerability: https://github.com/twbs/bootstrap/blob/v4-dev/js/src/util.js#L120 I recommend to mitigate it by applying @dmethvin's proposal. (Also see comits on @vanduynslagerp's fork.) Should I prepare a pull request? Or should I open a new issue for v4? |
Yes you can make a PR @meeque for this issue which is still present 👍 |
You could make a PR against v3-dev branch too if you want. |
Let's start off with a test case: http://jsbin.com/qalekeroke/edit?html,output |
The data-target attribute is vulnerable to Cross-Site Scripting attacks:
The text was updated successfully, but these errors were encountered: