fix(agglayer): replace NoAuth with AuthNetworkAccount on bridge and faucet#2818
Conversation
NoAuth with NetworkAccount on bridge and faucet
|
Note: this and the supporting PR(s) should be cherry-picked into the |
|
I think this PR is a requirement before we can remove My understanding is this PR deals with the bridge and agglayer faucet, so the next step after this PR is to migrate the network fungible faucet (as created by |
4e73ef7 to
21b4307
Compare
NoAuth with NetworkAccount on bridge and faucetNoAuth with AuthNetworkAccount on bridge and faucet
92bbfd3 to
275e441
Compare
Closes #2797. Installs the AuthNetworkAccount auth component on both the AggLayer bridge and the AggLayer faucet, with per-account allowlists of input-note script roots. Both accounts now reject any transaction that runs a tx script or consumes a note whose script root is outside the allowlist, preventing a forged-MINT path where a transaction against the bridge could emit a bridge-authored MINT note. Allowlists: - Bridge: CLAIM, B2AGG, CONFIG_AGG_BRIDGE, UPDATE_GER - Faucet: MINT, BURN Changes: - crates/miden-agglayer/src/lib.rs: install AuthNetworkAccount in create_bridge_account, create_existing_bridge_account, create_agglayer_faucet, create_existing_agglayer_faucet. Add helper functions bridge_note_allowlist() and faucet_note_allowlist(), plus a claim_script_root() accessor mirroring the other note wrappers. - crates/miden-agglayer/build.rs: compute BRIDGE_CODE_COMMITMENT and FAUCET_CODE_COMMITMENT using AuthNetworkAccount with a placeholder allowlist (allowlist contents do not affect the code commitment, and AuthNetworkAccount rejects empty allowlists at construction time). - crates/miden-testing/tests/agglayer/network_account_regression.rs: two tests against a bridge built with the production create_existing_bridge_account helper, covering the tx-script rejection and non-allowlisted-note rejection paths.
275e441 to
1441d6a
Compare
|
Rebased onto |
bobbinth
left a comment
There was a problem hiding this comment.
Looks good! Thank you! I reviewed only non-test code and left some small comments inline.
- AggLayerBridge::allowed_notes() / AggLayerFaucet::allowed_notes() replace the free bridge_note_allowlist() / faucet_note_allowlist() helpers. - .with_auth_component(...) is installed inside the bridge and faucet builders, so the four create_* wrappers stop duplicating it. - ClaimNote unit struct with ClaimNote::script() / ClaimNote::script_root() replaces the free claim_script() / claim_script_root() in lib.rs, matching the B2AggNote / ConfigAggBridgeNote / UpdateGerNote shape. - build.rs comment: the placeholder allowlist lives in storage, not code, so it does not affect the computed code commitment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- AggLayerBridge::allowed_notes() / AggLayerFaucet::allowed_notes() replace the free bridge_note_allowlist() / faucet_note_allowlist() helpers. - .with_auth_component(...) is installed inside the bridge and faucet builders, so the four create_* wrappers stop duplicating it. - ClaimNote unit struct with ClaimNote::script() / ClaimNote::script_root() replaces the free claim_script() / claim_script_root() in lib.rs, matching the B2AggNote / ConfigAggBridgeNote / UpdateGerNote shape. - build.rs comment: the placeholder allowlist lives in storage, not code, so it does not affect the computed code commitment.
776b2c5 to
81e2f66
Compare
|
Force-pushed |
Co-authored-by: Marti <marti@miden.team>
Mirrors the constructor pattern used by B2AggNote, ConfigAggBridgeNote, and UpdateGerNote. Addresses review feedback on #2818.
- bridge_rejects_tx_script: also consume an allowlisted UPDATE_GER input note, proving the tx-script check fires independently of the input-note check. - bridge_rejects_non_allowlisted_input_note: replace the generic NoteBuilder note with an attack script that lexically mirrors B2AGG's bridge entrypoint (call.bridge_out::bridge_out) but resolves to a different script root, so the bridge rejects it even though it looks like an allowed note. Addresses review feedback on #2818.
Calling bridge_out::bridge_out from the test isn't feasible — its input preconditions panic before the @auth_script allowlist check can fire, so the test would see the wrong error. Since the allowlist check is purely on script root, a minimal script with a non-allowlisted root suffices.
|
Noted. Will cherry-pick into the |
mmagician
left a comment
There was a problem hiding this comment.
LGTM thanks for applying the review changes!
Pulls in `next` so the changelog includes both v0.15.0 Fixes entries (#2818 AuthNetworkAccount and #2911 asset-in-storage MINT bind), and ports the new regression test in this branch (`test_mint_cannot_be_consumed_by_unrelated_faucet`) to the renamed `ClaimNote::create` API from #2849 (`c738f26e refactor(agglayer): move create_claim_note into impl ClaimNote::create`). No production logic changes from this branch; CHANGELOG auto-merged cleanly (both bullets coexist under v0.15.0 Fixes) and the bridge_in test file was the only call site still using the old free function.
PR #2818 installed `AuthNetworkAccount` on both the AggLayer bridge AND the AggLayer faucet (with `allowed_notes() = {MintNote, BurnNote}`), but only added regression tests for the bridge side. Pre-push code-review flagged the gap. Adds two faucet-side tests symmetric to `bridge_rejects_tx_script` and `bridge_rejects_non_allowlisted_input_note`: - `faucet_rejects_tx_script`: any transaction submitting a tx script against an AggLayer faucet aborts with `ERR_NOTE_SCRIPT_ALLOWLIST_TX_SCRIPT_NOT_ALLOWED`. - `faucet_rejects_non_allowlisted_input_note`: any input note whose script root is neither MINT nor BURN aborts with `ERR_NOTE_SCRIPT_ALLOWLIST_NOTE_NOT_ALLOWED`. Without these, a future refactor that drops the faucet's auth component or breaks its allowlist would keep the suite green and re-open the forged-MINT attack surface that #2797 / #2818 set out to close.
Summary
Closes #2797.
Installs the
AuthNetworkAccountauth component (added in #2817) on both the AggLayer bridge and the AggLayer faucet, with per-account whitelists of input-note script roots. This closes the forged-MINT attack surface: an attacker can no longer finalize an arbitrary transaction against the bridge and emit a bridge-authoredMINTnote.Allow lists for agglayer network accounts
CLAIM,B2AGG,CONFIG_AGG_BRIDGE,UPDATE_GERMINT,BURNStacking
This PR is the final one in the #2797 fix chain:
tx::get_script_rootkernel procedureNetworkAccountauth component #2817 —NetworkAccountauth component (merged tonextweird GH bug make it look like this PR was closed)