harden: create rewind working-tree directories via os.Root
main·
Commit

When entire checkpoint rewind restores files from a checkpoint tree,
the file write already used os.Root (kernel-enforced containment), but
the preceding directory creation used a raw
os.MkdirAll(filepath.Join(repoRoot, f.Name)). A crafted tree entry name
containing ".." from an untrusted checkpoint could thus create empty
directories outside the repo before the guarded write refused to escape.
Add osroot.MkdirAll, which creates each level via os.Root.Mkdir so the kernel rejects any path that escapes the root, and use it in the restore loop. Both filesystem operations in that loop are now containment-safe.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com Entire-Checkpoint: f52cf53648bf
Checkpoints
Checkpoint 1