Skip to content

Unsanitized Inner HTML in Chip component #1091

@jmuzina

Description

@jmuzina

I noticed when reviewing the TICS report for react-components that there are some uses of dangerouslySetInnerHTML that were flagged as XSS vulnerabilities.

Flag 1: Chip (src)
Flag 2: FilterPanelSection of Search and Filter (src)

Are these left here intentionally so that our users have the freedom to place whatever they like in the chips, and thus they have the responsibility to sanitize contents? Otherwise, we could use something like dompurify to sanitize the inner HTML, i.e:

import { sanitize } from 'dompurify'
// 
//
const el = ({ text }) => {
    return (
        <h3
              dangerouslySetInnerHTML={{
                __html: sanitize(text)
              }}
        />
    );
}

Here's what a change to fix this might look like: jmuzina@f3371c6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛Something isn't workingP3 TriagedIssue has been reviewed as part of legacy backlog grooming (project P3).Question ❓Further information is requestedTriaged: v4Triaged, to be implemented as part of Vanilla v4

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions