Skip to content

fix: harden fs and net handlers - #68

Merged
danbugs merged 2 commits into
mainfrom
fix/re-audit-round2
May 17, 2026
Merged

fix: harden fs and net handlers#68
danbugs merged 2 commits into
mainfrom
fix/re-audit-round2

Conversation

@danbugs

@danbugs danbugs commented May 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Set read/write timeouts on accepted sockets — accept() returns a new socket that doesn't inherit parent timeouts, leaving net_recv on accepted connections able to block the host thread indefinitely
  • Cap fs_write_bytes offset to MAX_TRUNCATE_LEN (1 GiB) — previously a guest could pass multi-TB offsets to create sparse files, circumventing the truncate cap
  • Add MAX_DIR_ENTRIES (100k) cap to fs_list to prevent host OOM on directories with millions of entries
  • Guard fs_unlink against deleting the mount root directory itself

Test plan

  • cargo test --lib passes (56 tests)
  • cargo clippy clean
  • cargo fmt clean
  • CI validates no regressions

…-root guard

Signed-off-by: danbugs <danilochiarlone@gmail.com>
Copilot AI review requested due to automatic review settings May 17, 2026 08:00

Copilot AI 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.

Pull request overview

This PR hardens host-side filesystem and networking RPC handlers to reduce guest-driven resource exhaustion and prevent host-thread stalls during socket I/O. It fits into the host crate’s tool/handler layer where guest calls are translated into constrained host operations.

Changes:

  • Set read/write timeouts on sockets returned by accept() so accepted connections can’t block host threads indefinitely.
  • Add caps/guards in filesystem handlers: limit fs_list directory enumeration size, reject oversized fs_write_bytes offsets, and prevent fs_unlink from removing the mount root.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@danbugs danbugs changed the title fix: harden fs and net handlers (re-audit round 2) fix: harden fs and net handlers May 17, 2026
Signed-off-by: danbugs <danilochiarlone@gmail.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Linux Benchmarks

Details
Benchmark suite Current: 0dcbe53 Previous: 4c053f6 Ratio
hello_world (median) 20 ms 20 ms 1
pandas (median) 110 ms 90 ms 1.22
density (per VM) 7 MB 7 MB 1
snapshot (disk) 385 MiB 385 MiB 1

This comment was automatically generated by workflow using github-action-benchmark.

@danbugs
danbugs enabled auto-merge May 17, 2026 08:16

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Windows Benchmarks

Details
Benchmark suite Current: 0dcbe53 Previous: 4c053f6 Ratio
hello_world (median) 272 ms 181 ms 1.50
pandas (median) 876 ms 557 ms 1.57
density (per VM) 6 MB 6 MB 1
snapshot (disk) 392 MiB 392 MiB 1

This comment was automatically generated by workflow using github-action-benchmark.

@danbugs
danbugs merged commit 52a28ce into main May 17, 2026
211 of 217 checks passed
@danbugs
danbugs deleted the fix/re-audit-round2 branch May 17, 2026 08:25
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.

2 participants