CVE-2026-50281: Craftcms/cms Craft CMS's Mass Assignment Vulnerability

HIGH
Advisory Identifier: GHSA-x5m4-g2cq-52pq
CWE-915
Published
Advisory Summary

CVE-2026-50281 is a HIGH craft cms's mass assignment vulnerability (CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes) affecting Craftcms/cms libraries in the Packagist ecosystem. The issue involves craft cms's mass assignment via id in newattributes during bulk duplicate overwrites existing elements. Remediation is available by upgrading affected packages to version 5.9.21.

CVE-2026-50281 at a Glance

CVE Identifier CVE-2026-50281
GHSA Identifier GHSA-x5m4-g2cq-52pq
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes
Affected Product Craftcms/cms
Package Ecosystem Packagist
Published Date
Last Updated

How to Fix CVE-2026-50281

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

craftcms/cms fixed: 5.9.21
Upgrade craftcms/cms to 5.9.21
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 craftcms/cms

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-50281, inspect your project dependencies for Craftcms/cms:

inspect dependencies for craftcms/cms

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

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

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes, where the product receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified. In Craftcms/cms, 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 There is a mass-assignment flaw in the bulk-duplicate element action. Alice, holding only the permission to duplicate an entry she owns, submits an arbitrary `id` through the `newAttributes` request parameter. The duplication routine overrides its own `id = null` reset with that value and writes Alice’s attributes into Bob’s existing entry row. ## Details `ElementsController::beforeAction()` (`src/controllers/ElementsController.php:119-124`) pulls the request body into `$this->_attributes` and rejects requests that ship an `id` or `canonicalId` key at the top level: ```php $this->_attributes = $this->request->getBodyParams(); // No funny business if (isset($this->_attributes['id']) || isset($this->_attributes['canonicalId'])) { throw new BadRequestHttpException('Changing an element’s ID is not allowed.'); } ``` The check inspects only the top-level payload. `actionBulkDuplicate()` (`src/controllers/ElementsController.php:1708-1749`) reads a separate `newAttributes` array and passes it straight through to the service layer: ```php $elementInfo = $this->request->getRequiredBodyParam('elements'); $newAttributes = $this->request->getRequiredBodyParam('newAttributes'); ... $safeNewAttributes = Collection::make($newAttributes) ->only($element->safeAttributes()) ->all(); ... $newElement = $elementsService->duplicateElement( $element, $safeNewAttributes + $element::baseBulkDuplicateAttributes(), false, checkAuthorization: true, ); ``` `Elements::duplicateElement()` (`src/services/Elements.php:1814-1840`) clones the source element, sets `id` to null, and then hands the attacker's array to `Craft::configure()`: ```php $mainClone = clone $element; $mainClone->id = null; $mainClone->uid = StringHelper::UUID(); ... Craft::configure($mainClone, ArrayHelper::merge( $newAttributes, $siteAttributes[$mainClone->siteId] ?? [], )); ``` `Craft::configure()` overwrites the reset `id` with any numeric value inside `$newAttributes`. Yii's `saveElement()` then performs an UPDATE against the row with that primary key instead of an INSERT. Alice's title, slug, authorId, postDate, and UID land on Bob’s entry. `safeAttributes()` on `Entry` includes `id` because the base element model exposes it, so the `Collection::only()` filter does not strip it. ## Impact A low-privileged author overwrites any other element (entries, categories, users that share the Entry element table inheritance) by predicting or enumerating element IDs. Content integrity on the entire install breaks. The attack requires only the ability to duplicate one entry Alice already owns.

CVE-2026-50281 Affected Craftcms/cms Versions

1 component(s)
Fixed Versions:
5.9.21
Product / Package Ecosystem Affected Versions Fixed Version
craftcms/cms
Packagist
≥ 5.7.0
< 5.9.21
5.9.21

References

Frequently Asked Questions

