runner: Never let a job .blend read host files outside its context #47
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
blocked
draft
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
s1d3sw1ped/jiggablend!47
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ash/relink-host-paths-43"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A job
.blendcould make the runner read any file the runner user can read and send it back in the render. Blake found it in the security review of PR 42. This does both issues in one PR, since they touch the same file (Mira's call allowed that).What changes
<job>/.not-in-context/<name>, which doesn't exist, and reloaded. Blender then has no data for it, and the task log names it..blend, before the script runs, so pointing the path somewhere else and reloading is not enough: the linked data stays in memory (the real Blender run below shows this)._insidecompares realpaths, andbuild_context_indexskips symlinks and anything whose realpath leaves the root.relink_to_contextraises, the render script exits with an error. Before, it printed a warning and rendered with the host paths.Not done: the optional
ExtractTarchange from #44 (reject link entries instead of dropping them). Links already never get extracted, and failing uploads that contain links is a product call. I can file it if you want it.Proof
go test ./pkg/scripts/... -count=1passes, with 13 Python tests. Four of the new tests fail on develop'srelink_context.py: POSIX,//..hops,X:\and host library neutralised; linked image resolved against its library; symlink not indexed; symlink not relinked to.go test ./...passes on the jumpbox exceptinternal/runner/encoding, which needs ffmpeg (the jumpbox has none; CI does).scripts/check-comments.py develop HEADis ok..blendwith a host image and a host library, and a second.blendwhose in-context library links an image at a host path. Output of the script, new code and then develop's code:Closes #43
Closes #44
GO from me on
1fbc25d.I read the whole diff. It's on the current develop tip (
d2f7276) and both CI checks are green.What I checked:
.not-in-contextpath and a reload, and host libraries are removed so their linked data goes with them. The real Blender run in the body shows the difference from develop._insideuses realpath on both sides andbuild_context_indexskips symlinks, which covers #44's acceptance criteria, and the symlink tests prove it.sysis already imported in the template.One note, not a blocker: the commit closes #44, but its optional ExtractTar part isn't done. That's fine since it was marked optional; Mira can say whether she wants a follow-up issue.
This is security work (a file read through job uploads), so Blake still needs to review before Linus merges.
Security GO from me (Blake) on head
1fbc25d157, base developd2f7276.I read the full diff, the template, and how render.go fills in CONTEXT_DIR. I also ran relink_context_test.py at this head: all 13 tests pass.
What I checked:
_insidenow runs realpath on both the path and the job folder beforecommonpath. That means symlinks are resolved before the check, and there is no prefix bug (/job and /job2 compare as separate folders).//../..path that climbs out, or a drive-letter path has no copy in the job folder, it is pointed at<job>/.not-in-context/<name>instead of being left on the host. Host libraries that are blocked are removed. Linked IDs now resolve against their own library, which closes the gap left by the oldlibrary is not None: continue.os.walkdoes not follow directory links, and a link inside the job folder that points out is not relinked to.sysis already imported.%qon the runner-owned WorkDir. That is unchanged, and the user can't control it.Still open for Mira, not a blocker: #44's optional part, rejecting symlinks in uploaded archives outright, is not done.