# CVE-2022-35942: loopback-connector-postgresql Vulnerable to Improper Sanitization of `contains` Filter

> Attackers can inject arbitrary SQL via the contains filter in loopback-connector-postgresql, compromising database confidentiality and integrity.

- **Severity:** Critical 9.3 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 12 Aug 2022
- **Updated:** 23 Apr 2025
- **Also known as:** GHSA-j259-6c58-9m58

## What is CVE-2022-35942?

CVE-2022-35942 is a critical SQL injection vulnerability in loopbackio loopback-connector-postgresql, published on 12 Aug 2022. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

Improper input validation on the `contains` LoopBack filter may allow for arbitrary SQL injection. When the extended filter property `contains` is permitted to be interpreted by the Postgres connector, it is possible to inject arbitrary SQL which may affect the confidentiality and integrity of data stored on the connected database. A patch was released in version 5.5.1. This affects users who does any of the following: - Connect to the database via the DataSource with `allowExtendedProperties: true` setting OR - Uses the connector's CRUD methods directly OR - Uses the connector's other methods to interpret the LoopBack filter. Users who are unable to upgrade should do the following if applicable: - Remove `allowExtendedProperties: true` DataSource setting - Add `allowExtendedProperties: false` DataSource setting - When passing directly to the connector functions, manually sanitize the user input for the `contains` LoopBack filter beforehand.

Weakness: CWE-89 (Improper Neutralization of Special Elements used in an SQL Command)

## Which versions are affected by CVE-2022-35942?

2 open source packages ship an affected version, including loopback-connector-postgresql. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `loopback-connector-postgresql` | npm | All versions | 5.5.1 |
| `loopback-connector-postgresql` | npm | All versions | 5.5.1 |

Products: Linuxfoundation Loopback-Connector-Postgresql.

## How do I fix CVE-2022-35942?

Upgrade loopback-connector-postgresql to 5.5.1 or later.

## Is CVE-2022-35942 being exploited?

There is no known exploitation of CVE-2022-35942 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2022-35942 and fix it if it is affected.

What it is: CVE-2022-35942 is a critical SQL injection vulnerability in loopbackio loopback-connector-postgresql, published on 12 Aug 2022. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2022-35942 in the wild and no public exploit code.

Affected packages and fixed versions:
- loopback-connector-postgresql (npm): affected all versions; fixed in 5.5.1
- loopback-connector-postgresql (npm): affected all versions; fixed in 5.5.1

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/CVE-2022-35942/ (Markdown: https://insights.sbomify.com/CVE-2022-35942/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2022-35942
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2022-35942
- OSV: https://osv.dev/vulnerability/CVE-2022-35942

---
From sbomify Insights: https://insights.sbomify.com/CVE-2022-35942/
Summaries are generated and may contain mistakes; the official description above is the record.
