
CGordon830606 (Community Member) asked a question.
export const el = str => {
// Ensure that str is a string; if not, set content to an empty string
const content = typeof str !== 'string' ? '' : str;
// Create a temporary div element
const tmp = document.createElement('div');
// Set the innerHTML of the div, with proper sanitization
tmp.innerHTML = DOMPurify.sanitize(content);
// Return the first element child of the temporary div
return tmp.firstElementChild;
}
.png)
This pattern is frustrating, and has played out several times for me. We do it in the suggested way, and there is still a problem. We open cases that lead to engineering tickets because of bugs on the regular. That is not what this is...
Answer from Veracode
"the use of DOMPurify was correct and satisfactory. This flaw is a False Positive as the risk of XSS is sufficiently controlled at this location. That said however, I do not expect other similar usage of DOMPurify to result in flaws being reported. If there are any other occurances where DOMPurify is used in the same way, those can be marked as False Positive. What has happened here for this one specific flaw is that we reached a technical limitation of our scanner, typically due to application size or complexity where we incorrectly raised this flaw out of"