Skip to content

harness-runtime: reject unsafe /download default filenames - #2159

Merged
jansari-ux merged 2 commits into
mainfrom
fix-download-default-filename
Nov 30, 2026
Merged

jansari-ux merged 2 commits into
mainfrom
fix-download-default-filename

Conversation

@jansari-ux

Copy link
Copy Markdown
Contributor

The interactive /download shortcut guessed a local filename from the workspace path using POSIX basename semantics. On Windows, a Linux filename containing backslashes, .. or a drive prefix is a path, so a workspace author could choose where the victim's download lands.

Require the derived name to be a single host-local filename (filepath.IsLocal plus basename equality, .. rejected); otherwise the caller must name the destination explicitly. The POSIX parse is unchanged.

Tests: Windows-gated cases for ..\outside.txt, drive-qualified, UNC and .., plus a command-level check that rejection happens before any transfer.

The interactive /download shortcut derives a local filename from the
workspace path with POSIX basename semantics. On Windows a Linux filename
containing backslashes, ".." or a drive prefix is a path, so a workspace
author could choose where the victim's download lands. Require the derived
name to be a single host-local filename and otherwise ask for one.
@jansari-ux

Copy link
Copy Markdown
Contributor Author

Test results

Check Result
gofmt + go vet ./commands/ clean
/download tests pass (5 tests, 17 cases)
go test ./commands/ (excl. 4 env-dependent registry/harbor tests) pass
go test ./do/... ./pkg/... ./internal/... . pass
CI ubuntu-latest / macos-latest pass (1m41s)
CI windows-latest pass (5m16s)

Windows assertions for ..\outside.txt, C:\…, \\server\share\…, dir\ and .. ran on the Windows runner and passed; ordinary names and POSIX behaviour unchanged.

@sanpj2292 sanpj2292 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The inferred /download name now has to be one host-local filename: filepath.IsLocal plus the filepath.Base check rejects ..\, drive-qualified, UNC and trailing-backslash names on Windows, and /workspace/.., which used to slip through. Ordinary names and the POSIX parsing are unchanged. The /download tests pass locally, the test package builds for Windows, and CI is green on all three OSes.

@jansari-ux
jansari-ux merged commit 2a0f955 into main Nov 30, 2026
6 checks passed
@jansari-ux
jansari-ux deleted the fix-download-default-filename branch November 30, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants