CVE-2022-25277: Drupal/core Drupal Core Arbitrary PHP Code Vulnerability

HIGH
Advisory Identifier: GHSA-6955-67hm-vjjq
CVSS 7.2
CWE-434
Published
Advisory Summary

CVE-2022-25277 is a HIGH (CVSS 7.2) drupal core arbitrary php code vulnerability (CWE-434: Unrestricted Upload of File with Dangerous Type) affecting Drupal/core libraries in the Packagist ecosystem. The issue involves drupal core arbitrary php code execution. Remediation is available by upgrading affected packages to version 9.3.19, 9.4.3.

CVE-2022-25277 at a Glance

CVE Identifier CVE-2022-25277
GHSA Identifier GHSA-6955-67hm-vjjq
Severity HIGH
CVSS v3.1 Base Score 7.2
CWE Classification CWE-434: Unrestricted Upload of File with Dangerous Type
Affected Product Drupal/core
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 7.2

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

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

How to Fix CVE-2022-25277

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

drupal/core fixed: 9.3.19
Upgrade drupal/core to 9.3.19
drupal/core fixed: 9.4.3
Upgrade drupal/core to 9.4.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for drupal/core

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-25277, inspect your project dependencies for Drupal/core:

inspect dependencies for drupal/core

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

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & RFC 5280 Specification

Under RFC 5280 specifications for X.509 certificates, the Name Constraints extension defines a namespace within which all subsequent subject names in a certification path must be located. Constraints apply to various name forms including directory names, IP addresses, rfc822Name (email addresses), and uniformResourceIdentifier (URI) entries. Specifically, during certificate path validation, affected versions of Drupal/core failed to properly normalize or enforce boundary checks when domain names contained trailing dot (.) characters. Because domain names with a trailing dot signify fully qualified domain names (FQDNs), this omission allowed non-conforming certificates to be improperly validated as compliant with the defined name constraints.

Source Advisory Statement

Drupal core sanitizes filenames with dangerous extensions upon upload and strips leading and trailing dots from filenames to prevent uploading server configuration files. However, the protections for these two vulnerabilities previously did not work correctly together. As a result, if the site were configured to allow the upload of files with an htaccess extension, these files' filenames would not be properly sanitized. This could allow bypassing the protections provided by Drupal core's default .htaccess files and possible remote code execution on Apache web servers. This issue is mitigated by the fact that it requires a field administrator to explicitly configure a file field to allow htaccess as an extension (a restricted permission), or a contributed module or custom code that overrides allowed file uploads.

CVE-2022-25277 Affected Drupal/core Versions

2 component(s)
Fixed Versions:
9.3.199.4.3
Product / Package Ecosystem Affected Versions Fixed Version
drupal/core
Packagist
≥ 8.0.0
< 9.3.19
9.3.19
drupal/core
Packagist
≥ 9.4.0
< 9.4.3
9.4.3

References

Frequently Asked Questions

What is CVE-2022-25277?
CVE-2022-25277 is a security vulnerability in Drupal/core involving Drupal core arbitrary PHP code execution under CWE-434: Unrestricted Upload of File with Dangerous Type.
Which Drupal/core versions are affected?
Affected versions include releases prior to 9.3.19, 9.4.3 across affected packages: drupal/core.
What version fixes CVE-2022-25277?
Upgrading to 9.3.19, 9.4.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is drupal/core affected?
Yes, drupal/core is affected in releases prior to 9.3.19, 9.4.3. Upgrade your dependency to 9.3.19, 9.4.3 or later.
What is the CVSS score of CVE-2022-25277?
CVE-2022-25277 has a CVSS v3.1 base score of 7.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2022-25277?
CVE-2022-25277 is classified under CWE-434: Unrestricted Upload of File with Dangerous Type (The product allows the upload or transfer of dangerous file types that are automatically processed within its environment.).
How can I check Packagist dependencies for CVE-2022-25277?
Run the dependency tree command: 'inspect dependencies for drupal/core'. 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-6955-67hm-vjjq",
  "modified" : "2023-05-10T00:36:31Z",
  "published" : "2022-08-06T09:33:38Z",
  "aliases" : [ "CVE-2022-25277" ],
  "summary" : "Drupal core arbitrary PHP code execution",
  "details" : "Drupal core sanitizes filenames with dangerous extensions upon upload and strips leading and trailing dots from filenames to prevent uploading server configuration files.\n\nHowever, the protections for these two vulnerabilities previously did not work correctly together. As a result, if the site were configured to allow the upload of files with an htaccess extension, these files' filenames would not be properly sanitized. This could allow bypassing the protections provided by Drupal core's default .htaccess files and possible remote code execution on Apache web servers.\n\nThis issue is mitigated by the fact that it requires a field administrator to explicitly configure a file field to allow htaccess as an extension (a restricted permission), or a contributed module or custom code that overrides allowed file uploads.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "drupal/core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "8.0.0"
      }, {
        "fixed" : "9.3.19"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "drupal/core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "9.4.0"
      }, {
        "fixed" : "9.4.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-25277"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/drupal/core/commit/1cd1830d79f221cc8490f53c2bb487dd07094f17"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/drupal/core/commit/5d464ea4407c50e40dcf6cb5ee376e7b8dd36f3a"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/drupal/core/CVE-2022-25277.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/drupal/core"
  }, {
    "type" : "WEB",
    "url" : "https://www.drupal.org/sa-core-2022-014"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-434" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-08-06T09:33:38Z",
    "nvd_published_at" : "2023-04-26T15:15:08Z"
  }
}