Back to skill

Security audit

Tar Tool

Security checks for vulnerabilities and agentic risk

Overview

This tar utility has a real unsafe extraction risk that can overwrite files outside the intended folder when handling a crafted archive.

Install only if you trust the archives and run it in a disposable or tightly scoped directory. Do not use it to extract untrusted tar files until it validates archive member paths, rejects unsafe links and traversal, and extracts into an explicit destination with overwrite controls.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/tar.py:9
Finding

Unsafe TAR Extraction Allows Path Traversal and Arbitrary File Overwrite

Content
View full analysis

Vulnerability Details

File Location: scripts/tar.py, lines 9–10
Vulnerability Type: Unsafe archive extraction
Risk Level: High

python
with tarfile.open(args.file, 'r:*') as t:
    t.extractall()

Technical Analysis

The application extracts every member of a user-supplied TAR archive by calling tarfile.extractall() without specifying a controlled destination, applying a safe extraction filter, or validating archive member paths and link targets.

On Python versions where secure TAR filtering is not the default, a malicious archive can contain absolute paths, ../ traversal sequences, or unsafe symbolic or hard-link targets. Such entries can resolve outside the intended extraction directory. Because extraction defaults to the process's current working directory, files outside that directory may be created or overwritten with attacker-controlled content.

Attack Path

  1. An attacker creates a TAR archive containing a member whose name traverses outside the extraction directory, such as ../../target-file.
  2. The attacker supplies the archive to a user or agent, or otherwise influences the archive selected for extraction.
  3. The user or agent runs:
    bash
    python3 scripts/tar.py -x malicious.tar
    
  4. The script opens the untrusted archive and passes all members directly to extractall().
  5. On an affected Python runtime, the crafted path or unsafe link escapes the current working directory.
  6. The extraction operation writes attacker-controlled data to a location writable by the invoking account.

Impact Assessment

Successful exploitation allows arbitrary file creation or overwrite with the privileges of the process running the skill. The attacker does not directly gain privileges beyond those of the invoking account, but may modify any file that account can write.

Depending on the execution environment and working directory, affected targets may include application ...[truncated 327 chars]

Remediation
View remediation

Remediation Suggestions

  • Extract archives only into an explicit, newly created destination directory.
  • On supported Python versions, enable the restrictive data filter:
    python
    from pathlib import Path
    import tarfile
    
    destination = Path("extracted").resolve()
    destination.mkdir(parents=True, exist_ok=True)
    
    with tarfile.open(args.file, "r:*") as archive:
        archive.extractall(path=destination, filter="data")
    
  • For compatibility with runtimes where secure filtering is unavailable or insufficient, validate every member before extraction:
    • Reject absolute member paths.
    • Resolve each target path and verify that it remains beneath the resolved destination directory.
    • Reject .. traversal components.
    • Reject device files and other special file types.
    • Validate symbolic-link and hard-link targets, rejecting links that resolve outside the destination.
  • Avoid relying solely on string-prefix checks; use canonical resolved paths and a path-containment operation.
  • Document a minimum supported Python version and add automated tests using malicious archives containing absolute paths, traversal entries, and escaping link targets.
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (4)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The finding indicates the implemented behavior includes unsafe archive extraction to the current directory without validating member paths, which can permit path traversal or arbitrary file overwrite via crafted tar entries. The mismatch is also security-relevant because the documentation omits this risk and may lead users or orchestrators to trust the skill for routine archive handling when it can write outside the intended extraction directory.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

This is a true vulnerability. tarfile.extractall() will write archive members using the paths stored in the tar, and without validating member names an attacker can supply entries containing absolute paths or '..' path traversal sequences to overwrite files outside the intended extraction directory. In a generic archive utility skill, users are likely to extract untrusted archives, which makes this especially dangerous.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
83% confidence
Finding

The skill declares no explicit tool scope or permissions despite behavior that can write files during archive creation or extraction. In an agent setting, omitted scope increases risk because the skill may be invoked with broader file-system access than users expect, enabling unintended overwrites or archive extraction into sensitive locations.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The code extracts all contents of a tar archive directly to the current working directory, which writes multiple files to disk. Although it prints after completion, there is no prior confirmation, warning, or explanatory comment/docstring about the extraction side effects or risks of unpacking arbitrary archives.

Content

No source excerpt is available for this finding.