Repository navigation
feat: read-only remote mounts (SharePoint / Google Drive) for caller-supplied folders - #17
Merged
Merged
Conversation
…nts on /v1/exec) Opt-in per request. A caller (vitinn-ui) sends the tree of a linked remote folder (SharePoint, Google Drive) plus refs to files it already uploaded and is authorized to read. The runner shows the tree read-only at /mnt/<name>: loaded files have bytes, the rest are 0000 stubs. A Python audit hook reports stub opens; /v1/exec returns them as remote_mounts_required so the caller can approve, load and run again. No credentials or network enter the sandbox. Requests without remote_mounts (LibreChat) are byte-identical: payload, manifest, nsjail args, env and response. See docs/remote-mounts/README.md.
Mounts are now writable inside the jail (noexec, nosuid, nodev kept; stubs
stay runner-owned 0000). After the run every loaded file is re-hashed by its
known path and the tree is walked (shared 20000-entry budget) for new
regular files. Each changed file is opened once (O_NOFOLLOW|O_NONBLOCK,
fstat isFile, /proc/self/fd verified under the tree root, parents checked to
be real directories) and hashed and uploaded from that same handle, so a
swapped symlink or FIFO can never read outside the tree or hang the runner.
Outputs carry remote_mount {path, change: modified|created}; the service
passes it through only when the request had remote_mounts. Skips are
recorded in artifact_truncation, never silent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Opt-in read-only remote mounts on
POST /v1/exec. A caller (vitinn-ui) can show a linked SharePoint or Google Drive folder inside the sandbox at/mnt/sharepointor/mnt/google-drive. Thenls,os.listdir,glob,openand pandas work on it, with no path rewriting.Design and rules:
docs/remote-mounts/README.md.How
remote_mounts: [{ path, entries: [{ path, type, size?, file? }] }].fileis loaded: it is a normalRequestFilethe caller uploaded through/upload.0555;0444, fetched like other input refs (egress gateway, or the pushed input cache on lambda-microvm);0000.nosuid,nodev,noexec) at its path, and removes it on every exit path. A startup sweep clears leftovers.sitecustomizeaudit hook turns anopenof a stub into a clearPermissionError./v1/execreturns the stubs asremote_mounts_required: { read: [...] }, so the caller can approve, load and run again.Security
files[]. They go through the sameauthorizeRequestedFilescall. They are also in the signed execution manifest, in egress masking and in input delivery, and the runner re-derives that scope. Covered by a cross-half test with a pinned fixture on both sides...,., leading/or backslash;^/mnt/[a-z0-9-]+$and must not be/mnt/data.files[]+ loaded files ≤ 256, the runner's limit, so nothing is accepted and then rejected after enqueue.prime_concurrency.remote-bridgereturns 400remote_mounts_unsupported, and/exec/programmaticrejects the field.LibreChat compatibility
LibreChat never sends
remote_mounts, andnullis treated as absent. Without the field, behaviour is byte-identical. Tests pin each part:PYTHONPATHunchanged);Requests without the field never create the per-job nonce.
Rollout
Deploy the runner and egress gateway before the API and worker. An old gateway does not mask mount refs, and the runner then fails closed with
scope_mismatch.Tests
Run on bun 1.4.4, as in CI:
python3, job, v2 route, execution-manifest-request, nsjail).Not run here: a real nsjail / Lambda MicroVM execution. Please verify on a staging runner before it goes to production.
Update: copy-on-write (c5071fe)
Mounts are now writable inside the jail (
noexec,nosuid,nodevkept; stubs stay runner-owned0000). The remote source is never touched.After the run, each loaded file is re-hashed by its known path, and the tree is walked for new regular files. The walk uses lstat only and has a shared budget of 20,000 entries.
Changed and new files come back as ordinary outputs with
remote_mount: {path, change: "modified" | "created"}, only when the request hadremote_mounts.Host-file safety. Every content read opens the file once:
O_NOFOLLOW|O_NONBLOCK;/proc/self/fdmust resolve under the tree root;The hash and the upload both read from that one handle. So a swapped symlink can't read outside the tree, and a FIFO (a pipe) can't hang the runner. Regression tests cover a symlinked parent dir, a symlink at a loaded path, a FIFO, and an fd that resolves outside the root.
Skips go into
artifact_truncation(max_files,unreadable,size), never silently dropped.Known small items, recorded and not fixed:
unreadable.