Commit 138c9f9
committed
harden(rng): cap per-request entropy allocation to 64 KiB
Backports upstream firecracker PR firecracker-microvm#5762 (commit 7550869). Adds a
MAX_ENTROPY_BYTES (64 KiB) cap on the per-request rand_bytes
allocation in handle_one().
The pre-fix code did `vec![0; iovec.len()]` where `iovec.len()` is
the *sum* of all descriptor lengths in a chain, not the distinct
guest memory backing them. A guest can craft 255 overlapping
descriptors each claiming 16 MiB but all pointing to the same
guest physical memory, inflating iovec.len() to ~4 GiB and
exhausting host RAM.
No CVE was assigned upstream; AWS classifies this as a host
DoS hardening rather than a security advisory.
Operationally, SAFE microVMs do not attach an entropy device, so
the unfixed code path is unreachable in our deployment. This is
defence-in-depth for any future config that does attach one.
Manual port — could not be cherry-picked cleanly because by
v1.15.x the rng device holds an owned `self.buffer` field and
process_entropy_queue has a different signature. Most importantly,
IoVecBufferMut::len() returns u32 in v1.15.x but usize in v1.6.5,
which forced a small change to the cap arithmetic and the function
return path. The actual security-relevant change (the cap itself)
is the same as upstream.1 parent d3b81c2 commit 138c9f9
1 file changed
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
26 | 33 | | |
27 | 34 | | |
28 | 35 | | |
| |||
112 | 119 | | |
113 | 120 | | |
114 | 121 | | |
115 | | - | |
| 122 | + | |
| 123 | + | |
116 | 124 | | |
117 | 125 | | |
118 | 126 | | |
119 | 127 | | |
120 | 128 | | |
121 | | - | |
| 129 | + | |
122 | 130 | | |
123 | | - | |
| 131 | + | |
| 132 | + | |
124 | 133 | | |
125 | 134 | | |
126 | 135 | | |
| |||
0 commit comments