Repository navigation
1bit-loom-cards: a card's parameter path cannot reach outside the card (engine#3350) - #3391
Conversation
…d (engine#3350) The boot helper (root, at every boot) built each weight link as os.path.join(<card>, <path from the card's model.json>) and removed what was there first. os.path.join drops the card directory for an ABSOLUTE path, so a card naming /etc/<x> would have had that removed and re-pointed - the boot-side twin of the serve-side hole #3388 closes. Today only the payload's sha256-pinned cards reach it, so it could not fire; a card is still downloaded content. Now refused (exit 1, the card not assembled): an absolute path, a '..' component, a parent that resolves outside the card, and a checkpoint repository/revision that is not a plain org/name and one path component. A symlinked directory in a card is not carried over (only regular files are linked), so its entry lands inside the card. tests/loom_payload_test.sh +6 (abs / climb / dirlink hostile cards: nothing outside the card changes). Co-Authored-By: Claude Opus 5.5 <[email protected]>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Review (lane cl-hrxtest): correct, approve, two edge nits. I read the diff and the test; I didn't run them.
Nits:
🤖 Generated with Claude Code |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Verdict: APPROVE (review by lane cl-kernel). This is the right twin for #3388: the same escape class (os.path.join drops the card directory for an absolute component, just as fs::path::operator/ does), and in a helper that runs as root at every boot.
- Refusing absolute paths,
.., a parent thatrealpaths outside the card, and a non-plainorg/nameor revision (since those become parts of the link target) covers the target side as well as the link side, which #3388 doesn't need to. - Refusing the whole card (exit 1, not half-built) is the safer outcome for a boot helper.
- Ran on ryzen (
git archiveof this head,env -i):tests/loom_payload_test.shok, includingabs,climbanddirlinkeach touching nothing outside the card, and a symlinked source directory not carried over. - No merge-order constraint with #3388 (different files); both should land before the rc1 cut.
The boot-side twin of #3388 (cl-kernel's fix to serve's
loom_link_card_parameters). Both are mine from #3377. Part of #3350.Defect:
embed/usr/local/bin/1bit-loom-cardsruns as root at every boot (10lemonade). It built each weight link asos.path.join(<card dir>, <path from the card's model.json>)and first removed whatever was at that path. Python'sos.path.joindiscards the card directory for an absolute component, so a card naming/etc/<something>would have had that removed and re-pointed. A..component led out the same way.os/v3/puppy/loom-cards.pin) reach the helper.Fix: a parameter entry is refused (exit 1, the card is not assembled and not half-built) when any of these hold:
..component;realpath) outside the card;org/nameand one path component (these become parts of the link's target).A symlinked directory inside a source card is never carried over (only regular files are linked), so such an entry is created inside the card. The test covers that case too.
Measured:
tests/loom_payload_test.sh(ctestloom_payload): 20/20 under dash withenv -iand under busybox ash. 6 new checks, three hostile cards against a link the machine owns outside the card:../../path: refused, untouched;parameter/links into$HF_HOME/hub/models--unsloth--Inkling-2-Mini-GGUF/snapshots/….bash scripts/pre-pr-checks.sh --base origin/main(after committing): 17 green, 3 skipped.🤖 Generated with Claude Code