Repository navigation
fix(cli): keep attachment-download --all inside --output-dir - #36
Open
amirhmoradi wants to merge 1 commit into
Open
amirhmoradi wants to merge 1 commit into
amirhmoradi wants to merge 1 commit into
Conversation
Attachment names come from the sender. `--all` joined them straight onto --output-dir, so a name like "../../.bashrc" or "/etc/cron.d/job" wrote outside the chosen directory. Names now go through safeFileName(), which keeps only the last path segment (/ or \), replaces control and Windows-reserved characters, and falls back to attachment-<partName>. Idea from DreatNU-oss/thunderbird-cli 651d9f1 (reimplemented, not copied). Found by the weekly upstream & forks scan (ODIAA-2402). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tb attachment-download <id> --all --output-dir <dir>built each file path asjoin(dir, <attachment name>). Attachment names come from whoever sent the email, so a name like../../.bashrcor/etc/cron.d/jobwrote outside<dir>.Names now go through a new
safeFileName()incli/src/client.js:/and\),<>:"|?*) with_,attachment-<partName>when nothing usable is left (empty,.,.., trailing separator).The single-file form (
--output <path>) is unchanged because the user picks that path. CLI only. Nothing underextension/,bridge/or the access policy changes.Credit: the idea comes from DreatNU-oss/thunderbird-cli
651d9f1. This is a reimplementation; no fork code was copied. Found by the weekly upstream & forks scan (ODIAA-2402).Changes
cli/src/client.js:safeFileName(name, fallback)cli/src/cli.js:attachment-download --alluses ittest/quick-test.mjs: 8 cases (traversal, absolute, Windows separators, reserved chars, fallbacks)docs/COMMANDS.md: documents the naming ruleCHANGELOG.md:### Securityentry under[Unreleased]No command or tool count change (74 CLI / 42 MCP).
Tests
npm run test:all: pass (exit 0, every suite reports 0 failed; quick-test 74/74)npm run test:pack-smoke: pass (10/10)🤖 Generated with Claude Code