Summary
Craft CMS contains a missing authorization check in the asset replacement workflow. An authenticated, low-privilege author who can replace files in a shared folder may overwrite a peer's asset with attacker-controlled content when the target asset is resolved after permission checks.
Affected context
The issue occurs in Craft CMS asset replacement operations involving shared folders. It becomes risky when a user has permission to replace files but does not have the permission required to replace another user's peer asset, and the target asset is identified through folder and filename resolution after authorization checks have already run.
Exploit preconditions
- Attack surface: Authenticated Craft CMS asset-management request handling
- Required access: A low-privilege author account with
replaceFilespermission on a shared folder - Trigger point: Asset replacement through
AssetsController::actionReplaceFile - Target condition: The target asset resides in the same folder as the attacker-controlled source or referenced filename
- Why exploitation is possible: Authorization checks occur before the target asset is fully resolved, so the
replacePeerFilespermission is not enforced for the selected peer asset
Why this happens
The underlying bug is an authorization-ordering and object-resolution flaw. The controller performs permission checks before resolving the target asset from the supplied folder and filename context, allowing the eventual target to differ from the object considered during authorization. This maps to CWE-862: Missing Authorization, because a sensitive file modification operation can proceed without verifying the caller's permission for the resolved resource.
Potential impact
- An attacker could overwrite a peer's asset content
- Website content or uploaded resources may be tampered with
- Malicious files could be introduced into shared asset locations
- Content integrity and user trust could be reduced
- Downstream systems consuming the modified asset may be affected
General mitigation guidance
Mitigation generally focuses on authorizing the fully resolved target resource before any replacement occurs.
Common defensive patterns include:
- Resolve the target asset and its ownership or sharing context before performing permission checks
- Enforce both general file-replacement and peer-file authorization requirements
- Bind authorization decisions to immutable resource identifiers rather than user-controlled names or paths
- Apply server-side validation to ensure source, target, folder, and filename relationships are permitted
- Minimize shared-folder permissions and follow least-privilege access principles
- Maintain audit records for asset replacement operations and flag unexpected cross-user modifications
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules that identify authorization checks performed before resource resolution
- Code review checks comparing the object authorized with the object ultimately modified
- Tests covering same-folder peer resources and users with overlapping but incomplete permissions
- Policy enforcement requiring every resource-modifying controller action to authorize the final resource identity
- Audit-log monitoring for asset replacements performed by users without peer-resource privileges
Automated application-security review tools may help identify missing or inconsistently applied authorization checks, but targeted authorization tests remain important.

