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

268
Views
Prevent Client DOM XSS Vulnerability in Javascript

I am working with Checkmarx to scan my code for any potential vulnerabilities. I am getting

This untrusted data is embedded straight into the output without proper sanitization or encoding, enabling an attacker to inject malicious code into the output. message with following code.

var currentUrl = location.href;

I have tried to resolve this with following code, but seems like Checkmarx is not able to detect that I am already sanitizing the data.

var currentUrl = checkUrlForXSS(location.href);

// function definition

function checkUrlForXSS(url) {
    const reg = /(script|\)|\(|\>|\<)/ig;
    return url.replace(reg, "");
}

Is there any way I can sanitize the data in Javascript and resolve the vulnerability without using any libraries (like DOMPurify)?

Thank you.

about 4 years ago · Juan Pablo Isaza
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!