0xMiden / 0xMiden/protocol

NonFungibleAssetDelta cancellation doesn't verify asset equality before removing

未关闭
#3,135 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
132
派生
167
平均合并
1 天 23 小时
30 天内合并 PR
110

描述

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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。