fix(security): fix latent sandbox escape in IO.path()
filepath.Clean("/"+p) returns absolute path, filepath.Join(root, "/abs")
drops root on Linux. Strip leading "/" before joining with sandbox root.
Currently not exploitable (validatePath handles it), but any future
caller of path() with active sandbox would escape. Defensive fix.
Found by Gemini Pro security review.
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
55cbfea7ca
commit
dd6803df10
1 changed files with 2 additions and 2 deletions
|
|
@ -60,8 +60,8 @@ func (m *IO) path(p string) string {
|
|||
return clean
|
||||
}
|
||||
|
||||
// Join cleaned relative path with root
|
||||
return filepath.Join(m.root, clean)
|
||||
// Strip leading "/" so Join works correctly with root
|
||||
return filepath.Join(m.root, clean[1:])
|
||||
}
|
||||
|
||||
// validatePath ensures the path is within the sandbox, following symlinks if they exist.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue