CVE-2023-39345: @strapi/plugin users permissions Unauthorized Access To Private Fields Vulnerability

HIGH
Advisory Identifier: GHSA-gc7p-j5xm-xxh2
CVSS 7.6
CWE-287
Published
Advisory Summary

CVE-2023-39345 is a HIGH (CVSS 7.6) unauthorized access to private fields vulnerability (CWE-287: Improper Authentication) affecting @strapi/plugin users permissions libraries in the npm ecosystem. The issue involves unauthorized access to private fields in user registration api. Remediation is available by upgrading affected packages to version 4.13.1.

CVE-2023-39345 at a Glance

CVE Identifier CVE-2023-39345
GHSA Identifier GHSA-gc7p-j5xm-xxh2
Severity HIGH
CVSS v3.1 Base Score 7.6
CWE Classification CWE-287: Improper Authentication
Affected Product @strapi/plugin users permissions
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.6

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

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

How to Fix CVE-2023-39345

To remediate this vulnerability, upgrade all affected @strapi/plugin users permissions dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@strapi/plugin-users-permissions fixed: 4.13.1
npm install @strapi/plugin-users-permissions@4.13.1
@strapi/strapi fixed: 4.13.1
npm install @strapi/strapi@4.13.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 @strapi/plugin-users-permissions

How to Check if You Are Affected

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

npm ls @strapi/plugin-users-permissions

Analyze the terminal output to locate any version of @strapi/plugin users permissions in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.13.1), your application is affected.

Note: The npm ls @strapi/plugin-users-permissions 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-287: Improper Authentication, where when an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct. In @strapi/plugin users permissions, 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

### System Details | Name | Value | |----------|------------------------| | OS | Windows 11 | | Version | 4.11.1 (node v16.14.2) | | Database | mysql | ### Description I marked some fields as private fields in user content-type, and tried to register as a new user via api, at the same time I added content to fill the private fields and sent a post request, and as you can see from the images below, I can write to the private fields. ![register](https://user-images.githubusercontent.com/32245914/246987508-9337ffd5-c681-4f51-9a0b-2490b424ca1e.png) ![user](https://user-images.githubusercontent.com/32245914/246987564-9f440b3f-a7a3-4710-9b75-0854667fc35d.png) ![private_field](https://user-images.githubusercontent.com/32245914/246987590-9c0ecefd-fd64-4221-b642-e730ea55d440.png) ![table](https://user-images.githubusercontent.com/32245914/246987604-009e6808-5690-458e-aa87-57dda7d4589d.png) To prevent this, I went to the extension area and tried to extend the register method, for this I wanted to do it using the sanitizeInput function that I know in the source codes of the strap. But the sanitizeInput function did not filter out private fields. ```js const { auth } = ctx.state; const data = ctx.request.body; const userSchema = strapi.getModel("plugin::users-permissions.user"); sanitize.contentAPI.input(data, userSchema, { auth }); ``` here's the solution I've temporarily kept to myself, code snippet ```js const body = ctx.request.body; const { attributes } = strapi.getModel("plugin::users-permissions.user"); const sanitizedData = _.omitBy(body, (data, key) => { const attribute = attributes[key]; if (_.isNil(attribute)) { return false; } //? If you want, you can throw an error for fields that we did not expect. // if (_.isNil(attribute)) // throw new ApplicationError(`Unexpected value ${key}`); // if private value is true, we do not want to send it to the database. return attribute.private; }); return sanitizedData; ```

CVE-2023-39345 Affected @strapi/plugin users permissions Versions

2 component(s)
Fixed Versions:
4.13.1
Product / Package Ecosystem Affected Versions Fixed Version
@strapi/plugin-users-permissions
npm
≥ 4.0.0
< 4.13.1
4.13.1
@strapi/strapi
npm
≥ 4.0.0
< 4.13.1
4.13.1

References

Frequently Asked Questions

