/

CVE-2026-40157

Severity:

HIGH RISK

(8.8)

Path Traversal / Directory Traversal in PraisonAI Recipe CLI

CVE-2026-40157

Analyzed

Vulnerability type

Category:

Path Traversal / Directory Traversal

CWE:

CWE-22

Impact:

Arbitrary File Overwrite on Filesystem

Severity:

HIGH RISK

(8.8)

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

PraisonAI's recipe CLI previously extracted .praison tar archives using tar.extract() without validating or normalizing member paths, enabling path traversal via ../ sequences.

If a user unpacks a malicious bundle, archive entries containing ../../ can escape the target directory and overwrite arbitrary files on the local filesystem, which becomes risky whenever bundles are obtained from untrusted or semi-trusted sources.

Affected context

This vulnerability affects environments where PraisonAI's recipe CLI is used to unpack .praison bundles with the cmd_unpack functionality.

It is relevant whenever:

  • Users download or receive .praison bundles not fully controlled by themselves, and
  • The CLI runs with filesystem permissions that give it access to sensitive files or application directories.

The issue manifests specifically when archives contain paths with directory traversal components (e.g., ../) that are not sanitized or constrained to the intended output directory.

Exploit preconditions

  • Attack surface: Local CLI usage; triggered when a user runs praisonai recipe unpack on a crafted .praison archive.
  • Required access: Ability for an attacker to distribute or influence the .praison bundle contents (e.g., via public repositories, shared bundles, or supply-chain channels).
  • Trigger point: Execution of the cmd_unpack command, which calls tar.extract() on archive members without validating their resolved paths.
  • Why exploitation is possible: The extraction logic trusts archive entry names, allowing ../ components or absolute-like paths to resolve outside the intended unpack directory, leading to uncontrolled write operations on the filesystem.

Why this happens

The core issue is an unchecked path traversal during archive extraction, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory.

The implementation uses raw tar.extract() on archive members, implicitly trusting the path information embedded in the archive.

Without normalizing and verifying that each member's final resolved path remains within the designated output directory, the tool permits ../ segments or other crafted paths to escape this directory.

This insecure pattern allows archives to dictate arbitrary write locations on the host filesystem, violating directory confinement expectations.

Potential impact

  • Overwriting existing application configuration files that the user has permission to modify.
  • Replacing executable scripts or binaries within the user's PATH, potentially enabling subsequent code execution when those programs run.
  • Corrupting or replacing project files, build artifacts, or data directories.
  • Introducing backdoors or malicious content into development environments by overwriting source files or dependencies.
  • Disrupting system or user workflows by clobbering critical files, leading to denial-of-service-like effects.

General mitigation guidance

Effective mitigations focus on constraining archive extraction to a trusted directory and distrusting embedded paths:

  • Normalize and join each archive member's path with the chosen output directory, then verify that the resulting absolute path still resides under that directory before extracting.
  • Reject archive entries containing .., absolute paths, or unexpected path prefixes, and log or surface these as errors instead of silently extracting them.
  • Use safer archive-handling patterns that iterate over members and perform per-entry checks instead of relying on bulk extraction primitives.
  • Run CLI tools with the least privileges necessary, avoiding execution with elevated permissions that would broaden the damage from unintended file writes.
  • Encourage workflows where .praison bundles are obtained from authenticated, integrity-checked sources to reduce the likelihood of malicious content.

How teams detect issues like this

Organizations can detect and monitor for similar issues through multiple approaches:

  • Static analysis: Add rules to flag use of generic tar.extract() or equivalent bulk extraction APIs without surrounding path validation logic.
  • Code review: During review, look for archive unpacking that:
  • Does not normalize and validate paths against a base directory.
  • Accepts archive paths directly from untrusted input or external bundles.
  • Security testing: Include tests that attempt to extract archives containing ../ components and confirm they are rejected or safely handled.
  • Policy enforcement: Establish internal guidelines requiring per-entry checks when handling compressed or archived content from external sources, and integrate automated linters that enforce these patterns.

Sources

SourceLink
github.comgithub.com/MervinPraison/PraisonAI/security/advisories/GHSA-99g3-w8gr-x37c

Frequently asked

questions

It is not directly remotely exploitable in the traditional network sense; exploitation occurs when a local user runs the PraisonAI recipe CLI on a malicious .praison bundle. However, attackers can deliver such bundles through remote channels (e.g., downloads, repositories), so the effective risk can be similar to remote compromise in supply-chain scenarios.

The attacker needs the ability to supply or influence the .praison bundle that the user unpacks. Once the user executes the unpack command, the archive contents are written with the same filesystem permissions as that user, enabling arbitrary file overwrites within their accessible directories.

The robust fix is to enforce directory confinement for all archive entries. This typically means normalizing member paths, rejecting absolute or traversal-containing paths, and ensuring the resolved extraction path remains under the intended output directory before performing any write operation.

Future prevention centers on treating archive contents as untrusted input: always validate and sanitize paths, prefer high-level APIs or helper utilities that enforce safe extraction by default, and incorporate security-focused code review and automated checks for file and archive handling logic.

Find out what's already
exploitable in your codebase.