What is CVE-2026-50281?
CVE-2026-50281 is a security vulnerability in Craftcms/cms involving Craft CMS's mass assignment via id in newAttributes during bulk duplicate overwrites existing elements under CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes.
Which Craftcms/cms versions are affected?
Affected versions include releases prior to 5.9.21 across affected packages: craftcms/cms.
What version fixes CVE-2026-50281?
Upgrading to 5.9.21 (or the latest patched release for your respective branch) resolves the vulnerability.
Is craftcms/cms affected?
Yes, craftcms/cms is affected in releases prior to 5.9.21. Upgrade your dependency to 5.9.21 or later.
What CWE is associated with CVE-2026-50281?
CVE-2026-50281 is classified under CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes (The product receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.).
How can I check Packagist dependencies for CVE-2026-50281?
Run the dependency tree command: 'inspect dependencies for craftcms/cms'. 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-x5m4-g2cq-52pq",
  "modified" : "2026-07-02T20:03:36Z",
  "published" : "2026-07-02T20:03:36Z",
  "aliases" : [ "CVE-2026-50281" ],
  "summary" : "Craft CMS's mass assignment via id in newAttributes during bulk duplicate overwrites existing elements",
  "details" : "## Summary\n\nThere is a mass-assignment flaw in the bulk-duplicate element action. Alice, holding only the permission to duplicate an entry she owns, submits an arbitrary `id` through the `newAttributes` request parameter. The duplication routine overrides its own `id = null` reset with that value and writes Alice’s attributes into Bob’s existing entry row.\n\n## Details\n\n`ElementsController::beforeAction()` (`src/controllers/ElementsController.php:119-124`) pulls the request body into `$this->_attributes` and rejects requests that ship an `id` or `canonicalId` key at the top level:\n\n```php\n$this->_attributes = $this->request->getBodyParams();\n\n// No funny business\nif (isset($this->_attributes['id']) || isset($this->_attributes['canonicalId'])) {\n    throw new BadRequestHttpException('Changing an element’s ID is not allowed.');\n}\n```\n\nThe check inspects only the top-level payload. `actionBulkDuplicate()` (`src/controllers/ElementsController.php:1708-1749`) reads a separate `newAttributes` array and passes it straight through to the service layer:\n\n```php\n$elementInfo = $this->request->getRequiredBodyParam('elements');\n$newAttributes = $this->request->getRequiredBodyParam('newAttributes');\n...\n$safeNewAttributes = Collection::make($newAttributes)\n    ->only($element->safeAttributes())\n    ->all();\n...\n$newElement = $elementsService->duplicateElement(\n    $element,\n    $safeNewAttributes + $element::baseBulkDuplicateAttributes(),\n    false,\n    checkAuthorization: true,\n);\n```\n\n`Elements::duplicateElement()` (`src/services/Elements.php:1814-1840`) clones the source element, sets `id` to null, and then hands the attacker's array to `Craft::configure()`:\n\n```php\n$mainClone = clone $element;\n$mainClone->id = null;\n$mainClone->uid = StringHelper::UUID();\n...\nCraft::configure($mainClone, ArrayHelper::merge(\n    $newAttributes,\n    $siteAttributes[$mainClone->siteId] ?? [],\n));\n```\n\n`Craft::configure()` overwrites the reset `id` with any numeric value inside `$newAttributes`. Yii's `saveElement()` then performs an UPDATE against the row with that primary key instead of an INSERT. Alice's title, slug, authorId, postDate, and UID land on Bob’s entry.\n\n`safeAttributes()` on `Entry` includes `id` because the base element model exposes it, so the `Collection::only()` filter does not strip it.\n\n## Impact\n\nA low-privileged author overwrites any other element (entries, categories, users that share the Entry element table inheritance) by predicting or enumerating element IDs. Content integrity on the entire install breaks. The attack requires only the ability to duplicate one entry Alice already owns.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "craftcms/cms"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.7.0"
      }, {
        "fixed" : "5.9.21"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/craftcms/cms/security/advisories/GHSA-x5m4-g2cq-52pq"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-50281"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/craftcms/cms/commit/8f6587c25050bbb6e080d59c71f6bb8932fc8600"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/craftcms/cms"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-915" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-02T20:03:36Z",
    "nvd_published_at" : "2026-07-02T17:17:00Z"
  }
}