0xMiden / 0xMiden/protocol

NonFungibleAssetDelta cancellation doesn't verify asset equality before removing

Abierto
#3,135 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
132
Forks
167
Merge medio
1 d 23 h
PR fusionados (30 d)
110

Descripción

`crates/miden-protocol/src/account/delta/vault.rs:427-439`:
```rust
fn apply_action(&mut self, asset: NonFungibleAsset, action: NonFungibleDeltaAction) -> ... {
match self.0.entry(asset.vault_key()) {
Entry::Vacant(entry) => { entry.insert((asset, action)); },
Entry::Occupied(entry) => {
let (_prev_asset, previous_action) = *entry.get();
if previous_action == action {
return Err(...);
}
entry.remove(); // cancel out — but discards `asset`
},
}
}
```

When a non-fungible asset is added and then removed (opposite actions), the entry is removed from the map. But the second call discards the `asset` parameter entirely it doesn't verify that the asset being removed matches the one that was added beyond having the same vault key. If two distinct non-fungible assets happen to share a vault key (same faucet ID, same asset ID), the cancellation silently drops the second operation without checking asset equivalence.

Fix: verify the removed asset matches the previously added asset before cancelling.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.