|
impl<'a, T> Iterator for Drain<'a, T> { |
|
type Item = (HeaderName, ValueDrain<'a, T>); |
|
|
|
fn next(&mut self) -> Option<Self::Item> { |
HeaderMap::Drain implements Iterator trait with Item = (HeaderName, ValueDrain<'a, T>). This definition makes it possible to create multiple mutable references to the underlying HeaderMap by creating multiple ValueDrain, because there is no relation between the lifetime of &mut self and the returned ValueDrain.
This bug may invalidate ValueDrain iterators or make them return incorrect results. In multi-threaded scenario, the bug allows multiple threads to mutate underlying Vec at the same time, which I believe exploitable. However, I expect no code is sending ValueDrain to the other thread in practice.
Demonstration
http/src/header/map.rs
Lines 2099 to 2102 in 9c05e39
HeaderMap::DrainimplementsIteratortrait withItem = (HeaderName, ValueDrain<'a, T>). This definition makes it possible to create multiple mutable references to the underlyingHeaderMapby creating multipleValueDrain, because there is no relation between the lifetime of&mut selfand the returnedValueDrain.This bug may invalidate
ValueDrainiterators or make them return incorrect results. In multi-threaded scenario, the bug allows multiple threads to mutate underlyingVecat the same time, which I believe exploitable. However, I expect no code is sendingValueDrainto the other thread in practice.Demonstration