CVE-2024-54152: Angular expressions Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-5462-4vcx-jh7j
CWE-94
Published
Advisory Summary

CVE-2024-54152 is a CRITICAL 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 when using locals. Remediation is available by upgrading affected packages to version 1.4.3.

CVE-2024-54152 at a Glance

CVE Identifier CVE-2024-54152
GHSA Identifier GHSA-5462-4vcx-jh7j
Severity CRITICAL
CVSS v3.1 Base Score N/A
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Angular expressions
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2024-54152

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.4.3
npm install angular-expressions@1.4.3
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-2024-54152, 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.4.3), 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

### Impact An attacker can write a malicious expression that escapes the sandbox to execute arbitrary code on the system. Example of vulnerable code: ```js const expressions = require("angular-expressions"); const result = expressions.compile("__proto__.constructor")({}, {}); // result should be undefined, however for versions <=1.4.2, it returns an object. ``` With a more complex (undisclosed) payload, one can get full access to Arbitrary code execution on the system. ### Patches The problem has been patched in version 1.4.3 of angular-expressions. ### Workarounds There is one workaround if it not possible for you to update : * Make sure that you use the compiled function with just one argument : ie this is not vulnerable : `const result = expressions.compile("__proto__.constructor")({});` : in this case you lose the feature of locals if you need it. ### Credits Credits go to [JorianWoltjer](https://github.com/JorianWoltjer) who has found the issue and reported it to use. https://jorianwoltjer.com/

CVE-2024-54152 Affected Angular expressions Versions

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

References

Frequently Asked Questions

What is CVE-2024-54152?
CVE-2024-54152 is a security vulnerability in Angular expressions involving Angular Expressions - Remote Code Execution when using locals under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Angular expressions versions are affected?
Affected versions include releases prior to 1.4.3 across affected packages: angular-expressions.
What version fixes CVE-2024-54152?
Upgrading to 1.4.3 (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.4.3. Upgrade your dependency to 1.4.3 or later.
What CWE is associated with CVE-2024-54152?
CVE-2024-54152 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (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.).
How can I check npm dependencies for CVE-2024-54152?
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-5462-4vcx-jh7j",
  "modified" : "2024-12-10T20:59:46Z",
  "published" : "2024-12-10T16:54:50Z",
  "aliases" : [ "CVE-2024-54152" ],
  "summary" : "Angular Expressions - Remote Code Execution when using locals",
  "details" : "### Impact\n\nAn attacker can write a malicious expression that escapes the sandbox to execute arbitrary code on the system.\n\nExample of vulnerable code:\n\n```js\nconst expressions = require(\"angular-expressions\");\nconst result = expressions.compile(\"__proto__.constructor\")({}, {});\n// result should be undefined, however for versions <=1.4.2, it returns an object.\n```\n\nWith a more complex (undisclosed) payload, one can get full access to Arbitrary code execution on the system.\n\n### Patches\n\nThe problem has been patched in version 1.4.3 of angular-expressions.\n\n### Workarounds\n\nThere is one workaround if it not possible for you to update : \n\n* Make sure that you use the compiled function with just one argument : ie this is not vulnerable : \n    `const result = expressions.compile(\"__proto__.constructor\")({});` : in this case you lose the feature of locals if you need it.\n\n### Credits\n\nCredits go to [JorianWoltjer](https://github.com/JorianWoltjer) who has found the issue and reported it to use. https://jorianwoltjer.com/",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "angular-expressions"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.4.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/peerigon/angular-expressions/security/advisories/GHSA-5462-4vcx-jh7j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-54152"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/peerigon/angular-expressions/commit/97f7ad94006156eeb97fc942332578b6cfbf8eef"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/peerigon/angular-expressions"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-12-10T16:54:50Z",
    "nvd_published_at" : "2024-12-10T16:15:23Z"
  }
}