Skip to content

incentive: high-s signature malleability asymmetry — vouchers accepted off-chain are unsettleable on-chain (free delivery / settlement griefing) #836

Closed

Description

@thiras

Surfaced by a full-repository review (2026-06-09).

Finding

Off-chain voucher verification (recover_signer, crates/incentive/src/voucher.rs:160-165; also channel.rs:275-277, bind_sig.rs:119-122) uses alloy's recover_address_from_prehash, which internally calls normalized_s() — it silently accepts a high-s (non-canonical) ECDSA signature and recovers the correct signer.

On-chain, PaymentChannel._verifyVoucher (contracts/src/PaymentChannel.sol:642) uses OpenZeppelin SignatureChecker, whose ECDSA.tryRecover rejects high-s with InvalidSignatureS.

The node persists the signature bytes verbatim (channel.rs:292; alloy's as_bytes() does not normalize), so the exact high-s bytes are what later get submitted to withdraw/closeChannel.

Impact

A malicious client deliberately signs vouchers with high-s:

  1. The node accepts the voucher in apply_voucher, serves the bytes, and advances last_nonce.
  2. At settlement, withdraw/closeChannel revert (InvalidSignatureS).
  3. The replay guard requires nonce > last_nonce, so the node can never obtain a replacement low-s voucher for that nonce — the accrued value is unrecoverable on-chain.

Net effect: free delivery for the attacker, or settlement griefing.

The same asymmetry applies to slash evidence: a high-s slash_sig (probe_sig.rs / stream_sig.rs) verifies off-chain but would fail at the on-chain SlashJudge, silently weakening collected evidence.

Fix

Reject non-canonical s at acceptance time (check signature.s() > secp256k1n/2 → InvalidSignature) in voucher verification, and mirror the check in the probe_sig/stream_sig/bind_sig paths, so the off-chain accept-set exactly matches the on-chain verifiable-set. Add a regression test that flips a valid signature to its high-s form and asserts rejection.

Refs

Activity

  1. added
    kind:bug
    kind:security
    prio:high
    on Jun 9, 2026
  2. github-actions commented on Jun 9, 2026

    @github-actions

    🎯 Triage report

    A directly exploitable off-chain / on-chain signature acceptance asymmetry in crates/incentive: alloy's recover_address_from_prehash silently normalises high-s ECDSA signatures during verification, but OpenZeppelin's ECDSA.tryRecover (used in PaymentChannel._verifyVoucher) hard-rejects them. Because persisted signature bytes are never normalised, any voucher signed with a high-s value will be accepted by the node, served against, and then permanently fail on-chain settlement — with no recovery path due to the nonce replay guard. The same asymmetry affects slash-evidence paths (probe_sig.rs, stream_sig.rs).

    📊 Assessment

    Dimension Value Reasoning
    Type Bug Correctness defect with direct financial exploit path
    Labels critical, poc-blocking, rust added Unrecoverable-value-loss attack is above high; payment settlement is PoC-blocking; fix is purely in Rust
    Coding agent Suitable Root cause, all affected file locations, fix strategy, and test requirement are fully specified

    🔗 Similar issues

    💡 Notes and suggestions

    Affected locations (all must be patched in lockstep):

    • crates/incentive/src/voucher.rs:160-165 (recover_signer)
    • crates/incentive/src/channel.rs:275-277
    • crates/incentive/src/bind_sig.rs:119-122
    • crates/incentive/src/probe_sig.rs (slash-evidence path)
    • crates/incentive/src/stream_sig.rs (slash-evidence path)

    Fix pattern:

    // After recovering the signature, before accepting it:
    let s = signature.s();
    if s > secp256k1::Scalar::from_be_bytes(SECP256K1N_HALF).unwrap() {
        return Err(Error::InvalidSignature); // non-canonical s
    }

    Alternatively, use k256::ecdsa::Signature::normalize_s() and check whether normalisation changed the bytes — reject if it did (so the caller must re-sign). Do not silently normalise and store the corrected bytes; the node should never accept a voucher it can only make valid by mutating it.

    Regression test outline:

    1. Sign a valid voucher to get a canonical low-s signature.
    2. Compute the high-s form: s' = secp256k1n - s, v' = 1 - v (or flip the recovery bit).
    3. Assert apply_voucher (or the equivalent verify call) returns Err(InvalidSignature).
    4. Assert the original low-s form still passes.

    Checklist:

    • Add is_high_s guard in voucher.rs::recover_signer
    • Mirror guard in channel.rs, bind_sig.rs
    • Mirror guard in probe_sig.rs, stream_sig.rs
    • Add #[test] fn rejects_high_s_voucher regression test
    • Add #[test] fn rejects_high_s_slash_sig regression test
    • Verify no storage/serialisation path normalises silently (search as_bytes() call sites)

    Note for reviewer: OZ's ECDSA.tryRecover follows EIP-2 (only low-s canonical signatures). The alloy normalized_s() path is intended for producing canonical signatures, not enforcing that incoming ones are canonical. The fix is purely additive (new rejection branch), so no migration of stored state is needed — existing valid vouchers all have low-s values by construction if signers used any EIP-2-compliant library.

    Generated by Agentic Triage for issue #836 · sonnet46 540.1K · ◷

    Add this agentic workflows to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/issue-triage.md@94ec5db57374c5b04a4b8eef8b4413f9af44d63f
    
  3. added
    prio:critical
    rust
    on Jun 9, 2026
  4. self-assigned this
    on Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind:bugkind:securityprio:criticalprio:highrust

Type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions