Skip to content

fix(native-sidecar): preserve Python edits to API-seeded files - #2023

Closed
ankssjain wants to merge 2 commits into
rivet-dev:mainfrom
ankssjain:fix/python-shadow-write-consistency
Closed

ankssjain wants to merge 2 commits into
rivet-dev:mainfrom
ankssjain:fix/python-shadow-write-consistency

Conversation

@ankssjain

Copy link
Copy Markdown
Contributor

@the-company-company the-company-company Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 1 medium-severity finding

Reviewed commit f1e1bac.


🟠 Medium · Mirroring rejects writes to read-only shadow files after the kernel write succeeds

kernel.write_file has already accepted and committed the Python write, but fs::write re-applies the host sidecar user's DAC permissions to the shadow copy. Because the sidecar is intentionally unprivileged, an API-seeded file whose guest mode is 0444/0000 makes this return EACCES; the RPC reports failure after mutating the kernel and leaves stale shadow bytes that reconciliation can restore. Temporarily add owner-write permission to an existing regular shadow file, write it, and restore the guest mode (including on the error path), or use an equivalent sidecar-owned write helper.

Original location: "crates/native-sidecar/src/filesystem.rs":5130 (new side, not submitted inline).

eersnington added a commit that referenced this pull request Oct 21, 2026
Python and WASM/shell writes go only to the kernel VFS, so the VM root
shadow kept the bytes from filesystem.writeFile. The next shadow-to-kernel
sync saw the two sides differ and copied the stale shadow over the guest
edit, and treated a guest rm/recreate as a host deletion.

The shadow sync inventory now records a stamp for both sides at each
reconciliation. A shadow change reaches the kernel only when the kernel
node is unchanged since then, so every guest writer wins without a
per-runtime mirror. Seeded bootstrap content still imports as before.

Fixes #2022 and #1901. The Python test helper is adapted from #2023 by
ankssjain.

Co-authored-by: ankssjain <308424510+ankssjain@users.noreply.github.com>
@eersnington

Copy link
Copy Markdown
Member

closing this since #2070 fixes it in the shadow sync itself, so shell and wasm writes are covered too. thanks for tracking down the python side, i reused your test setup and credited you in the commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python edits to filesystem.writeFile-created files are reverted by shadow reconciliation

2 participants