{"id":"CVE-2023-25572","aliases":["CVE-2023-25572","GHSA-5jcr-82fh-339v"],"related":[],"kind":"vulnerability","state":"published","title":"React-Admin vulnerable to Cross-Site-Scripting attack on `<RichTextField>`","summary":"react-admin is a frontend framework for building browser applications on top of REST/GraphQL APIs. react-admin prior to versions 3.19.12 and 4.7.6, along with ra-ui-materialui prior to 3.19.12 and 4.7.6, are vulnerable to cross-site scripting. All React applications built with react-admin and using the `<RichTextField>` are affected. `<RichTextField>` outputs the field value using `dangerouslySetInnerHTML` without client-side sanitization. If the data isn't sanitized server-side, this opens a possible cross-site scripting (XSS) attack. Versions 3.19.12 and 4.7.6 now use `DOMPurify` to escape the HTML before outputting it with React and `dangerouslySetInnerHTML`. Users who already sanitize HTML data server-side do not need to upgrade. As a workaround, users may replace the `<RichTextField>` by a custom field doing sanitization by hand.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"react-admin is a frontend framework for building browser applications on top of REST/GraphQL APIs. react-admin prior to versions 3.19.12 and 4.7.6, along with ra-ui-materialui prior to 3.19.12 and 4.7.6, are vulnerable to cross-site scripting. All React applications built with react-admin and using the `<RichTextField>` are affected. `<RichTextField>` outputs the field value using `dangerouslySetInnerHTML` without client-side sanitization. If the data isn't sanitized server-side, this opens a possible cross-site scripting (XSS) attack. Versions 3.19.12 and 4.7.6 now use `DOMPurify` to escape the HTML before outputting it with React and `dangerouslySetInnerHTML`. Users who already sanitize HTML data server-side do not need to upgrade. As a workaround, users may replace the `<RichTextField>` by a custom field doing sanitization by hand.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nAll React applications built with react-admin and using the `<RichTextField>` are affected. \n\n`<RichTextField>` outputs the field value using `dangerouslySetInnerHTML` without client-side sanitization. If the data isn't sanitized server-side, this opens a possible Cross-Site-Scripting (XSS) attack. \n\nProof of concept:\n\n```jsx\nimport { RichTextField } from 'react-admin';\n\nconst record = {\n    id: 1,\n    body: `\n<p>\n<strong>War and Peace</strong> is a novel by the Russian author\n<a href=\"https://en.wikipedia.org/wiki/Leo_Tolstoy\" onclick=\"document.getElementById('stolendata').value='credentials';\">Leo Tolstoy</a>,\npublished serially, then in its entirety in 1869.\n</p>\n<p onmouseover=\"document.getElementById('stolendata').value='credentials';\">\nIt is regarded as one of Tolstoy's finest literary achievements and remains a classic of world literature.\n</p>\n<img src=\"x\" onerror=\"document.getElementById('stolendata').value='credentials';\" />\n`,\n};\n\nconst VulnerableRichTextField = () => (\n    <>\n        <RichTextField record={record} source=\"body\" />\n        <hr />\n        <h4>Stolen data:</h4>\n        <input id=\"stolendata\" defaultValue=\"none\" />\n    </>\n);\n```\n\n### Patches\n\nVersions 3.19.12 and 4.7.6 now use `DOMPurify` to escape the HTML before outputting it with React and `dangerouslySetInnerHTML`\n\n### Workarounds\n\nYou don't need to upgrade if you already sanitize HTML data server-side. \n\nOtherwise, you'll have to replace the `<RichTextField>` by a custom field doing sanitization by hand:\n\n```tsx\n// react-admin v4\nimport * as React from 'react';\nimport { memo } from 'react';\nimport PropTypes from 'prop-types';\nimport get from 'lodash/get';\nimport Typography from '@material-ui/core/Typography';\nimport { useRecordContext, sanitizeFieldRestProps, fieldPropTypes } from 'react-admin';\nimport purify from 'dompurify';\n\nexport const removeTags = (input) =>\n    input ? input.replace(/<[^>]+>/gm, '') : '';\n\nconst RichTextField = memo(\n    props => {\n        const { className, emptyText, source, stripTags, ...rest } = props;\n        const record = useRecordContext(props);\n        const value = get(record, source);\n\n        return (\n            <Typography\n                className={className}\n                variant=\"body2\"\n                component=\"span\"\n                {...sanitizeFieldRestProps(rest)}\n            >\n                {value == null && emptyText ? (\n                    emptyText\n                ) : stripTags ? (\n                    removeTags(value)\n                ) : (\n                    <span\n                        dangerouslySetInnerHTML={{\n                            __html: purify.sanitize(value),\n                        }}\n                    />\n                )}\n            </Typography>\n        );\n    }\n);\n\nRichTextField.defaultProps = {\n    addLabel: true,\n    stripTags: false,\n};\n\nRichTextField.propTypes = {\n    // @ts-ignore\n    ...Typography.propTypes,\n    ...fieldPropTypes,\n    stripTags: PropTypes.bool,\n};\n\nRichTextField.displayName = 'RichTextField';\n\nexport default RichTextField;\n```\n\n### References\n\nhttps://github.com/marmelab/react-admin/pull/8644, https://github.com/marmelab/react-admin/pull/8645","format":"markdown","source":"ghsa"}],"published":"2023-02-13T20:49:54.340Z","modified":"2026-09-10T03:49:56.699Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N","score":5.4,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"< 3.19.12","status":"affected"},{"version":">= 4.0.0, < 4.7.6","status":"affected"}],"vendor":"marmelab","product":"react-admin","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"3.19.12"}],"ecosystem":"npm","package":"react-admin","purl":"pkg:npm/react-admin","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"4.0.0","status":"affected","fixed":"4.7.6"}],"ecosystem":"npm","package":"react-admin","purl":"pkg:npm/react-admin","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"4.0.0","status":"affected","fixed":"4.7.6"}],"ecosystem":"npm","package":"ra-ui-materialui","purl":"pkg:npm/ra-ui-materialui","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"3.19.12"}],"ecosystem":"npm","package":"ra-ui-materialui","purl":"pkg:npm/ra-ui-materialui","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"3.9.12"},{"status":"affected","introduced":"4.0.0","fixed":"4.7.6"}],"vendor":"marmelab","product":"ra-ui-materialui","cpe":"cpe:2.3:a:marmelab:ra-ui-materialui:*:*:*:*:*:node.js:*:*","source":"nvd"},{"ranges":[{"status":"affected","fixed":"3.9.12"},{"status":"affected","introduced":"4.0.0","fixed":"4.7.6"}],"vendor":"marmelab","product":"react-admin","cpe":"cpe:2.3:a:marmelab:react-admin:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/marmelab/react-admin/security/advisories/GHSA-5jcr-82fh-339v","tags":["exploit","mitigation","vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/marmelab/react-admin/pull/8644","tags":["exploit","patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/marmelab/react-admin/pull/8645","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/marmelab/react-admin/releases/tag/v3.19.12","tags":["release-notes","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/marmelab/react-admin/releases/tag/v4.7.6","tags":["release-notes","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-25572","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/marmelab/react-admin","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2025-03-10T21:00:46.979Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2023-25572","url":"https://www.cve.org/CVERecord?id=CVE-2023-25572","licence":"CVE Terms of Use","modified":"2025-03-10T21:12:31.239Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-5jcr-82fh-339v","url":"https://github.com/advisories/GHSA-5jcr-82fh-339v","licence":"CC-BY-4.0","modified":"2026-09-10T03:49:56.699Z"},{"source":"nvd","name":"NVD","id":"CVE-2023-25572","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-25572","licence":"Public domain","modified":"2026-06-17T05:41:31.163Z"}],"updatedAt":"2026-11-25T22:58:21.949Z","epss":{"score":0.00701,"percentile":0.54465,"date":"2026-12-01T12:00:22.000Z"}}