# GHSA-m9hw-7xfv-wqg7: Prototype Pollution in json-logic-js

> Prototype pollution in json-logic-js allows attackers to inject code via malicious rules, leading to remote code execution.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 12 Nov 2020

## What is GHSA-m9hw-7xfv-wqg7?

GHSA-m9hw-7xfv-wqg7 is a code injection vulnerability in json-logic-js, published on 12 Nov 2020. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Versions of json-logic-js prior to 2.0.0 are vulnerable to Prototype Pollution. The method operation allows a malicious user to modify the prototype of Object through the method property name. This causes modification of any existing property that will exist on all objects and leads to Remote Code Execution.

The following rule creates a popup when run from a browser:
```
{
  "method": [
    {
      "method": [
        {
          "var": "__proto__.constructor.is.__proto__"
        },
        "constructor",
        [
          "var x = 'SECURITY!'; console.log(x, window.fetch); alert(x)"
        ]
      ]
    },
    "call"
  ]
}
```

## Which versions are affected by GHSA-m9hw-7xfv-wqg7?

2 open source packages ship an affected version, including json-logic-js.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `json-logic-js` | npm | All versions | 2.0.0 |
| `json-logic-js` | npm | All versions | 2.0.0 |

## How do I fix GHSA-m9hw-7xfv-wqg7?

Upgrade json-logic-js to 2.0.0 or later.

## Is GHSA-m9hw-7xfv-wqg7 being exploited?

There is no known exploitation of GHSA-m9hw-7xfv-wqg7 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-m9hw-7xfv-wqg7 and fix it if it is affected.

What it is: GHSA-m9hw-7xfv-wqg7 is a code injection vulnerability in json-logic-js, published on 12 Nov 2020. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-m9hw-7xfv-wqg7 in the wild and no public exploit code.

Affected packages and fixed versions:
- json-logic-js (npm): affected all versions; fixed in 2.0.0
- json-logic-js (npm): affected all versions; fixed in 2.0.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-m9hw-7xfv-wqg7/ (Markdown: https://insights.sbomify.com/GHSA-m9hw-7xfv-wqg7/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-m9hw-7xfv-wqg7

---
From sbomify Insights: https://insights.sbomify.com/GHSA-m9hw-7xfv-wqg7/
Summaries are generated and may contain mistakes; the official description above is the record.
