News for hackers. Stuff that matters.
Re:Show HN: Enlight – Learn to code by building projects by inimino on Sunday December 10, 2017 @06:23PM (#15894068)
Typing `<script>alert(0)</script>` into the chat box shows the injection hazard.

In fact this is caused by using jQuery, which (inexcusably) runs embedded scripts when adding HTML to the page. The simplest solution to this entire class of bugs is simply to not use jQuery and use the better-designed DOM methods instead, which is probably a more modern approach anyway.

Using innerHTML would solve the script injection, but you probably want to use innerText or createTextNode instead, since supporting HTML tags in a basic chat app seems more bug than feature.

The server side should be safe already as it looks like there’s no persistence.

Re:Show HN: Enlight – Learn to code by building projects by shamdasani on Sunday December 10, 2017 @08:23PM (#15894555)
Thanks for the heads up. DOM methods are more clear and better. Will update the tutorial soon.
Re:Show HN: Enlight – Learn to code by building projects by foota on Sunday December 10, 2017 @06:36PM (#15894137)
innerHtml wouldn't eliminate xss vectors though, things like load=something could bypass this.
Re:Show HN: Enlight – Learn to code by building projects by inimino on Tuesday December 12, 2017 @10:10PM (#15911724)
Yes, it's not completely safe. In a beginner tutorial, if you allow arbitrary HTML you should state that it shouldn't be done that way in a real app.