Vulnerabilities in pkg:npm/@strapi/plugin-email

PACKAGE
Advisory Identifier: GHSA-2h87-4q2w-v4hf
Advisory Summary

CVE-2023-22621 is a CRITICAL (CVSS 10.0) remote code execution vulnerability (CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')) affecting @strapi/plugin users permissions libraries in the npm ecosystem. The issue involves strapi plugins vulnerable to server-side template injection and remote code execution in the users-permissions plugin. Remediation is available by upgrading affected packages to version 4.5.6.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/@strapi/plugin-email

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/@strapi/plugin-email. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-2h87-4q2w-v4hf CVE-2023-22621 CRITICAL Strapi plugins vulnerable to Server-Side Template Injection and Remote Code Execution in the Users-Permissions Plugin

CVE-2023-22621 at a Glance

CVE Identifier CVE-2023-22621
GHSA Identifier GHSA-2h87-4q2w-v4hf
Severity CRITICAL
CVSS v3.1 Base Score 10.0
CWE Classification CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
Affected Product @strapi/plugin users permissions
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 10.0

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

Attack Vector Network (AV:N)
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-2023-22621

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.5.6
npm install @strapi/plugin-users-permissions@4.5.6
@strapi/plugin-email fixed: 4.5.6
npm install @strapi/plugin-email@4.5.6
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-22621, 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.5.6), 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-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection'), where the product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component. 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

### Summary Strapi through 4.5.5 allows authenticated Server-Side Template Injection (SSTI) that can be exploited to execute arbitrary code on the server. ### Details Strapi through 4.5.5 allows authenticated Server-Side Template Injection (SSTI) that can be exploited to execute arbitrary code on the server. A remote attacker with access to the Strapi admin panel can inject a crafted payload that executes code on the server into an email template that bypasses the validation checks that should prevent code execution. ### IoC Using just the request log files, the only IoC to search for is a `PUT` request to URL path `/users-permissions/email-templates`. This IoC only indicates that a Strapi email template was modified on your server and by itself does not indicate if your Strapi server has been compromised. If this IoC is detected, you will need to manually review your email templates on your Strapi server and backups of your database to see if any of the templates contain a `lodash` template delimiter (eg. `<%STUFF HERE%>`) that contains suspicious JavaScript code. Generally speaking these templates should look like the following, you may have minor adjustments but any unrecognized code should be considered suspicious. Reset Password Template: ```html <p>We heard that you lost your password. Sorry about that!</p> <p>But don’t worry! You can use the following link to reset your password:</p> <p><%= URL %>?code=<%= TOKEN %></p> <p>Thanks.</p> ``` Email Confirmation Template: ```html <p>Thank you for registering!</p> <p>You have to confirm your email address. Please click on the link below.</p> <p><%= URL %>?confirmation=<%= CODE %></p> <p>Thanks.</p> ``` Specifically you should look for odd code contained within the `<%STUFF HERE%>` blocks as this is what is used to bypass the lodash templating system. If you find any code that is not a variable name, or a variable name that is not defined in the template you are most likely impacted and should take immediate steps to confirm there are no malicious applications running on your servers. ### Impact All users on Strapi below 4.5.6 with access to the admin panel and the ability to modify the email templates

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

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

References

Frequently Asked Questions

What is CVE-2023-22621?
CVE-2023-22621 is a security vulnerability in @strapi/plugin users permissions involving Strapi plugins vulnerable to Server-Side Template Injection and Remote Code Execution in the Users-Permissions Plugin under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection').
Which @strapi/plugin users permissions versions are affected?
Affected versions include releases prior to 4.5.6 across affected packages: @strapi/plugin-users-permissions, @strapi/plugin-email.
What version fixes CVE-2023-22621?
Upgrading to 4.5.6 (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.5.6. Upgrade your dependency to 4.5.6 or later.
Is @strapi/plugin-email affected?
Yes, @strapi/plugin-email is affected in releases prior to 4.5.6. Upgrade your dependency to 4.5.6 or later.
What is the CVSS score of CVE-2023-22621?
CVE-2023-22621 has a CVSS v3.1 base score of 10.0 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2023-22621?
CVE-2023-22621 is classified under CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection') (The product constructs all or part of a command, data structure, or record using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify how it is parsed or interpreted when it is sent to a downstream component.).
How can I check npm dependencies for CVE-2023-22621?
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-2h87-4q2w-v4hf",
  "modified" : "2023-05-01T18:34:55Z",
  "published" : "2023-04-19T21:41:30Z",
  "aliases" : [ "CVE-2023-22621" ],
  "summary" : "Strapi plugins vulnerable to Server-Side Template Injection and Remote Code Execution in the Users-Permissions Plugin",
  "details" : "### Summary\n\nStrapi through 4.5.5 allows authenticated Server-Side Template Injection (SSTI) that can be exploited to execute arbitrary code on the server.\n\n### Details\n\nStrapi through 4.5.5 allows authenticated Server-Side Template Injection (SSTI) that can be exploited to execute arbitrary code on the server. A remote attacker with access to the Strapi admin panel can inject a crafted payload that executes code on the server into an email template that bypasses the validation checks that should prevent code execution.\n\n### IoC\n\nUsing just the request log files, the only IoC to search for is a `PUT` request to URL path `/users-permissions/email-templates`. This IoC only indicates that a Strapi email template was modified on your server and by itself does not indicate if your Strapi server has been compromised. If this IoC is detected, you will need to manually review your email templates on your Strapi server and backups of your database to see if any of the templates contain a `lodash` template delimiter (eg. `<%STUFF HERE%>`) that contains suspicious JavaScript code. Generally speaking these templates should look like the following, you may have minor adjustments but any unrecognized code should be considered suspicious.\n\nReset Password Template:\n\n```html\n<p>We heard that you lost your password. Sorry about that!</p>\n\n<p>But don’t worry! You can use the following link to reset your password:</p>\n<p><%= URL %>?code=<%= TOKEN %></p>\n\n<p>Thanks.</p>\n```\n\nEmail Confirmation Template:\n\n```html\n<p>Thank you for registering!</p>\n\n<p>You have to confirm your email address. Please click on the link below.</p>\n\n<p><%= URL %>?confirmation=<%= CODE %></p>\n\n<p>Thanks.</p>\n```\n\nSpecifically you should look for odd code contained within the `<%STUFF HERE%>` blocks as this is what is used to bypass the lodash templating system. If you find any code that is not a variable name, or a variable name that is not defined in the template you are most likely impacted and should take immediate steps to confirm there are no malicious applications running on your servers.\n\n### Impact\n\nAll users on Strapi below 4.5.6 with access to the admin panel and the ability to modify the email templates\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@strapi/plugin-users-permissions"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.5.6"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@strapi/plugin-email"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.5.6"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/strapi/strapi/security/advisories/GHSA-2h87-4q2w-v4hf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-22621"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/strapi/strapi/pull/15385"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/strapi/strapi/commit/921d30961d6ba96cc098f2aea197350a49f990bd"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/strapi/strapi"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/strapi/strapi/releases"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/strapi/strapi/releases/tag/v4.5.6"
  }, {
    "type" : "WEB",
    "url" : "https://strapi.io/blog/security-disclosure-of-vulnerabilities-cve"
  }, {
    "type" : "WEB",
    "url" : "https://www.ghostccamm.com/blog/multi_strapi_vulns"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-74" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-04-19T21:41:30Z",
    "nvd_published_at" : "2023-04-19T16:15:07Z"
  }
}