0xMiden / 0xMiden/protocol

NonFungibleAssetDelta cancellation doesn't verify asset equality before removing

Aperta
#3,135 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
132
Fork
167
Merge medio
1g 23h
PR unite (30g)
110

Descrizione

`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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.