Repository navigation
Conversation
Withdraw only reads the nullifier state during proof verification and writes it after the payout, so the same proof repeated in one MixWithdrawAction was paid N times. Deposit accumulates note amounts in a uint64 without an overflow check, so several notes whose values sum past 2^64 could be recorded in the Merkle tree after paying only the wrapped remainder. - ForkMixDupNullifier: deduplicate nullifiers inside one action. - ForkMixAmountOverflow: reject v.Uint64() that would overflow MaxInt64-sum before accumulating. Both forks are registered defaulting to height 0; set a future height in the fork config to keep the legacy behavior for an existing chain.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
本次 v1.76.3 审计发现 mix 执行器两处可直接盗取资金池的问题:
withdrawVerify/spendVerify只读状态检查 nullifier 是否存在,nullifier KV 在整笔 action 付款完成后才写入,且循环内不写库。同一MixWithdrawAction里重复放同一个 proof,把Amount写成N*value即可通过sumValue == Amount校验,同一张票据被支付 N 次。sum += v.Uint64()无溢出检查,付款使用int64(sum)。构造多张单张可正常取出的票据,使总和超过 2^64,实际只支付回绕后的零头,票据仍按原面额逐张进入 Merkle 树后取出。修复
ForkMixDupNullifier:Withdraw在单笔 action 内维护 nullifier 集合,重复直接返回ErrNulliferHashExist。ForkMixAmountOverflow:Deposit累加前校验v.Uint64() > math.MaxInt64 - sum,溢出返回ErrAmountOverflow。两个分叉默认注册为高度 0;老链如需保持旧共识行为,在
[fork.sub.mix]中配置为未来高度即可。验证
go build ./plugin/dapp/mix/...通过go test ./plugin/dapp/mix/executor/ -count=1通过(既有执行器套件)