Summary
A path traversal vulnerability in Wazuh's DistributedAPI can cause the master node to return files outside the intended temporary-file location when processing a cluster request. A cluster peer that possesses the shared Fernet key may read sensitive files, including the API private key, and could forge administrator tokens for privileged REST API access.
Affected context
This issue affects Wazuh deployments using the vulnerable DistributedAPI cluster communication path in affected 4.x and 5.x beta releases. The risk exists when a cluster peer can submit a temporary-file reference that is processed by the master without canonicalization or confinement to the expected Wazuh directory. Exposure is especially serious when the master can read credentials or cryptographic key material from its filesystem.
Exploit preconditions
- Attack surface: Wazuh cluster communication handled by the DistributedAPI
- Required access: A cluster peer or equivalent position with access to the shared Fernet key
- Trigger point: Processing of a requested temporary-file path by
DistributedAPI.send_tmp_file() - Why exploitation is possible: The supplied path is joined to the Wazuh base path without canonicalization or effective confinement, allowing references to resolve outside the intended directory
Why this happens
The vulnerability results from treating an attacker-controlled file path as a trusted relative filename. Joining that value to a trusted base directory without canonicalizing the result and verifying that it remains within the permitted directory allows path traversal and absolute-path resolution.
This behavior maps to CWE-73: External Control of File Name or Path, in which externally influenced path data determines which filesystem object an application accesses. The resulting read operation can expose sensitive configuration, credentials, or cryptographic material.
Potential impact
- An attacker may read files accessible to the Wazuh master process
- Sensitive credentials or private keys could be disclosed
- An attacker could forge administrator REST API tokens if the relevant signing key is exposed
- Administrative API privileges could be obtained without creating a Wazuh account
- Security monitoring configuration and protected data could be altered
- The confidentiality and integrity of the Wazuh deployment could be compromised
General mitigation guidance
Mitigation generally focuses on enforcing a strict trust boundary around cluster file-transfer operations.
Common defensive patterns include:
- Canonicalizing requested paths before filesystem access
- Rejecting absolute paths and traversal components
- Verifying that the resolved path remains beneath an explicitly permitted directory
- Replacing filename-based requests with opaque, server-issued file identifiers
- Limiting cluster peers and protecting shared authentication keys
- Storing private keys outside broadly readable locations and applying least-privilege filesystem permissions
- Running the Wazuh master with only the filesystem and administrative privileges it requires
- Rotating exposed cryptographic material and invalidating tokens when key disclosure is suspected
- Applying vendor-provided security fixes through the organization's normal patch-management process
How teams detect issues like this
Organizations can look for this weakness through:
- Static analysis rules that flag filesystem joins involving externally controlled path values
- Code review checks for missing canonicalization and containment validation
- Tests covering absolute paths, traversal sequences, symlink resolution, and alternate path representations
- Runtime monitoring for unusual cluster file-transfer requests or access to sensitive paths
- Audit review for unexpected administrator token creation or use
- Policy enforcement requiring allowlisted directories and opaque file references for internal transfer APIs
- Automated security review tools that identify path traversal and uncontrolled file path patterns

