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

XSS vulnerability in default announcements #45

Open
thomas-insyde opened this issue Nov 25, 2020 · 0 comments
Open

XSS vulnerability in default announcements #45

thomas-insyde opened this issue Nov 25, 2020 · 0 comments

Comments

@thomas-insyde
Copy link

Hi,

There's an XSS vulnerability while rendering the LiveRegion when the list is generated with user input. I also managed to recreate it in the demo.

Steps to recreate:

  1. Go to the live demo on https://schne324.github.io/dragon-drop/demo/
  2. Replace on of the labels, for instance Ween with "><img src=x onerror="alert('Evil script');" />. (Make sure that the text in the dom is encoded, so "&gt;&lt;img src=x onerror="alert('Evil script');" /&gt;.)
  3. Drag & drop the item with malicious content.
  4. You'll be prompted with the Js alert.

The problem lies with the use of HTMLElement.innerText for the default announcements.

  announcement: {
    grabbed: function grabbed(el) {
      return 'Item ' + el.innerText + ' grabbed';
    },
    dropped: function dropped(el) {
      return 'Item ' + el.innerText + ' dropped';
    },
    reorder: function reorder(el, items) {
      var pos = items.indexOf(el) + 1;
      var text = el.innerText;
      return 'The list has been reordered, ' + text + ' is now item ' + pos + ' of ' + items.length;
    },
    cancel: 'Reordering cancelled'
  }

Some documentation on XSS prevention can be found here https://cheatsheetseries.owasp.org/cheatsheets/DOM_based_XSS_Prevention_Cheat_Sheet.html.

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