Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
Can xss attacks bypass InnerText?

all my friend's website DOM use innerText instead of innerHTML. I tried all possible ways i know but none of them work. Is it anyway that I can bypass innerText and make the tag work just like with the innerHTML tag?

Thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Why not just using innerHTML ? and then use DOMPurify to sanitize your DOM. it finds any potential ways that the user can add data like javascript:alert('hacked'); and makes them as normal HTML.

DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG.

look at the below example:

DOMPurify.sanitize('<img src=x onerror=alert(1)//>'); // becomes <img src="x">

you can use sanitize method then wrapped your html field or in this case image to avoid xss

another example,

const html = `<input type="text" name="text" />`;

ELEMENT.innerHTML = DOMPurify.sanitize(html, { // optional configurations // })

so if a user tries to add for example an image inside the input like

DOMpurify notices onload on image and removes it from submitting

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!