Skip to content
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

Code Injection Vulnerability #371

Open
corporealfunk opened this issue Feb 7, 2019 · 0 comments
Open

Code Injection Vulnerability #371

corporealfunk opened this issue Feb 7, 2019 · 0 comments

Comments

@corporealfunk
Copy link

If you allow users to input titles/captions for use in swipebox, the current code allows code injection. For example, say you properly escape all HTML entities in your "a" tag's title attribute like this:

<a class='swipebox' href='https://picsum.photos/200/300' title='&lt;script&gt;alert(&quot;hi&quot;);&lt;/script&gt;'>click to see image</a>

At first glance the above tag looks OK: we've escaped our user input as we should to avoid code injection. However, when the swipebox plugin is initialized and the user clicks this link, the JS code is executed and the alert box is shown. You can see this in action here:

https://jsfiddle.net/wk481x95/

This functionality normally allows us to display a caption in the swipebox widget, by setting the "a" tag's title attribute. The reason the code injection occurs is because the swipebox plugin is using jQuery's "append" method to insert the "a" tag's title attribute into the swipebox widget. It should be using jQuery's "text" method which escapes any data placed into the node.

$( '#swipebox-title' ).append( title );

Jens2014 added a commit to Jens2014/libratus_nPG that referenced this issue Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant