Skip to content

fix: cap AllowList learned_ips at 256 entries - #63

Merged
danbugs merged 2 commits into
mainfrom
fix/cap-learned-ips
May 17, 2026
Merged

fix: cap AllowList learned_ips at 256 entries#63
danbugs merged 2 commits into
mainfrom
fix/cap-learned-ips

Conversation

@danbugs

@danbugs danbugs commented May 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Caps the learned_ips HashSet in AllowList at 256 entries to prevent unbounded memory growth from DNS response learning
  • A guest performing many DNS lookups for allowed hostnames could previously grow this set without limit
  • Adds allowlist_learned_ips_capped test verifying the cap

Test plan

  • cargo test --lib passes (54 tests)
  • cargo clippy clean
  • cargo fmt clean

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

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 caps DNS-learned allowlist IPs to prevent unbounded memory growth when processing DNS responses for allowed hostnames.

Changes:

  • Adds MAX_LEARNED_IPS with a 256-entry limit.
  • Updates AllowList::learn_ip to stop inserting once the cap is reached.
  • Adds a unit test covering the learned IP cap.

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

Comment thread host/src/lib.rs Outdated
#[test]
fn allowlist_learned_ips_capped() {
use std::net::{IpAddr, Ipv4Addr};
let al = AllowList::from_hosts(&["example.com"]).unwrap();

@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: 740cd06 Previous: 2c92788 Ratio
hello_world (median) 20 ms 20 ms 1
pandas (median) 100 ms 110 ms 0.91
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: 740cd06 Previous: 2c92788 Ratio
hello_world (median) 291 ms 187 ms 1.56
pandas (median) 1023 ms 545 ms 1.88
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.

Signed-off-by: danbugs <danilochiarlone@gmail.com>
@danbugs
danbugs merged commit 5198570 into main May 17, 2026
79 checks passed
@danbugs
danbugs deleted the fix/cap-learned-ips branch May 17, 2026 07:03
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