/

CVE-2026-35573

Severity:

CRITICAL RISK

(9.1)

Path Traversal and Unrestricted File Upload in ChurchCRM

CVE-2026-35573

Analyzed

Vulnerability type

Category:

Path Traversal and Unrestricted File Upload

CWE:

CWE-22, CWE-434

Impact:

Remote Code Execution via Web Server Configuration Manipulation

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal flaw in ChurchCRM's backup restore feature allows authenticated administrators to upload files with attacker-controlled names into the web-accessible filesystem.

By overwriting Apache .htaccess configuration files, an attacker can change web server behavior and potentially achieve remote code execution on the underlying server.

Affected context

The vulnerability occurs in ChurchCRM's backup restore functionality, specifically in src/ChurchCRM/Backup/RestoreJob.php, where uploaded backup files are written into /var/www/html/tmp_attach/ChurchCRMBackups/ using the user-controlled $rawUploadedFile['name'] parameter.

Affected instances are those where:

  • The ChurchCRM application is deployed behind Apache (or a similar server honoring .htaccess),
  • The web server process has write permissions to the backup directory or nearby paths,
  • Administrative users can access the backup restore interface and upload files.

Exploit preconditions

  • Attack surface: Web-based backup restore endpoint within the ChurchCRM administrative interface.
  • Required access: Authenticated ChurchCRM account with administrator-level permissions or equivalent privileges to use backup restore.
  • Trigger point: Submission of a crafted backup upload request where the name field of the uploaded file is manipulated to include path traversal sequences or targeted filenames such as .htaccess.
  • Why exploitation is possible: The server uses the unvalidated $rawUploadedFile['name'] parameter to construct filesystem paths, allowing traversal and overwriting of sensitive configuration files under the web root. Combined with the ability of .htaccess to modify execution rules, this can escalate into remote code execution.

Why this happens

The root cause is insufficient normalization and validation of user-controlled file names in the backup restore path, combined with overly permissive upload behavior.

The code in RestoreJob.php trusts $rawUploadedFile['name'] when constructing the destination path under /var/www/html/tmp_attach/ChurchCRMBackups/ without robust checks for:

  • Path traversal sequences (e.g., ../) that escape the intended directory (mapping to CWE-22: Improper Limitation of a Pathname to a Restricted Directory).
  • Restricting the set of allowable filenames, paths, and extensions to safe, expected backup formats (relating to CWE-434: Unrestricted Upload of File with Dangerous Type).

This insecure pattern turns an internal backup mechanism into a write-primitive for arbitrary files under the web server's control, enabling configuration tampering and code execution.

Potential impact

  • Overwriting .htaccess files to:
  • Enable execution of previously non-executable content,
  • Route requests to malicious scripts,
  • Bypass or weaken existing access controls.
  • Remote code execution in the context of the web server process.
  • Installation of persistent web shells or backdoors in the application directory.
  • Tampering with application behavior, logging, and access control rules.
  • Escalation from an application-level administrative account to full server compromise, depending on server configuration.

General mitigation guidance

Defensive measures should focus on constraining file paths, filenames, and upload semantics in the backup restore workflow:

  • Enforce strict allowlists for destination directories and perform canonicalization of paths before any filesystem write, rejecting uploads if the resolved path escapes the intended backup directory.
  • Replace user-provided filenames with server-generated names (e.g., based on UUIDs or timestamps) and maintain metadata separately, preventing user control over filesystem paths.
  • Restrict acceptable file types and extensions to specific backup formats, and validate file contents where feasible rather than trusting client-supplied metadata.
  • Ensure backup directories cannot influence server configuration: avoid storing uploads in locations where .htaccess or other configuration files are evaluated, or disable .htaccess processing for upload paths.
  • Apply least-privilege to the web server's filesystem permissions so that it cannot overwrite configuration files or executable code outside designated data directories.

How teams detect issues like this

Detection efforts can combine code-based and operational monitoring approaches:

  • Static analysis and code review:
  • Search for use of user-controlled filename fields (e.g., $_FILES['...']['name']) directly in filesystem operations (move_uploaded_file, fopen, file_put_contents).
  • Flag concatenation of raw request parameters into file paths without normalization and checks against path traversal patterns.
  • Review upload and backup-related code for absence of extension and directory allowlists, as well as missing checks against critical filenames (e.g., .htaccess, web.config, index.php).
  • Configuration and policy checks:
  • Enforce policies that disallow .htaccess processing in upload directories and ensure configuration files are immutable by the web server process.
  • Use infrastructure-as-code or configuration management tools to verify permission boundaries between application data and configuration/code.
  • Runtime and log monitoring:
  • Monitor web server and application logs for suspicious upload filenames containing traversal sequences or targeting known configuration files.
  • Track unexpected changes to .htaccess or other key configuration files using file integrity monitoring to detect potential exploitation early.

Sources

SourceLink
github.comgithub.com/ChurchCRM/CRM/security/advisories/GHSA-r6cr-mvr9-f6wx

Frequently asked

questions

Yes, but only by authenticated users with administrative access to the ChurchCRM instance. If such access is reachable over the internet, an attacker can exploit the vulnerability remotely by abusing the backup restore interface.

Exploitation requires valid administrative credentials or another account with equivalent permissions to access and use the backup restore functionality. Anonymous or low-privilege users cannot directly trigger the vulnerable code path under normal configurations.

The safest fix is to completely decouple user input from filesystem paths: generate server-side filenames, canonicalize and validate any paths against a strict allowlist, and ensure upload directories cannot influence server configuration or code execution behavior. Additionally, enforce extension and content checks so only benign backup formats are accepted.

Adopt a standard secure file handling pattern: never trust client-supplied filenames, always resolve and validate paths before use, separate configuration/code from writable data directories, and subject all upload and backup-related changes to focused security review and automated static checks. Institutionalizing these patterns in development guidelines and CI pipelines helps prevent recurrence of path traversal and unsafe upload issues.

Find out what's already
exploitable in your codebase.