Commit 424e4a7
test(controller): add failing tests for unsafe snapshot_tag in create_sandbox
Reproduces the path-traversal gap in `create_sandbox`: it skipped
`is_safe_tag` on `req.snapshot_tag`, unlike `delete_snapshot` and
`branch_sandbox` which both validate. A tag like `../../etc/passwd`
falls through to disk-fallback where `snapshot_root.join(tag)`
produces a path whose `../` segments std::fs syscalls resolve outside
snapshot_root. The vmstate-existence check partially gates impact,
but the unvalidated tag also persists into SandboxInfo.snapshot_tag
and later flows into `read_snapshot_volumes`, which parses attacker-
chosen JSON files as forkd_vmm::Snapshot and inherits their volumes
into branches — i.e. attacker controls volume mounts of grandchild
VMs (post-auth, but the K8s manifest's placeholder bearer token
makes that gate brittle in practice).
Two tests added:
- create_sandbox_rejects_unsafe_snapshot_tag_traversal: `../` path
- create_sandbox_rejects_unsafe_snapshot_tag_chars: space char
Both currently FAIL on this commit (returns 404, not 400). The next
commit will add the validation and turn them green. CI logs are the
verification harness — keeping the failing-test commit separate so
the bug-reproduction is recorded in the PR history.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent 112d17e commit 424e4a7
1 file changed
Lines changed: 47 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
871 | 871 | | |
872 | 872 | | |
873 | 873 | | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
874 | 921 | | |
875 | 922 | | |
876 | 923 | | |
| |||
0 commit comments