question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No Protections Against XSS Attacks Using innerHTML

See original GitHub issue

If someone were building an app with Hyperapp and wanted to allow for formatting of user-supplied data with HTML instead of Markdown or other such syntax, using the innerHTML attribute adds a XSS vulnerability that we should probably at least warn about if not prevent entirely.

Example pen.

In React this would be prevented with the message:

Warning: Directly setting property `innerHTML` is not permitted. For more information, lookup documentation on `dangerouslySetInnerHTML`.

As the warning implies, the dangerouslySetInnerHTML attribute is React’s way of allowing the user to still do this while acknowledging how dangerous it is.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

12reactions
SkaterDadcommented, Sep 11, 2017

My vote is documentation. No need to add the extra complexity in my opinion.

It’s a good candidate for “Dev mode” console warnings in the future also.

On Sun, Sep 10, 2017, 7:22 PM Jorge Bucaran notifications@github.com wrote:

So, what solutions have we come up with so far?

  • Disable innerHTML and give you dangerouslySetInnerHTML to do the same.
  • Document using innerHTML is dangerous.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hyperapp/hyperapp/issues/360#issuecomment-328385905, or mute the thread https://github.com/notifications/unsubscribe-auth/AMpDr_0CTlLYNChCpcLICkP-z0cZnDiOks5shH1ZgaJpZM4PSbnG .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Preventing cross-site scripting attacks when using innerHTML ...
The idea behind an XSS attack with innerHTML is that malicious code would get injected into your site and then execute. This is...
Read more >
If using innerHTML poses a security threat when should we ...
And I've read that if you're using a front end framework like React, there will be built in protections against XSS attacks.
Read more >
XSS prevention and .innerHTML - javascript - Stack Overflow
This would be like a DOM Based XSS attack as it is using rendered JavaScript rather than HTML, however, as it passes though...
Read more >
Cross Site Scripting Prevention - OWASP Cheat Sheet Series
This cheatsheet is a list of techniques to prevent or limit the impact of XSS. No single technique will solve XSS. Using the...
Read more >
.innerHTML Cross-site Scripting - DEV Community ‍ ‍
It's a security issue if it inserts user-provided values, but if you use it to insert static data, or something generated without including...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found