/

CVE-2026-33656

Severity:

CRITICAL RISK

(9.1)

Path Traversal in EspoCRM Formula Engine

CVE-2026-33656

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Read/Write within open_basedir Scope

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

EspoCRM's formula scripting engine allows an authenticated admin to modify the sourceId field of Attachment entities, which is then concatenated directly into file paths without sanitization.

This path traversal flaw can redirect file read and write operations to arbitrary locations within the web server's open_basedir scope, enabling access to or modification of sensitive files.

Affected context

The vulnerability occurs in EspoCRM deployments where:

  • The built-in formula scripting engine is enabled and used to manipulate Attachment entities.
  • The sourceId field can be updated by users with administrative rights through formulas.
  • The application constructs file paths using EspoUploadDir::getFilePath() by concatenating sourceId directly into the path.

It becomes risky in environments where sensitive data or application configuration resides within the same open_basedir scope as the EspoCRM upload directories.

Exploit preconditions

  • Attack surface: Application-layer operations involving file attachments (upload, read, write, processing) via EspoCRM.
  • Required access: Authenticated administrator or any role allowed to define or execute formulas that can update Attachment.sourceId.
  • Trigger point: Execution of a formula or workflow that sets sourceId to a crafted value, followed by any functionality that uses EspoUploadDir::getFilePath() to access the file.
  • Why exploitation is possible: The sourceId field is treated as trusted input and concatenated directly into filesystem paths without normalization, validation, or restriction to a safe directory, allowing directory traversal within the open_basedir boundary.

Why this happens

This issue stems from insufficient validation of user-controllable data used in filesystem operations.

The formula engine permits updates to Attachment.sourceId, and this field is later embedded directly into a path string in EspoUploadDir::getFilePath() without sanitization or canonicalization.

This aligns with CWE-22: Path Traversal, where untrusted input influences the resolution of file system paths, enabling access to files outside the intended directory.

Conceptually, the insecure pattern is: filePath = baseDir . '/' . userInput, with no checks to enforce that the resulting path stays within a designated safe root.

Potential impact

  • Read of arbitrary files within the web server's open_basedir scope, potentially exposing credentials, configuration, or source code.
  • Overwrite or corruption of files accessible to the web server user, which may affect logs, application data, or other locally stored information.
  • Escalation of impact through modification of configuration or data files that influence application behavior.
  • Indirect assistance in further attacks, such as information disclosure that simplifies exploitation of other vulnerabilities.

General mitigation guidance

Effective mitigation focuses on restricting how user-controlled values are incorporated into filesystem paths and on tightening privilege boundaries:

  • Treat all identifiers that influence file paths (like sourceId) as untrusted unless explicitly validated.
  • Introduce strict validation and normalization of path-related fields, allowing only expected formats (e.g., UUIDs, numeric IDs) and rejecting any path separators or traversal sequences.
  • Resolve candidate paths to their canonical form and enforce that they remain under a predefined, application-controlled root directory before performing file I/O.
  • Separate the logical identifier of an attachment from the physical file path; map IDs to paths using internal lookups rather than embedding IDs directly into paths.
  • Apply least-privilege principles for the web server account so that even if traversal is attempted, access to sensitive OS-level files is limited.
  • Minimize the contents of the open_basedir scope to only what the application strictly requires, reducing the consequences of any unintended file access.

How teams detect issues like this

Organizations can detect this class of flaw through a combination of review and automated checks:

  • Static analysis: Configure rules to flag any filesystem calls that concatenate user-controllable fields (such as entity attributes or formula-derived values) directly into paths without validation or canonicalization.
  • Code review: Examine areas where business logic or scripting engines (like formulas, workflows, or templates) can influence low-level operations such as file access. Pay special attention to helper utilities like getFilePath() that are widely reused.
  • Policy enforcement: Establish secure coding guidelines requiring centralized APIs for file access that perform path validation, and prohibit direct string concatenation with user input in file operations.
  • Runtime monitoring: Use application logging or security monitoring to detect anomalous file access patterns, such as attempts to access paths containing traversal tokens (../) or unexpected directories—even if blocked by other controls.
  • Automated tooling: Integrate SAST/IAST tools into CI pipelines to highlight path traversal patterns and unsanitized inputs reaching filesystem sinks.

Sources

SourceLink
github.comgithub.com/espocrm/espocrm/security/advisories/GHSA-7922-x7cf-j54x

Frequently asked

questions

Exploitation is scoped to authenticated users with administrative-level capabilities or equivalent rights to manipulate formulas affecting attachments. It is not typically exploitable by unauthenticated users, but within an administrative session the impact can be severe.

The attacker must be able to define or execute formulas that update the sourceId field on Attachment entities. In most deployments, this corresponds to full admin access or a highly privileged application role.

The safest approach is to prevent any user-controlled value from directly determining filesystem paths. Use strongly validated identifiers for attachments, map them to internally managed paths, and enforce canonical-path checks to ensure all file operations stay within a controlled directory.

Standardize on secure file access utilities that encapsulate validation and path normalization, prohibit direct path construction with user input in code review policies, and use automated analysis to detect unsanitized input flowing into filesystem operations. Additionally, minimize the privileges and accessible directories of the web server process to reduce potential damage if a flaw does slip through.

Find out what's already
exploitable in your codebase.