/

CVE-2026-48716

Severity:

HIGH RISK

(8.7)

Path Traversal (CWE-22) in Nanobot WhatsApp Bridge

CVE-2026-48716

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write

Severity:

HIGH RISK

(8.7)

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 vulnerability in the Nanobot WhatsApp bridge allows user-controlled filenames from incoming document messages to influence where files are written on disk.

By crafting a filename with directory traversal sequences, an attacker can cause the application to write arbitrary content to unintended locations on the server filesystem when handling WhatsApp media attachments.

Affected context

This vulnerability occurs in deployments of the Nanobot personal AI assistant that use the WhatsApp bridge component to receive document messages and store media attachments on disk.

The issue manifests when the bridge constructs output file paths by concatenating a static prefix with the unvalidated documentMessage.fileName from WhatsApp messages, and then calls path.join with a media directory base.

In environments where the service user has write permission to sensitive directories (such as SSH configuration, application configs, or other users' files), this behavior can enable out-of-directory writes and potentially serious follow-on compromise.

Exploit preconditions

  • Attack surface: Incoming WhatsApp document messages processed by the Nanobot WhatsApp bridge.
  • Required access: Ability to send document messages to a WhatsApp account that is connected to the vulnerable Nanobot instance (e.g., being able to message the bot or a bridged group).
  • Trigger point: The moment the bridge receives a document message, downloads its content, and derives an output filename from documentMessage.fileName before writing to disk.
  • Why exploitation is possible: The bridge trusts the fileName field as safe, uses it directly in path.join(mediaDir, outFilename), and does not normalize or restrict the resulting path to remain within the intended media directory. Because Node.js path.join respects .. segments, an attacker can escape the media directory and control both the target path and the file contents.

Why this happens

The underlying flaw is a classic directory traversal or path traversal issue, as described by CWE-22.

The code constructs file system paths using user-supplied data (documentMessage.fileName) without sanitization, validation, or enforcement that the final resolved path stays within a designated safe directory.

By failing to apply allowlists, stripping traversal tokens, or using secure path normalization and containment checks, the implementation allows untrusted input to influence filesystem locations beyond the intended media storage area.

Potential impact

  • Attacker-controlled files can be written outside the media directory.
  • Overwriting or creating SSH-related files (e.g., ~/.ssh/authorized_keys) may allow remote login or persistent access where SSH is in use.
  • Modification of application configuration, scripts, or service files could enable code execution under the Nanobot service account.
  • Corruption or replacement of log files, data files, or other critical resources may disrupt service operation or aid in covering attack traces.
  • Planting web-accessible files in a co-hosted web root (if writable) could allow web-based backdoor deployment.

General mitigation guidance

Effective mitigation focuses on restricting how user input influences filesystem paths and on constraining write locations:

  • Normalize and validate filenames before use, enforcing an allowlist of permitted characters and extensions, and rejecting any path separators or traversal sequences.
  • Use path resolution and containment checks (e.g., resolve the path and confirm it starts with the intended media directory) before writing files.
  • Replace user-provided filenames with server-generated identifiers (random IDs or hashes) and store the original names only as metadata, not as filesystem paths.
  • Run the Nanobot WhatsApp bridge under a minimally privileged account whose filesystem permissions are restricted to a dedicated media directory.
  • Segregate media storage onto isolated directories or volumes that do not contain sensitive configuration or executable files.

How teams detect issues like this

Detection efforts can focus on both code-level patterns and runtime behavior:

  • Static analysis and code review:
  • Flag uses of path.join, string concatenation, or other path APIs where any part of the path is derived from request fields, message metadata, or other untrusted sources without validation.
  • Look for direct use of message properties like documentMessage.fileName in filesystem operations (fs.writeFile, fs.createWriteStream, etc.) with no sanitization utilities in between.
  • Enforce secure coding guidelines that require containment checks when building paths from user input.
  • Runtime monitoring and logging:
  • Log paths used for media writes and alert on attempts to write outside the configured media directory.
  • Use host-based intrusion detection to monitor for unexpected modifications to sensitive files (e.g., SSH keys, configuration directories) by the Nanobot process.
  • Policy enforcement:
  • Integrate automated code scanning in CI pipelines to catch path traversal patterns early.
  • Apply filesystem-level controls (such as mandatory access controls or container volume mappings) to prevent the process from writing to sensitive locations even if a similar bug recurs.

Sources

SourceLink
github.comgithub.com/HKUDS/nanobot/security/advisories/GHSA-3f63-vcp3-hvqr

Frequently asked

questions

Exploitability is limited to environments where an attacker can send document messages to the WhatsApp account bridged by Nanobot. In such setups, any party able to send those documents can attempt path traversal, subject to the filesystem permissions of the Nanobot service user.

No local system privileges are required. The key requirement is the ability to communicate with the WhatsApp bridge (for example, being a contact or group member). The Nanobot process will perform the file write using its own privileges.

Avoid using user-controlled values as filesystem paths. Generate server-side filenames, strictly validate any retained user-supplied name, and enforce that resolved paths remain within a predefined base directory before writing.

Establish and follow secure coding guidelines for file operations: treat all external input as untrusted, apply canonicalization and containment checks for paths, enforce least-privilege execution environments, and use automated code review or static analysis rules to flag unsafe path construction patterns.

Find out what's already
exploitable in your codebase.