CVE-2022-35942: Loopback connector postgresql Loopback-connector-postgresql Vulnerable To Improper Sanitization Vulnerability

CRITICAL
Advisory Identifier: GHSA-j259-6c58-9m58
CVSS 9.3
CWE-89 CWE-20
Published
Advisory Summary

CVE-2022-35942 is a CRITICAL (CVSS 9.3) loopback-connector-postgresql vulnerable to improper sanitization vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Loopback connector postgresql libraries in the npm ecosystem. The issue involves loopback-connector-postgresql vulnerable to improper sanitization of `contains` filter. Remediation is available by upgrading affected packages to version 5.5.1.

CVE-2022-35942 at a Glance

CVE Identifier CVE-2022-35942
GHSA Identifier GHSA-j259-6c58-9m58
Severity CRITICAL
CVSS v3.1 Base Score 9.3
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Loopback connector postgresql
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H).

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

How to Fix CVE-2022-35942

To remediate this vulnerability, upgrade all affected Loopback connector postgresql dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

loopback-connector-postgresql fixed: 5.5.1
npm install loopback-connector-postgresql@5.5.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 loopback-connector-postgresql

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2022-35942, inspect your project dependencies using npm:

npm ls loopback-connector-postgresql

Analyze the terminal output to locate any version of Loopback connector postgresql in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.5.1), your application is affected.

Note: The npm ls loopback-connector-postgresql 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-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Loopback connector postgresql, 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

Improper input validation on the `contains` LoopBack filter may allow for arbitrary SQL injection. ### Impact 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. 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. ### Patches Patch release `loopback-connector-postgresql@5.5.1` has been published of which resolves this issue. ### Workarounds 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.

CVE-2022-35942 Affected Loopback connector postgresql Versions

1 component(s)
Fixed Versions:
5.5.1
Product / Package Ecosystem Affected Versions Fixed Version
loopback-connector-postgresql
npm
< 5.5.1
5.5.1

References

Frequently Asked Questions

What is CVE-2022-35942?
CVE-2022-35942 is a security vulnerability in Loopback connector postgresql involving loopback-connector-postgresql Vulnerable to Improper Sanitization of `contains` Filter under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Loopback connector postgresql versions are affected?
Affected versions include releases prior to 5.5.1 across affected packages: loopback-connector-postgresql.
What version fixes CVE-2022-35942?
Upgrading to 5.5.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is loopback-connector-postgresql affected?
Yes, loopback-connector-postgresql is affected in releases prior to 5.5.1. Upgrade your dependency to 5.5.1 or later.
What is the CVSS score of CVE-2022-35942?
CVE-2022-35942 has a CVSS v3.1 base score of 9.3 (CRITICAL) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2022-35942?
CVE-2022-35942 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check npm dependencies for CVE-2022-35942?
Run the dependency tree command: 'npm ls loopback-connector-postgresql'. 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-j259-6c58-9m58",
  "modified" : "2022-08-11T21:13:43Z",
  "published" : "2022-08-11T21:13:43Z",
  "aliases" : [ "CVE-2022-35942" ],
  "summary" : "loopback-connector-postgresql Vulnerable to Improper Sanitization of `contains` Filter",
  "details" : "Improper input validation on the `contains` LoopBack filter may allow for arbitrary SQL injection.\n\n### Impact\n\nWhen 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.\n\nThis affects users who does any of the following:\n\n- Connect to the database via the DataSource with `allowExtendedProperties: true` setting OR\n- Uses the connector's CRUD methods directly OR\n- Uses the connector's other methods to interpret the LoopBack filter.\n\n### Patches\n\nPatch release `loopback-connector-postgresql@5.5.1` has been published of which resolves this issue.\n\n### Workarounds\n\nUsers who are unable to upgrade should do the following if applicable:\n\n- Remove `allowExtendedProperties: true` DataSource setting\n- Add `allowExtendedProperties: false` DataSource setting\n- When passing directly to the connector functions, manually sanitize the user input for the `contains` LoopBack filter beforehand.\n\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "loopback-connector-postgresql"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.5.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/loopbackio/loopback-connector-postgresql/security/advisories/GHSA-j259-6c58-9m58"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-35942"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/loopbackio/loopback-connector-postgresql/commit/d57406c6737692a3a106b58a35406290cddb23e5"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/loopbackio/loopback-connector-postgresql"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20", "CWE-89" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-08-11T21:13:43Z",
    "nvd_published_at" : "2022-08-12T23:15:00Z"
  }
}