GitHub Advisoryadvisory · npm

GHSA-gc7p-j5xm-xxh2 Unauthorized Access to Private Fields in User Registration API

HIGH Published 2023-11-03 Modified 2023-11-06 Official page ↗
Aliases
CVE-2023-39345
Ecosystem
npm
Packages
@strapi/plugin-users-permissions, @strapi/strapi
Severity
High
CVSS vector
CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:L
Weaknesses
CWE-287
Reviewed
2023-11-03

Affected packages

• npm @strapi/plugin-users-permissions: >= 4.0.0, < 4.13.1 → fixed in 4.13.1 • npm @strapi/strapi: >= 4.0.0, < 4.13.1 → fixed in 4.13.1

Description

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. 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; ```

Related

Alias · CVE (1)

Weakness · CWE (1)

  • CWE-287 Improper Authentication weakness

References