0xMiden / 0xMiden/protocol

NonFungibleAssetDelta cancellation doesn't verify asset equality before removing

Offen
#3,135 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
132
Forks
167
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
110

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.