CVE-2021-21277: Angular expressions Remote Code Execution Vulnerability
HIGHCVE-2021-21277 is a HIGH (CVSS 8.8) remote code execution vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Angular expressions libraries in the npm ecosystem. The issue involves angular expressions - remote code execution. Remediation is available by upgrading affected packages to version 1.1.2.
CVE-2021-21277 at a Glance
Security Impact
CVSS: 8.8
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:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2021-21277
To remediate this vulnerability, upgrade all affected Angular expressions 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 angular-expressions@1.1.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls angular-expressions
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-21277, inspect your project dependencies using npm:
npm ls angular-expressions
Analyze the terminal output to locate any version of Angular expressions in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.1.2), your application is affected.
Note: The npm ls angular-expressions 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-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Angular expressions, 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-21277 Affected Angular expressions Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
angular-expressions
|
npm |
< 1.1.2
|
1.1.2
|
References
Frequently Asked Questions
What is CVE-2021-21277?
Which Angular expressions versions are affected?
What version fixes CVE-2021-21277?
Is angular-expressions affected?
What is the CVSS score of CVE-2021-21277?
What CWE is associated with CVE-2021-21277?
How can I check npm dependencies for CVE-2021-21277?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-j6px-jwvv-vpwq",
"modified" : "2022-10-20T13:26:13Z",
"published" : "2021-02-01T15:01:26Z",
"aliases" : [ "CVE-2021-21277" ],
"summary" : "Angular Expressions - Remote Code Execution",
"details" : "### Impact\n\nThe vulnerability, reported by GoSecure Inc, allows Remote Code Execution, if you call `expressions.compile(userControlledInput)` where `userControlledInput` is text that comes from user input.\n\nThis time, the security of the package could be bypassed by using a more complex payload, using a `.constructor.constructor` technique.\n\n* If running angular-expressions in the browser, an attacker could run any browser script when the application code calls expressions.compile(userControlledInput).\n* If running angular-expressions on the server, an attacker could run any Javascript expression, thus gaining Remote Code Execution.\n\n### Patches\n\nUsers should upgrade to version 1.1.2 of angular-expressions\n\n### Workarounds\n\nA temporary workaround might be either to : \n\n* disable user-controlled input that will be fed into angular-expressions in your application\n\nOR\n\n* allow only following characters in the userControlledInput : \n\n```js\nif (/^[|a-zA-Z.0-9 :\"'+-?]+$/.test(userControlledInput)) {\n var result = expressions.compile(userControlledInput);\n}\nelse {\n result = undefined;\n}\n```\n\n### References\n\n[Removal of angular-expression sandbox](http://blog.angularjs.org/2016/09/angular-16-expression-sandbox-removal.html)\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n* Open an issue in [angular-expressions](https://github.com/peerigon/angular-expressions/issues)\n* [Email us](mailto:contact@javascript-ninja.fr)\n\n### Credits \n\nThe issue was reported by Maxime Nadeau from GoSecure, Inc.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "angular-expressions"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.1.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/peerigon/angular-expressions/security/advisories/GHSA-j6px-jwvv-vpwq"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-21277"
}, {
"type" : "WEB",
"url" : "https://github.com/peerigon/angular-expressions/commit/07edb62902b1f6127b3dcc013da61c6316dd0bf1"
}, {
"type" : "WEB",
"url" : "https://www.npmjs.com/package/angular-expressions"
}, {
"type" : "WEB",
"url" : "http://blog.angularjs.org/2016/09/angular-16-expression-sandbox-removal.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-74", "CWE-94" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2021-02-01T15:00:53Z",
"nvd_published_at" : "2021-02-01T15:15:00Z"
}
}