path-traversal-and-file-handling

path-traversal-and-file-handling is a skill for Claude Code, Codex from makifbaysal/tasktrooper. It costs 52 tokens per session (1,734 once invoked), scanned C, original, Apache-2.0.

A security review guide for Go code that handles paths, files, archives, uploads, temporary files, or served content. It focuses on cases where a user-controlled name can reach a different file than intended.

In plain words
What is it for?
Use it to review path traversal, symlink escapes, archive extraction, upload handling, file serving, content types, and temporary-file creation.
Why use it?
Cleaning or normalizing a path only changes its text; it does not prevent symlinks, absolute paths, or archive entries from escaping a directory. The guide helps check the path that the filesystem will actually open.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to review path traversal, symlink escapes, archive extraction, upload handling, file serving, content types, and temporary-file creation.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/makifbaysal/tasktrooper/path-traversal-and-file-handling
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add makifbaysal/tasktrooper --skill path-traversal-and-file-handling
Clone the repo
git clone --depth 1 https://github.com/makifbaysal/tasktrooper

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for path-traversal-and-file-handling

README.md
[![agentmods](https://agentmods.dev/badge/skills/makifbaysal/tasktrooper/path-traversal-and-file-handling/github.svg)](https://agentmods.dev/skills/makifbaysal/tasktrooper/path-traversal-and-file-handling)
Your own site
<a href="https://agentmods.dev/skills/makifbaysal/tasktrooper/path-traversal-and-file-handling"><img src="https://agentmods.dev/badge/skills/makifbaysal/tasktrooper/path-traversal-and-file-handling/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for path-traversal-and-file-handling

Your own site · 80×15
<a href="https://agentmods.dev/skills/makifbaysal/tasktrooper/path-traversal-and-file-handling"><img src="https://agentmods.dev/badge/skills/makifbaysal/tasktrooper/path-traversal-and-file-handling.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,734 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00052 $0.01734
Opus 5.5 $0.00021 $0.00694
Sonnet 5.5 $0.00010 $0.00347
Haiku 4.5 $0.00005 $0.00173

Measured 4d ago against content hash df7cbb93c390, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

path-traversal-and-file-handling scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reaches for credential fileshighPrivilege escalation

SSH keys, cloud credentials, git-credentials, .npmrc, /etc/shadow: reading these is how a config file becomes a credential leak.

Archive entry names are attacker input: `../../.ssh/authorized_keys`, absolute paths, and symlink entries that point outside and are then written through.
catalog/agents/security-agent/skills/path-traversal-and-file-handling/SKILL.md · 125 lines

How it starts

The opening of the file, as written. The whole thing — 125 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Path Traversal and File Handling

Overview

Join, normalize, resolve and clean are lexical: they rewrite a string, they do not ask the filesystem where it points. A path check that runs on the string and an open that runs on the filesystem disagree whenever there is a .., an absolute path, or a symlink.

Core principle: resolve the real path first, then check containment by path components, then open what you checked — or use an API that confines the open itself.

1. Traversal (CWE-22)

// ❌ HasPrefix on a cleaned string: "/srv/files-private/x" passes for base "/srv/files",
//    and a symlink inside base escapes entirely
p := filepath.Join(base, name)
if !strings.HasPrefix(filepath.Clean(p), base) { return errBadPath }
f, _ := os.Open(p)

// ✅ Go 1.24+: the root confines every lookup, symlinks included
root, _ := os.OpenRoot(base)
f, err := root.Open(name)
// older Go: reject non-local names first — filepath.IsLocal(name) (Go 1.20+)
// ❌ normalize() is lexical; a symlink under base still escapes
Path p = base.resolve(name).normalize();
if (!p.startsWith(base)) throw new SecurityException();

// ✅ compare real paths (Path.startsWith is component-wise, String.startsWith is not)
Path real = base.resolve(name).toRealPath();
if (!real.startsWith(base.toRealPath())) throw new SecurityException();
# ❌ os.path.join drops base entirely when name is absolute ("/etc/passwd")
path = os.path.join(UPLOAD_DIR, name)

# ✅
root = Path(UPLOAD_DIR).resolve()
path = (root / name).resolve()
if not path.is_relative_to(root):   # Python 3.9+
    abort(400)
// ❌ startsWith without a trailing separator; "/data/app-secrets" passes for "/data/app"
const p = path.resolve(base, name); if (!p.startsWith(base)) throw ...
// ✅
const p = path.resolve(base, name); if (!p.startsWith(base + path.sep)) throw ...
// and for symlinks: fs.realpathSync(p) before the check

Flask: send_from_directory. Express: res.sendFile(name, { root: base }) (rejects escaping paths) rather than res.sendFile(path.join(base, name)).

Read the full file on GitHub · 125 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 125 lines · 52 tokens per session scan C df7cbb93c390

Subscribe to this mod's changes

path-traversal-and-file-handling is a skill published in the GitHub repository makifbaysal/tasktrooper (113 stars, last pushed yesterday), licensed Apache-2.0. It adds 52 tokens to every session and 1,734 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it C with 1 finding (reaches for credential files). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-09.