CVE-2020-5219: Angular expressions Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-hxhm-96pp-2m43
CVSS 8.7
CWE-74
Published
Advisory Summary

CVE-2020-5219 is a HIGH (CVSS 8.7) remote code execution vulnerability (CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')) affecting Angular expressions libraries in the npm ecosystem. The issue involves remote code execution in angular expressions. Remediation is available by upgrading affected packages to version 1.0.1.

CVE-2020-5219 at a Glance

CVE Identifier CVE-2020-5219
GHSA Identifier GHSA-hxhm-96pp-2m43
Severity HIGH
CVSS v3.1 Base Score 8.7
CWE Classification CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
Affected Product Angular expressions
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.7

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:H/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2020-5219

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.

angular-expressions fixed: 1.0.1
npm install angular-expressions@1.0.1
Verify Direct and Transitive Dependencies

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-2020-5219, 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.0.1), 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-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection'), where the product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. 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

### Impact The vulnerability, reported by GoSecure Inc, allows Remote Code Execution, if you call `expressions.compile(userControlledInput)` where `userControlledInput` is text that comes from user input. * If running angular-expressions in the browser, an attacker could run any browser script when the application code calls expressions.compile(userControlledInput). * If running angular-expressions on the server, an attacker could run any Javascript expression, thus gaining Remote Code Execution. ### Patches Users should upgrade to version 1.0.1 of angular-expressions ### Workarounds A temporary workaround might be either to : * disable user-controlled input that will be fed into angular-expressions in your application OR * allow only following characters in the userControlledInput : ```js if (/^[|a-zA-Z.0-9 :"'+-?]+$/.test(userControlledInput)) { var result = expressions.compile(userControlledInput); } else { result = undefined; } ``` ### References [Removal of angular-expression sandbox](http://blog.angularjs.org/2016/09/angular-16-expression-sandbox-removal.html) ### For more information If you have any questions or comments about this advisory: * Open an issue in [angular-expressions](https://github.com/peerigon/angular-expressions/issues) * [Email us](mailto:contact@javascript-ninja.fr) ### Credits The issue was reported by Maxime Nadeau from GoSecure, Inc.

CVE-2020-5219 Affected Angular expressions Versions

1 component(s)
Fixed Versions:
1.0.1
Product / Package Ecosystem Affected Versions Fixed Version
angular-expressions
npm
< 1.0.1
1.0.1

References

Frequently Asked Questions

What is CVE-2020-5219?
CVE-2020-5219 is a security vulnerability in Angular expressions involving Remote Code Execution in Angular Expressions under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection').
Which Angular expressions versions are affected?
Affected versions include releases prior to 1.0.1 across affected packages: angular-expressions.
What version fixes CVE-2020-5219?
Upgrading to 1.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is angular-expressions affected?
Yes, angular-expressions is affected in releases prior to 1.0.1. Upgrade your dependency to 1.0.1 or later.
What is the CVSS score of CVE-2020-5219?
CVE-2020-5219 has a CVSS v3.1 base score of 8.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N.
What CWE is associated with CVE-2020-5219?
CVE-2020-5219 is classified under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') (The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.).
How can I check npm dependencies for CVE-2020-5219?
Run the dependency tree command: 'npm ls angular-expressions'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-hxhm-96pp-2m43",
  "modified" : "2021-01-08T20:33:38Z",
  "published" : "2020-01-24T15:27:25Z",
  "aliases" : [ "CVE-2020-5219" ],
  "summary" : "Remote Code Execution in Angular Expressions",
  "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\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.0.1 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:R/S:C/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "angular-expressions"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.0.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/peerigon/angular-expressions/security/advisories/GHSA-hxhm-96pp-2m43"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-5219"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/peerigon/angular-expressions/commit/061addfb9a9e932a970e5fcb913d020038e65667"
  }, {
    "type" : "WEB",
    "url" : "http://blog.angularjs.org/2016/09/angular-16-expression-sandbox-removal.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-74" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-01-24T15:27:04Z",
    "nvd_published_at" : null
  }
}