/

CVE-2026-40024

Severity:

HIGH RISK

(7.1)

Path Traversal in Sleuth Kit tsk_recover File Recovery

CVE-2026-40024

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Write / Potential Remote Code Execution

Severity:

HIGH RISK

(7.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 vulnerability in Sleuth Kit's tsk_recover utility allows crafted filenames within a filesystem image to escape the intended recovery directory when files are written to disk.

If an attacker can supply or influence a processed filesystem image, they may cause recovered files to be written to arbitrary paths on the host system, potentially overwriting sensitive configuration files and enabling code execution.

Affected context

This vulnerability appears when tsk_recover is used to extract files from potentially untrusted or externally supplied filesystem images, such as those obtained during incident response, forensic analysis, or automated processing pipelines.

The issue occurs during the reconstruction of directory paths from the image, where filename components containing traversal tokens (for example, ../) are not fully normalized or constrained to the configured output directory.

The risk is higher in workflows where tsk_recover is run with elevated privileges or where the output directory is located near sensitive configuration paths.

Exploit preconditions

  • Attack surface: The tsk_recover command-line tool when invoked on attacker-controlled or crafted filesystem images.
  • Required access: Ability to provide or influence the filesystem image processed by tsk_recover (e.g., uploaded disk images, evidence submissions, or automated intake sources).
  • Trigger point: Running tsk_recover with a specified output directory that is assumed to be a safe boundary for recovered files.
  • Why exploitation is possible: The code that reconstructs file paths from image metadata does not strictly sanitize or normalize path components, allowing embedded ../ sequences to traverse out of the designated output directory and target arbitrary file locations on the host.

Why this happens

The underlying issue is insufficient validation and normalization of path components derived from untrusted data inside the filesystem image.

Instead of enforcing that all recovered paths remain strictly within the specified output directory, tsk_recover constructs paths directly from filenames and directory entries that may include ../ or absolute-style segments.

This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-controlled or untrusted path segments bypass intended directory constraints and allow access or writes outside the target directory tree.

Potential impact

  • Overwriting of arbitrary files writable by the tsk_recover process.
  • Modification of user or system shell configuration files (e.g., to add malicious commands on login).
  • Tampering with scheduled task or cron entries to achieve code execution.
  • Corruption of application configuration, logs, or other operational data.
  • Facilitation of privilege escalation if sensitive root-owned files are overwritten when tsk_recover runs with elevated privileges.

General mitigation guidance

Effective mitigation typically focuses on constraining output paths and treating filesystem image contents as fully untrusted input:

  • Normalize and canonicalize all recovered path components before file creation, ensuring the final resolved path remains within the intended output directory.
  • Strip or reject any paths containing traversal tokens (.., absolute prefixes, or drive roots) or other unsafe characters before writing to disk.
  • Enforce a strict "chroot-like" policy in path resolution logic: join paths only after validation and refuse recovery of files that cannot be safely mapped inside the output directory.
  • Run tsk_recover under a dedicated, least-privileged account and direct output to isolated working directories, reducing impact if traversal occurs.
  • In operational workflows, treat external filesystem images as untrusted and avoid running tsk_recover with elevated privileges where possible.

How teams detect issues like this

Detection and assurance can rely on both code-level and operational controls:

  • Static analysis: Configure rules or linters to flag path construction that concatenates untrusted path segments without normalization or checks against a base directory.
  • Code review: Examine file recovery and export routines for direct use of image-derived names in filesystem APIs (open, mkdir, rename) and verify that checks enforce containment within the output directory.
  • Runtime monitoring: Use filesystem auditing to detect unexpected writes outside designated recovery directories during tsk_recover runs.
  • Policy enforcement: Integrate automated security tests in CI to simulate paths with ../ sequences and validate they are rejected or safely confined.

Sources

SourceLink
github.comgithub.com/sleuthkit/sleuthkit/commit/a3f96b3bc36a8bb1a00c297f77110d4a6e7dd31b
mobasi.aimobasi.ai/sentinel
vulncheck.comvulncheck.com/advisories/sleuth-kit-tsk-recover-path-traversal

Frequently asked

questions

It can be, depending on how tsk_recover is integrated. If a system accepts disk or filesystem images from remote sources and automatically processes them with tsk_recover, an attacker may be able to exploit the vulnerability remotely by submitting a crafted image.

The attacker needs the ability to supply or influence a filesystem image that will be processed by tsk_recover. They do not necessarily need shell access to the host, but the impact depends on the privileges under which tsk_recover runs and where its output is stored.

Implement strict path normalization and validation before any file is written, guaranteeing that the resolved path cannot escape the designated output directory. Reject recovery of entries whose normalized paths would break this guarantee, and avoid using untrusted path segments directly in filesystem operations.

Treat all filenames and path components from external data sources as untrusted, enforce canonicalization against a known-safe base directory, and incorporate security-focused code review and static analysis for file-handling code paths. Running file-processing tools with least privilege and in isolated directories further reduces the impact of any remaining flaws.

Find out what's already
exploitable in your codebase.