fix(native-sidecar): close maxFilesystemBytes gaps on host-backed writes#1813
Conversation
Review found the mapped-host budget check barely constrained a real guest: - fs.writeFile/writeFileSync and fs.copyFile allocate no fd, so they never reached the fd-based check at all. writeFileSync is the most common Node write API: a single 8 GB write succeeded under a 64 MiB cap. Both now check before writing (O_TRUNC, so the resulting size is the payload size). - The fd check failed OPEN: metadata() errors defaulted the current size to 0, so an append was measured from offset 0 and any file size passed. An enforcement check that fails open is worse than none, because it reads as enforced. It now fails closed. - ftruncate: VERIFIED NOT a bypass, contrary to one review claim. The kernel truncate applies the quota and the single construction site always supplies a guest path. Added a fail-closed guard so a future `guest_path: None` caller cannot silently disable enforcement for truncation. All host-backed writes now funnel through one admission point, check_mapped_host_write_budget, so the per-VM aggregate has a single place to land. That aggregate is still MISSING: the budget remains per-file while the kernel side compares against whole-filesystem usage, so a guest can still exceed its VM budget by spreading bytes across many files. Documented on the function.
This was referenced Jul 20, 2026
Member
Author
This was referenced Jul 20, 2026
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.
Review found the mapped-host budget check barely constrained a real guest:
fs.writeFile/writeFileSync and fs.copyFile allocate no fd, so they never
reached the fd-based check at all. writeFileSync is the most common Node
write API: a single 8 GB write succeeded under a 64 MiB cap. Both now
check before writing (O_TRUNC, so the resulting size is the payload size).
The fd check failed OPEN: metadata() errors defaulted the current size to
0, so an append was measured from offset 0 and any file size passed. An
enforcement check that fails open is worse than none, because it reads as
enforced. It now fails closed.
ftruncate: VERIFIED NOT a bypass, contrary to one review claim. The kernel
truncate applies the quota and the single construction site always supplies
a guest path. Added a fail-closed guard so a future
guest_path: Nonecaller cannot silently disable enforcement for truncation.
All host-backed writes now funnel through one admission point,
check_mapped_host_write_budget, so the per-VM aggregate has a single place
to land. That aggregate is still MISSING: the budget remains per-file while
the kernel side compares against whole-filesystem usage, so a guest can still
exceed its VM budget by spreading bytes across many files. Documented on the
function.