Vulnerabilities in pkg:npm/@grafana/data
PACKAGECVE-2021-41174 is a MODERATE (CVSS 6.9) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting @grafana/data libraries in the npm ecosystem. The issue involves xss vulnerability allowing arbitrary javascript execution. Remediation is available by upgrading affected packages to version 8.2.3.
pkg:npm/@grafana/data
Vulnerability advisories affecting package pkg:npm/@grafana/data. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-3j9m-hcv9-rpj8 | CVE-2021-41174 | MODERATE | XSS vulnerability allowing arbitrary JavaScript execution |
CVE-2021-41174 at a Glance
Security Impact
CVSS: 6.9
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N).
How to Fix CVE-2021-41174
To remediate this vulnerability, upgrade all affected @grafana/data 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 @grafana/data@8.2.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls @grafana/data
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-41174, inspect your project dependencies using npm:
npm ls @grafana/data
Analyze the terminal output to locate any version of @grafana/data in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.2.3), your application is affected.
Note: The npm ls @grafana/data 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 @grafana/data, 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-2021-41174 Affected @grafana/data Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
@grafana/data
|
npm |
≥ 8.0.0
< 8.2.3
|
8.2.3
|
References
Frequently Asked Questions
What is CVE-2021-41174?
Which @grafana/data versions are affected?
What version fixes CVE-2021-41174?
Is @grafana/data affected?
What is the CVSS score of CVE-2021-41174?
What CWE is associated with CVE-2021-41174?
How can I check npm dependencies for CVE-2021-41174?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-3j9m-hcv9-rpj8",
"modified" : "2021-11-29T15:05:31Z",
"published" : "2021-11-08T18:13:19Z",
"aliases" : [ "CVE-2021-41174" ],
"summary" : "XSS vulnerability allowing arbitrary JavaScript execution",
"details" : "Today we are releasing Grafana 8.2.3. This patch release includes an important security fix for an issue that affects all Grafana versions from 8.0.0-beta1.\n\n[Grafana Cloud](https://grafana.com/cloud) instances have already been patched and an audit did not find any usage of this attack vector. [Grafana Enterprise](https://grafana.com/products/enterprise) customers were provided with updated binaries under embargo.\n\n## CVE-2021-41174 XSS vulnerability on unauthenticated pages\n\n### Summary\n\nCVSS Score: 6.9 Medium\nCVSS:[CVSS:3.0/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N/E:U/RL:O/RC:R/CR:L/MAV:N/MAC:H/MPR:N/MUI:R/MS:C/MC:N/MI:H/MA:L](https://www.first.org/cvss/calculator/3.0#CVSS:3.0/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N/E:U/RL:O/RC:R/CR:L/MAV:N/MAC:H/MPR:N/MUI:R/MS:C/MC:N/MI:H/MA:L)\n\nWe received a security report to security@grafana.com on 2021-10-21 about a vulnerability in Grafana regarding the XSS vulnerability.\n\nIt was later identified as affecting Grafana versions from 8.0.0-beta1 to 8.2.2. [CVE-2021-41174](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-41174) has been assigned to this vulnerability.\n\n### Impact\n\nIf an attacker is able to convince a victim to visit a URL referencing a vulnerable page, arbitrary JavaScript content may be executed within the context of the victim's browser.\n\nThe user visiting the malicious link must be unauthenticated and the link must be for a page that contains the login button in the menu bar.\n\nThere are two ways an unauthenticated user can open a page in Grafana that contains the login button:\n- Anonymous authentication is enabled. This means all pages in Grafana would be open for the attack.\n- The link is to an unauthenticated page. The following pages are vulnerable:\n - `/dashboard-solo/snapshot/*`\n - `/dashboard/snapshot/*`\n - `/invite/:code`\n\nThe url has to be crafted to exploit AngularJS rendering and contain the interpolation binding for AngularJS expressions. AngularJS uses double curly braces for interpolation binding: {{ }} \n\nAn example of an expression would be: `{{constructor.constructor(‘alert(1)’)()}}`. This can be included in the link URL like this: \n\nhttps://play.grafana.org/dashboard/snapshot/%7B%7Bconstructor.constructor('alert(1)')()%7D%7D?orgId=1\n\nWhen the user follows the link and the page renders, the login button will contain the original link with a query parameter to force a redirect to the login page. The URL is not validated and the AngularJS rendering engine will execute the JavaScript expression contained in the URL.\n\n### Attack audit\n\nWe can not guarantee that the below will identify all attacks, so if you find something using the audit process described below, you should consider doing a full assessment.\n\n#### Through reverse proxy/load balancer logs\n\nTo determine if your Grafana installation has been exploited for this vulnerability, search through your reverse proxy/load balancer access logs for instances where the path contains `{{` followed by something that would invoke JavaScript code. For example, this could be code that attempts to show a fake login page or to steal browser or session data. The [OWASP cheat sheet](https://cheatsheetseries.owasp.org/cheatsheets/XSS_Filter_Evasion_Cheat_Sheet.html) has several examples of XSS attacks.\n\n#### Through the Grafana Enterprise audit feature\n\nIf you enabled “Log web requests” in your configuration with `router_logging = true`, look for requests where `path` contains `{{` followed by something that would invoke JavaScript code.\n\n### Patched versions\n\nRelease 8.2.3:\n\n- [Download Grafana 8.2.3](https://grafana.com/grafana/download/8.2.3)\n- [Release notes](https://grafana.com/docs/grafana/latest/release-notes/release-notes-8-2-3/)\n\n### Solutions and mitigations\n\nDownload and install the appropriate patch for your version of Grafana.\n\n[Grafana Cloud](https://grafana.com/cloud) instances have already been patched, and [Grafana Enterprise](https://grafana.com/products/enterprise) customers were provided with updated binaries under embargo.\n\n### Workaround\n\nIf for some reason you cannot upgrade, you can use a reverse proxy or similar to block access to block the literal string `{{` in the path.\n\nExample of an Nginx rule to block the literal string `{{`:\n\n```\nlocation ~ \\{\\{ {\n deny all;\n}\n```\n### Timeline and postmortem\n\nHere is a detailed timeline starting from when we originally learned of the issue. All times in UTC. \n\n* 2021-10-21 23:13: Security researcher sends the initial report about an XSS vulnerability.\n* 2021-10-21 23:13: Confirmed to be reproducible in at least versions 8.0.5 and 8.2.2.\n* 2021-10-22 02:02 MEDIUM severity declared.\n* 2021-10-22 09:22: it is discovered that Grafana instances with anonymous auth turned on are vulnerable. This includes https://play.grafana.org/ .\n* 2021-10-22 09:50: Anonymous access disabled for all instances on Grafana Cloud as a mitigation measure.\n* 2021-10-22 11:15: Workaround deployed on Grafana Cloud that blocks malicious requests.\n* 2021-10-22 12:35: Enabled anonymous access for instances on Grafana Cloud. \n* 2021-10-22 12:51: All instances protected by the workaround. From this point forward, Grafana Cloud is no longer affected.\n* 2021-10-22 14:05 Grafana Cloud instances updated with a fix.\n* 2021-10-22 19:23 :Determination that no weekend work is needed as the issue is of MEDIUM severity and the root cause has been identified.\n* 2021-10-25 14:13: Audit of Grafana Cloud concluded, no evidence of exploitation.\n* 2021-10-27 12:00: Grafana Enterprise images released to customers under embargo.\n* 2021-11-03 12:00: Public release.\n\n## Reporting security issues\n\nIf you think you have found a security vulnerability, please send a report to [security@grafana.com](mailto:security@grafana.com). This address can be used for all of\nGrafana Labs' open source and commercial products (including but not limited to Grafana, Tempo, Loki, k6, Tanka, and Grafana Cloud, Grafana Enterprise, and grafana.com). We only accept vulnerability reports at this address. We would prefer that you encrypt your message to us using our PGP key. The key fingerprint is:\n\nF988 7BEA 027A 049F AE8E 5CAA D125 8932 BE24 C5CA\n\nThe key is available from [ keyserver.ubuntu.com]( https://keyserver.ubuntu.com/pks/lookup?op=get&fingerprint=on&search=0xD1258932BE24C5CA) by searching for [security@grafana]( https://keyserver.ubuntu.com/pks/lookup?search=security@grafana&fingerprint=on&op=index).\n\n## Security announcements\n\nThere is a Security [category](https://grafana.com/tags/security/) on the Grafana blog where we will post a summary, remediation, and mitigation details for any patch containing security fixes and you can subscribe to updates from our [Security Announcements RSS feed](https://grafana.com/tags/security/index.xml).",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "@grafana/data"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "8.0.0"
}, {
"fixed" : "8.2.3"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/grafana/grafana/security/advisories/GHSA-3j9m-hcv9-rpj8"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-41174"
}, {
"type" : "WEB",
"url" : "https://github.com/grafana/grafana/commit/31b78d51c693d828720a5b285107a50e6024c912"
}, {
"type" : "WEB",
"url" : "https://github.com/grafana/grafana/commit/3cb5214fa45eb5a571fd70d6c6edf0d729983f82"
}, {
"type" : "WEB",
"url" : "https://github.com/grafana/grafana/commit/fb85ed691290d211a5baa44d9a641ab137f0de88"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/grafana/grafana"
}, {
"type" : "WEB",
"url" : "https://security.netapp.com/advisory/ntap-20211125-0003"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-79" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2021-11-03T18:18:08Z",
"nvd_published_at" : "2021-11-03T18:15:00Z"
}
}