Vulnerabilities in pkg:npm/react-admin
PACKAGECVE-2023-25572 is a MODERATE (CVSS 5.4) cross-site-scripting attack on `<richtextfield>` vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting React admin libraries in the npm ecosystem. The issue involves cross-site-scripting attack on `<richtextfield>`. Remediation is available by upgrading affected packages to version 3.19.12, 4.7.6.
pkg:npm/react-admin
Vulnerability advisories affecting package pkg:npm/react-admin. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-5jcr-82fh-339v | CVE-2023-25572 | MODERATE | Cross-Site-Scripting attack on `<RichTextField>` |
CVE-2023-25572 at a Glance
Security Impact
CVSS: 5.4
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N).
How to Fix CVE-2023-25572
To remediate this vulnerability, upgrade all affected React admin dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install react-admin@3.19.12
npm install react-admin@4.7.6
npm install ra-ui-materialui@4.7.6
npm install ra-ui-materialui@3.19.12
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls react-admin
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2023-25572, inspect your project dependencies using npm:
npm ls react-admin
Analyze the terminal output to locate any version of React admin in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.19.12), your application is affected.
Note: The npm ls react-admin command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In React admin, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2023-25572 Affected React admin Versions
4 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
react-admin
|
npm |
< 3.19.12
|
3.19.12
|
|
react-admin
|
npm |
≥ 4.0.0
< 4.7.6
|
4.7.6
|
|
ra-ui-materialui
|
npm |
≥ 4.0.0
< 4.7.6
|
4.7.6
|
|
ra-ui-materialui
|
npm |
< 3.19.12
|
3.19.12
|
References
Frequently Asked Questions
What is CVE-2023-25572?
Which React admin versions are affected?
What version fixes CVE-2023-25572?
Is react-admin affected?
Is ra-ui-materialui affected?
What is the CVSS score of CVE-2023-25572?
What CWE is associated with CVE-2023-25572?
How can I check npm dependencies for CVE-2023-25572?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-5jcr-82fh-339v",
"modified" : "2023-02-14T00:32:21Z",
"published" : "2023-02-14T00:32:21Z",
"aliases" : [ "CVE-2023-25572" ],
"summary" : "Cross-Site-Scripting attack on `<RichTextField>`",
"details" : "### 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\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "react-admin"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.19.12"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "react-admin"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.0.0"
}, {
"fixed" : "4.7.6"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "ra-ui-materialui"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.0.0"
}, {
"fixed" : "4.7.6"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "ra-ui-materialui"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.19.12"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/marmelab/react-admin/security/advisories/GHSA-5jcr-82fh-339v"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-25572"
}, {
"type" : "WEB",
"url" : "https://github.com/marmelab/react-admin/pull/8644"
}, {
"type" : "WEB",
"url" : "https://github.com/marmelab/react-admin/pull/8645"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/marmelab/react-admin"
}, {
"type" : "WEB",
"url" : "https://github.com/marmelab/react-admin/releases/tag/v3.19.12"
}, {
"type" : "WEB",
"url" : "https://github.com/marmelab/react-admin/releases/tag/v4.7.6"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2023-02-14T00:32:21Z",
"nvd_published_at" : "2023-02-13T21:15:00Z"
}
}