Skip to content

fix: add resource caps and DNS pointer-loop guard - #67

Merged
danbugs merged 1 commit into
mainfrom
fix/dns-pointer-loop
May 17, 2026
Merged

fix: add resource caps and DNS pointer-loop guard#67
danbugs merged 1 commit into
mainfrom
fix/dns-pointer-loop

Conversation

@danbugs

@danbugs danbugs commented May 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds MAX_DISPATCH_PAYLOAD (64 MiB) — rejects oversized dispatch payloads before JSON parsing to prevent host OOM
  • Adds MAX_FS_WRITE (16 MiB) — caps fs_write and fs_write_bytes payloads (matching the existing MAX_FS_READ)
  • Adds MAX_TRUNCATE_LEN (1 GiB) — prevents guest from creating extremely large sparse files via fs_truncate
  • Adds hop counter (max 128) to dns_read_name to prevent infinite loops from circular DNS compression pointers in crafted responses

Test plan

  • All 55 existing unit tests pass
  • CI validates no regressions in runtime tests

…inter-loop guard

- Add MAX_DISPATCH_PAYLOAD (64 MiB) check at top of dispatch()
- Add MAX_FS_WRITE (16 MiB) check in fs_write and fs_write_bytes
- Add MAX_TRUNCATE_LEN (1 GiB) check in fs_truncate
- Add hop counter (max 128) in dns_read_name to prevent infinite
  loops from circular DNS compression pointers

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

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 dispatch and filesystem/DNS handling by adding resource caps and a DNS compression-pointer loop guard.

Changes:

  • Adds payload limits for dispatch, filesystem writes, and truncation.
  • Rejects oversized write/truncate operations with explicit errors.
  • Adds a DNS name pointer hop counter to avoid infinite loops.

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

Comment thread host/src/lib.rs
));
}
let offset = args["offset"].as_u64();
let append = args["append"].as_bool().unwrap_or(false);
Comment thread host/src/lib.rs
Comment on lines +1154 to +1156
hops += 1;
if hops > 128 {
return None;

@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: 4611c78 Previous: 5198570 Ratio
hello_world (median) 20 ms 20 ms 1
pandas (median) 110 ms 110 ms 1
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.

@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: 4611c78 Previous: 5198570 Ratio
hello_world (median) 228 ms 191 ms 1.19
pandas (median) 655 ms 540 ms 1.21
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 f096ea1 into main May 17, 2026
80 checks passed
@danbugs
danbugs deleted the fix/dns-pointer-loop branch May 17, 2026 07:51
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