AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 69 Bitcoin

optiga: fix detached buffer reuse

Public commit record

What the developer wrote

Authored by Marko Bencun

68/100 · Adequate
optiga: fix detached buffer reuse

The Optiga C API keeps raw pointers to the Rust wrapper's static
buffers until the asynchronous callback completes. The Rust wrapper
has a Detached state for futures that were dropped after launching a
command, but the individual wrappers initialized their per-operation
static buffers before calling begin_async_op().

That meant a repeated call to the same wrapper could clear or
overwrite the exact static storage still owned by the detached C
command before begin_async_op() noticed the Detached state and waited
for the old callback.

Move begin_async_op().await before every static buffer or length-cell
mutation. Detached operations are now reclaimed before any static
storage is reused, and live concurrent operations still panic before
their buffers can be corrupted.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This patch fixes a timing bug in how the BitBox02 hardware wallet talks to its secure chip (Optiga). Previously, the code could overwrite memory buffers that were still being used by an unfinished, dropped secure-chip operation. That could corrupt data or cause the device to behave unpredictably when secure-chip commands were started and then abandoned. The fix simply makes sure the code checks for and reclaims any leftover detached operation before touching the shared buffers.

Recommended action

Treat this as a security-relevant firmware bug. Apply the patch and verify that concurrent or repeated secure-chip operations no longer trigger buffer corruption. Add regression tests or fuzzing around dropped futures and repeated async secure-chip calls if not already present. Consider whether other async FFI wrappers in the codebase have the same pattern.

Security signals we found

01

Use-after-free-like pattern on static buffers shared with asynchronous C code

02

Detached async operation state not reclaimed before buffer reuse

03

Potential memory corruption or incorrect secure-chip command results

04

Fix is purely reordering; no new locks or allocations added

05

Affects cryptographic operations: HMAC, ECDSA sign, symmetric encrypt/decrypt, random generation, key generation

Risk score

Why this scored 69/100

Our methodology →
Potential impact 22/30
Exploitability 14/25
Stealth signal 10/15
Affected reach 12/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.