Skip to content
Path traversal Write-up Intermediate

Craft Agent’ta kritik path traversal: STORE_ATTACHMENT üzerinden arbitrary file write

The STORE_ATTACHMENT IPC handler in Craft Agent passed a user-controlled sessionId into path.join without validation, allowing path traversal. An attacker could write files outside the intended session directory, potentially leading to code execution if a writable location is a startup directory or shell profile.

xeloxa Follow

Published on medium.com

Bazen bir açık ilk bakışta küçük görünüyor. Basit bir input validation eksikliği gibi.

Ali Sünbül (xeloxa), on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The sessionId value was used directly in path.join without validation, so '..' components could escape the intended directory.

Impact

An attacker could write arbitrary files to any location the Craft Agent process can write to, potentially leading to code execution if a writable location is a startup directory or shell profile, or at least overwriting or corrupting existing files.

What the attacker needed

Ability to send IPC messages to the app; Electron IPC bridge accessible

The fix

The fix added input validation with validateSessionId using an allowlist and path.basename check, plus a second sanitisation layer in getSessionPath.

How it was found

  1. Send a crafted IPC message to the STORE_ATTACHMENT channel.
  2. Include a sessionId containing traversal sequences such as multiple '../' segments.
  3. The app writes the attachment to a path outside the intended sessions directory, for example under /tmp/attachments/.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The app builds a file path using a value the user can control, called sessionId. Because it does not check that value, someone can include '..' sequences to make the app write files somewhere else on the computer. This is called path traversal, and it can let an attacker place files in sensitive locations.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.