CVE-2026-50283
JSON

5.3medium

Craft CMS: Unauthorized Deletion of Source Assets During File Replacement

Severity
5.3medium CVSS:4.0 by GitHub_M
Exploit likelihood
0.36% (higher than 22% of CVEs)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-qh45-9g5p-m2v4

Description

Craft CMS is a content management system (CMS). Versions 5.0.0-RC1 through 5.9.20, and 4.0.0-RC1 through 4.17.13 contain an authorization issue in the AssetsController::actionReplaceFile that can delete a source asset without source delete permission by supplying both assetId and sourceAssetId. AssetsController::actionReplaceFile() supports replacing a target asset file using another existing asset as the source. The action loads: assetId -> $assetToReplace and sourceAssetId -> $sourceAsset, then enforces replace permissions using ($assetToReplace ?: $sourceAsset). When both IDs are provided, this expression resolves to the target asset so no permission check is performed against the source asset volume. When both assets are present, Craft copies the source file into the target and then deletes the source asset. There is no deletion check for for the source asset. An authenticated user who can replace files in one volume can delete assets in another volume where they do not have delete permission, as long as they can obtain a sourceAssetId, leading to broken content references and data loss. This issue has been fixed in versions 4.17.14 and 5.9.21.

Affected

Product or packageVersionsReported by
craftcms cms>= 5.0.0-RC1, < 5.9.21, >= 4.0.0-RC1, < 4.17.14CVE List
craftcms/cms (Packagist)from 5.0.0-RC1 before 5.9.21, from 4.0.0-RC1 before 4.17.14GitHub Advisory Database

All scores

GitHub_M5.3medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:L/VA:L/SC:N/SI:N/SA:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:N/VI:L/VA:L/SC:N/SI:N/SA:N

Classification

CWE-639CWE-862

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

Craft CMS is a content management system (CMS). Versions 5.0.0-RC1 through 5.9.20, and 4.0.0-RC1 through 4.17.13 contain an authorization issue in the AssetsController::actionReplaceFile that can delete a source asset without source delete permission by supplying both assetId and sourceAssetId. AssetsController::actionReplaceFile() supports replacing a target asset file using another existing asset as the source. The action loads: assetId -> $assetToReplace and sourceAssetId -> $sourceAsset, then enforces replace permissions using ($assetToReplace ?: $sourceAsset). When both IDs are provided, this expression resolves to the target asset so no permission check is performed against the source asset volume. When both assets are present, Craft copies the source file into the target and then deletes the source asset. There is no deletion check for for the source asset. An authenticated user who can replace files in one volume can delete assets in another volume where they do not have delete permission, as long as they can obtain a sourceAssetId, leading to broken content references and data loss. This issue has been fixed in versions 4.17.14 and 5.9.21.

GitHub Advisory Database

We have identified an authorization issue in Craft CMS AssetsController::actionReplaceFile that can delete a source asset without source delete permission by supplying both assetId and sourceAssetId.

Description

Craft CMS’s craft\\controllers\\AssetsController::actionReplaceFile() supports replacing a target asset file using another existing asset as the source. The action loads:

  • $assetToReplace from assetId
  • $sourceAsset from sourceAssetId

It then enforces replace permissions using ($assetToReplace ?: $sourceAsset). When both IDs are provided, this expression resolves to the target asset so no permission check is performed against the source asset volume.

$this->requireVolumePermissionByAsset('replaceFiles', $assetToReplace ?: $sourceAsset);
$this->requirePeerVolumePermissionByAsset('replacePeerFiles', $assetToReplace ?: $sourceAsset);

src/controllers/AssetsController.php:L433-L434

In the branch where both assets are present, Craft copies the source file into the target and then deletes the source asset. There is no check for deleteAssets:<sourceVolumeUid> or deletePeerAssets:<sourceVolumeUid> for the source asset before deletion.

$assets->replaceAssetFile($assetToReplace, $tempPath, $assetToReplace->getFilename(), $sourceAsset->getMimeType());
Craft::$app->getElements()->deleteElement($sourceAsset);

src/controllers/AssetsController.php:L462-L463

Impact

An authenticated user who can replace files in one volume can delete assets in another volume where they do not have delete permission, as long as they can obtain a sourceAssetId. This can lead to unauthorized asset deletion, broken content references, and data loss.

NVD (es)

Craft CMS es un sistema de gestión de contenido (CMS). Las versiones 5.0.0-RC1 hasta 5.9.20, y 4.0.0-RC1 hasta 4.17.13 contienen un problema de autorización en AssetsController::actionReplaceFile que puede eliminar un activo de origen sin permiso de eliminación de origen al proporcionar tanto assetId como sourceAssetId. AssetsController::actionReplaceFile() admite reemplazar un archivo de activo de destino utilizando otro activo existente como origen. La acción carga: assetId -> $assetToReplace y sourceAssetId -> $sourceAsset, luego aplica los permisos de reemplazo utilizando ($assetToReplace ?: $sourceAsset). Cuando se proporcionan ambos ID, esta expresión se resuelve en el activo de destino, por lo que no se realiza ninguna verificación de permiso contra el volumen del activo de origen. Cuando ambos activos están presentes, Craft copia el archivo de origen en el destino y luego elimina el activo de origen. No hay verificación de eliminación para el activo de origen. Un usuario autenticado que puede reemplazar archivos en un volumen puede eliminar activos en otro volumen donde no tiene permiso de eliminación, siempre que pueda obtener un sourceAssetId, lo que lleva a referencias de contenido rotas y pérdida de datos. Este problema ha sido solucionado en las versiones 4.17.14 y 5.9.21.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-50283 changed 2026-07-02CVE Terms of Use
GitHub Advisory DatabaseGHSA-qh45-9g5p-m2v4 changed 2026-09-10CC-BY-4.0
NVDCVE-2026-50283 changed 2026-10-25Public domain