PT-2026-83513 · Crates.Io · Block Buffer

Publicado

2026-08-19

·

Atualizado

2026-08-19

CVSS v4.0

6.3

Média

VetorAV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N

Summary

A caught panic may leave the cursor position of EagerBuffer or ReadBuffer in a corrupted state; this in turn allows out-of-bounds reads/writes.

Details & PoC

The following two tests fail miri:
rust
#[cfg(miri)]
#[test]
fn eager digest blocks panic corrupts inline position() {
  // `EagerBuffer` stores its cursor in the last byte of the internal block.
  // When `digest blocks` completes a previously partial block, it overwrites
  // that byte with input data before invoking the caller-provided `compress`
  // callback. If the callback panics, safe code can catch the panic and keep
  // using the buffer while its cursor byte no longer satisfies the internal
  // `pos < block size` invariant. Under Miri this `get pos` call reaches the
  // `unreachable unchecked` used for the assumed-valid cursor.
  let mut buf = EagerBuffer::<U4>::new(&[1, 2]);

  let  = std::panic::catch unwind(std::panic::AssertUnwindSafe(|| {
    buf.digest blocks(&[3, 0xff], | | panic!("simulated compression failure"));
  }));

  let  = buf.get pos();
}

#[cfg(miri)]
#[test]
fn read buffer generator panic corrupts inline position() {
  // `ReadBuffer` stores its cursor in `buffer[0]`, but `write block` gives
  // `gen block` mutable access to the whole internal block before restoring
  // `buffer[0]` to a valid cursor. If `gen block` writes an arbitrary first
  // byte and panics, safe code can catch the panic and later observe an
  // invalid cursor. Under Miri this `get pos` call reaches the
  // `unreachable unchecked` used for the assumed-valid cursor.
  let mut buf = ReadBuffer::<U4>::default();

  let  = std::panic::catch unwind(std::panic::AssertUnwindSafe(|| {
    buf.write block(
      1,
      |block| {
        block[0] = 0xff;
        panic!("simulated block generation failure");
      },
      | | {},
    );
  }));

  let  = buf.get pos();
}
They fail on an unreachable unchecked!() under the invariant for the pos to always be within bounds of the block.

Impact

While the byte that overwrites pos may come from untrusted input and is therefore attacker-controlled, this still relies on the surrounding code catching the panic and carrying on, which should be uncommon in practice.
For this to be exploitable, the attacker also needs a way to trigger a panic here; I have not investigated how feasible that is.

Credits

The issue was discovered by GPT-5.5

Correção

Buffer Overflow

Encontrou algum problema na descrição? Tem algo a acrescentar? Fique à vontade para nos escrever 👾

Enumeração de Fraquezas

Identificadores relacionados

GHSA-QWGH-2VCV-G2F7

Produtos afetados

Block Buffer