detached 4615780

fix(jail): block POSIX-absolute cd targets on Windows

filepath.IsAbs("/etc") is false on Windows, so the cd-escape check
folded "/etc" back inside root via filepath.Join and let it through,
failing CI. Treat a leading forward slash that is not OS-absolute as an
escape attempt.
commit
4615780369a41d6b6ee6dc661ce00be2dcdb5e44
author
patriceckhart · · 2026-06-17 15:24 UTC
parent
bfd8c07
signature
unsigned
refs
tag: v0.2.37
1 file · +8 -0
M packages/agent/tools/sandbox.go +8 -0
@@ -168,6 +168,14 @@ func (s *Sandbox) checkCDTarget(dir string) error {
168168 return fmt.Errorf("sandbox root: %w", err)
169169 }
170170 expanded := expandHome(dir)
171+ // A leading forward slash is an absolute POSIX path. The shell uses
172+ // POSIX-style paths regardless of host OS, but on Windows
173+ // filepath.IsAbs("/etc") is false and filepath.Join would fold it
174+ // back inside root, so a `cd /etc` escape would slip through. Treat
175+ // it as an unconditional escape attempt: outside any project root.
176+ if strings.HasPrefix(expanded, "/") && !filepath.IsAbs(expanded) {
177+ return fmt.Errorf("jailed: cd outside sandbox root is not allowed (use /unjail to disable)")
178+ }
171179 if !filepath.IsAbs(expanded) {
172180 // Relative targets (including `..`) resolve against the sandbox
173181 // root, which is the bash tool's working directory when jailed.
@@ -168,6 +168,14 @@ func (s *Sandbox) checkCDTarget(dir string) error {
168 return fmt.Errorf("sandbox root: %w", err)168 return fmt.Errorf("sandbox root: %w", err)
169 }169 }
170 expanded := expandHome(dir)170 expanded := expandHome(dir)
171+ // A leading forward slash is an absolute POSIX path. The shell uses
172+ // POSIX-style paths regardless of host OS, but on Windows
173+ // filepath.IsAbs("/etc") is false and filepath.Join would fold it
174+ // back inside root, so a `cd /etc` escape would slip through. Treat
175+ // it as an unconditional escape attempt: outside any project root.
176+ if strings.HasPrefix(expanded, "/") && !filepath.IsAbs(expanded) {
177+ return fmt.Errorf("jailed: cd outside sandbox root is not allowed (use /unjail to disable)")
178+ }
171 if !filepath.IsAbs(expanded) {179 if !filepath.IsAbs(expanded) {
172 // Relative targets (including `..`) resolve against the sandbox180 // Relative targets (including `..`) resolve against the sandbox
173 // root, which is the bash tool's working directory when jailed.181 // root, which is the bash tool's working directory when jailed.

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close