0xMiden / 0xMiden/protocol

Smart Contract Diff Audit L-10: Truncated Procedure Roots Can Render Distinct Custom Procedures Identically

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

描述

The [`name`](https://github.com/0xMiden/protocol/blob/8411bf093bde25285708faac152b6d7269009617/crates/miden-standards/src/account/interface/component.rs#L91-L98) accessor renders the `Custom` variant of `AccountComponentInterface` by slicing the hexadecimal form of each procedure MAST root to its first nine characters, which retains the `0x` prefix and seven hex digits out of the sixty-four that a full root produces. The roots collected into that variant come from a set of distinct entries in [`from_procedures`](https://github.com/0xMiden/protocol/blob/8411bf093bde25285708faac152b6d7269009617/crates/miden-standards/src/account/interface/extension.rs#L42-L62), so two entries that render alike always denote genuinely different procedures, and the rendered list carries no index, deduplication, or other disambiguator.

The effect is confined to a human-readable label. Equality, serialization, and every protocol decision operate on the full root, and no caller of `name` exists in the repository, so the string is consumed only by downstream tooling. Because a MAST root is a deterministic hash of compiled code, however, a component author can grind trivial variants until a root matches a chosen 28-bit prefix. An operator who compares custom procedures through a renderer built on this label may therefore accept one procedure as another.

Consider including a collision-resistant identifier in the `Custom` display string, such as the full MAST root hexadecimal form or a substantially longer prefix and suffix pair. If the shortened form is retained, consider documenting that it is not a unique identifier and must not be relied upon to distinguish procedures.

---

_Copied verbatim from finding [L-10](https://audits.openzeppelin.com/miden/miden-01-07-smart-contract-diff-audit-nfts/issues/truncated-procedure-roots-can-render-distinct-custom-procedures-identically-d44ce616) (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`._

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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