What is CVE-2023-39345?
CVE-2023-39345 is a security vulnerability in @strapi/plugin users permissions involving Unauthorized Access to Private Fields in User Registration API under CWE-287: Improper Authentication.
Which @strapi/plugin users permissions versions are affected?
Affected versions include releases prior to 4.13.1 across affected packages: @strapi/plugin-users-permissions, @strapi/strapi.
What version fixes CVE-2023-39345?
Upgrading to 4.13.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @strapi/plugin-users-permissions affected?
Yes, @strapi/plugin-users-permissions is affected in releases prior to 4.13.1. Upgrade your dependency to 4.13.1 or later.
Is @strapi/strapi affected?
Yes, @strapi/strapi is affected in releases prior to 4.13.1. Upgrade your dependency to 4.13.1 or later.
What is the CVSS score of CVE-2023-39345?
CVE-2023-39345 has a CVSS v3.1 base score of 7.6 (HIGH) with vector string CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:L.
What CWE is associated with CVE-2023-39345?
CVE-2023-39345 is classified under CWE-287: Improper Authentication (When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.).
How can I check npm dependencies for CVE-2023-39345?
Run the dependency tree command: 'npm ls @strapi/plugin-users-permissions'. 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-gc7p-j5xm-xxh2",
  "modified" : "2023-11-06T21:58:57Z",
  "published" : "2023-11-03T19:01:11Z",
  "aliases" : [ "CVE-2023-39345" ],
  "summary" : "Unauthorized Access to Private Fields in User Registration API",
  "details" : "### System Details\n| Name     | Value                  |\n|----------|------------------------|\n| OS       | Windows 11             |\n| Version  | 4.11.1 (node v16.14.2) |\n| Database | mysql                  |\n\n\n### Description\nI marked some fields as private fields in user content-type, and tried to register as a new user via api, at the same time I added content to fill the private fields and sent a post request, and as you can see from the images below, I can write to the private fields.\n\n![register](https://user-images.githubusercontent.com/32245914/246987508-9337ffd5-c681-4f51-9a0b-2490b424ca1e.png)\n\n![user](https://user-images.githubusercontent.com/32245914/246987564-9f440b3f-a7a3-4710-9b75-0854667fc35d.png)\n\n![private_field](https://user-images.githubusercontent.com/32245914/246987590-9c0ecefd-fd64-4221-b642-e730ea55d440.png)\n\n![table](https://user-images.githubusercontent.com/32245914/246987604-009e6808-5690-458e-aa87-57dda7d4589d.png)\n\nTo prevent this, I went to the extension area and tried to extend the register method, for this I wanted to do it using the sanitizeInput function that I know in the source codes of the strap. But the sanitizeInput function did not filter out private fields.\n\n```js\n  const { auth } = ctx.state;\n  const data = ctx.request.body;\n  const userSchema = strapi.getModel(\"plugin::users-permissions.user\");\n\n  sanitize.contentAPI.input(data, userSchema, { auth });\n```\n\nhere's the solution I've temporarily kept to myself, code snippet\n\n```js\n  const body = ctx.request.body;\n\n  const { attributes } = strapi.getModel(\"plugin::users-permissions.user\");\n\n  const sanitizedData = _.omitBy(body, (data, key) => {\n    const attribute = attributes[key];\n\n    if (_.isNil(attribute)) {\n      return false;\n    }\n\n    //? If you want, you can throw an error for fields that we did not expect.\n\n    // if (_.isNil(attribute))\n    //   throw new ApplicationError(`Unexpected value ${key}`);\n\n    // if private value is true, we do not want to send it to the database.\n    return attribute.private;\n  });\n\n  return sanitizedData;\n```\n\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@strapi/plugin-users-permissions"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.13.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@strapi/strapi"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.13.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/strapi/strapi/security/advisories/GHSA-gc7p-j5xm-xxh2"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-39345"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/strapi/strapi"
  }, {
    "type" : "WEB",
    "url" : "https://strapi.io/blog/security-disclosure-of-vulnerabilities-sept-2023"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-287" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-11-03T19:01:11Z",
    "nvd_published_at" : "2023-11-06T19:15:09Z"
  }
}