Smart Contract Diff Audit L-25: PSWAP Remainder Notes Drop Network Account Routing Metadata After Partial Fills
- Ngôn ngữ chính
- Rust
- Star
- 132
- Fork
- 167
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 110
Mô tả
A PSWAP note can be routed to a network account by carrying a `NetworkAccountTarget` attachment, registered as scheme `2` in [`NETWORK_ACCOUNT_TARGET_ATTACHMENT_SCHEME`](https://github.com/0xMiden/protocol/blob/8411bf093bde25285708faac152b6d7269009617/crates/miden-standards/asm/standards/attachments/network_account_target.masm#L14). The note documentation recommends [setting that attachment](https://github.com/0xMiden/protocol/blob/8411bf093bde25285708faac152b6d7269009617/crates/miden-standards/src/note/pswap.rs#L237-L239) for consumption in network transactions. On a partial fill, [`create_remainder_note`](https://github.com/0xMiden/protocol/blob/8411bf093bde25285708faac152b6d7269009617/crates/miden-standards/asm/standards/notes/pswap.masm#L340-L423) builds a fresh output note and adds only the PSWAP lineage attachment, without copying any attachment carried by the parent note. The Rust construction path behaves identically in [`create_remainder_pswap_note`](https://github.com/0xMiden/protocol/blob/8411bf093bde25285708faac152b6d7269009617/crates/miden-standards/src/note/pswap.rs#L781-L814), which sets the lineage word as the sole attachment of the remainder.
Consequently, the first partial fill strips the routing target from the order. The remainder no longer satisfies [`is_network_note`](https://github.com/0xMiden/protocol/blob/8411bf093bde25285708faac152b6d7269009617/crates/miden-standards/src/note/network_note.rs#L91-L94), which requires a public note whose attachments decode as a `NetworkAccountTarget`, so components that index or automatically consume notes on behalf of the targeted network account stop recognizing the leftover order. Any account can trigger this by consuming the note with a minimal fill amount. Assets remain safe, because the remainder inherits the tag and note type of the parent and the creator can still reclaim the unfilled asset, but a documented routing capability stops applying after the first partial fill without any signal to the note creator. Carrying both attachments is permitted at the protocol level, where a note may hold up to [`MAX_ATTACHMENTS_PER_NOTE`](https://github.com/0xMiden/protocol/blob/8411bf093bde25285708faac152b6d7269009617/crates/miden-protocol/asm/kernels/transaction-core/src/output_note.masm#L23) attachments, but `PswapNote` models a single optional attachment and [rejects](https://github.com/0xMiden/protocol/blob/8411bf093bde25285708faac152b6d7269009617/crates/miden-standards/src/note/pswap.rs#L864-L870) any note carrying more than one.
Consider copying the attachments of the parent note, at minimum `NetworkAccountTarget`, onto the remainder in `create_remainder_note` and its Rust counterpart, and extending `PswapNote` to model multiple attachments so that routing metadata can coexist with the PSWAP lineage attachment. If discarding routing metadata on remainder notes is intended, consider documenting that behavior and qualifying the recommendation to route PSWAP notes through a `NetworkAccountTarget` attachment.
---
_Copied verbatim from finding [L-25](https://audits.openzeppelin.com/miden/miden-01-07-smart-contract-diff-audit-nfts/issues/pswap-remainder-notes-drop-network-account-routing-metadata-after-partial-fills-a5d774f8) (low severity) of the OpenZeppelin [smart contract diff audit (NFTs)](https://audits.openzeppelin.com/miden/miden-01-07-smart-contract-diff-audit-nfts). The audit was performed against commit `8411bf093bde25285708faac152b6d7269009617`._
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.