Fix cookie-import path validation bypass + hardcoded /tmp#852
Open
urbantech wants to merge 1 commit intogarrytan:mainfrom
Open
Fix cookie-import path validation bypass + hardcoded /tmp#852urbantech wants to merge 1 commit intogarrytan:mainfrom
urbantech wants to merge 1 commit intogarrytan:mainfrom
Conversation
cookie-import (write-commands.ts): - Always resolve to absolute path before safe-directory check (garrytan#707) - Resolve symlinks (macOS /tmp → /private/tmp) matching validateOutputPath() - Relative paths like '../../etc/shadow' now correctly blocked - Removes separate path.isAbsolute gate that let relative paths skip validation cookie-import-browser.ts: - Replace hardcoded /tmp with os.tmpdir() for cross-platform support (garrytan#708) Tests updated to accept either 'Path must be within' or 'Path traversal' error message for traversal attempts. All 224 browse tests pass. Fixes garrytan#707, fixes garrytan#708
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
Two security/portability fixes in the browse cookie-import command.
#707 — Path validation bypass via relative paths
Before: Relative paths like
../../etc/shadowbypassed the safe-directory check becausepath.isAbsolute()gated the entire validation block. Only the..pattern check ran for relative paths, but a relative path without..(e.g.,sensitive-file.jsonin an unexpected cwd) passed through completely.After: Always
path.resolve()to absolute, then resolve symlinks (matchingvalidateOutputPath()), then check againstSAFE_DIRECTORIES. No separate code paths for relative vs absolute.#708 — Hardcoded
/tmpin cookie-import-browser.tsBefore:
openDbFromCopy()hardcoded/tmp/browse-cookies-.... On Windows,/tmpmay not exist.After: Uses
path.join(os.tmpdir(), ...). Theosmodule was already imported.Test Plan
bun test browse/test/)Fixes #707, fixes #708