Skip to content

fix(bridge): bound Hyperliquid withdrawal legs and pin the deposit address - #841

Open
kome12 wants to merge 2 commits into
mainfrom
fix/hl-bridge-leg-count-destination
Open

kome12 wants to merge 2 commits into
mainfrom
fix/hl-bridge-leg-count-destination

Conversation

@kome12

@kome12 kome12 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

What

bridge execute on a Hyperliquid withdrawal (hyperliquid_signature quote) now refuses, before signing anything:

  • a plan that isn't at most one authorize plus exactly one sendAsset (counting legs not yet complete), mirroring the existing EVM deposit check;
  • a sendAsset whose destination isn't Relay's Hyperliquid deposit address (0x66cf0aace1b4e562593bec10ec7868fba9932224).

Why

The HL plan was validated one leg at a time. A plan with several sendAsset legs, each within the amount cap, would have every leg signed and submitted, withdrawing a multiple of the requested amount. destination is part of the signed payload but was never checked, so a withdrawal could also be sent to any HL address.

The pinned address is the same in live read-only quotes for all three withdrawal routes (HL → base / ethereum / arbitrum) and in earlier captures. If Relay changes it, HL withdrawals fail closed with an "update nansen-cli" message, the same trade-off as the EVM router pin.

Testing

  • New unit and execute-level tests for both checks, on the local and Privy signing paths. Each asserts nothing was signed or posted and the quote was not used up. All 14 fail against the previous bridge.js.
  • Before / after with a mocked tampered quote: two sendAsset legs went from 2 HL exchange POSTs to refused with 0; a foreign destination went from 1 POST to refused with 0.
  • bridge execute --dry-run on real HL → base / ethereum / arbitrum quotes passes, so legitimate quotes are not blocked.
  • Four existing fixtures updated: three used the user's wallet as destination, and one used an authorize-only plan.
  • npm test, npm run lint.

🤖 Generated with Claude Code

…dress

A hyperliquid_signature bridge plan was validated leg by leg, so a plan
with several sendAsset legs (each within the amount cap) would sign and
submit all of them. The sendAsset destination, which the signature
commits to, was never checked.

preflightHlBridgeSteps now requires at most one authorize and exactly
one sendAsset among the incomplete legs, mirroring the EVM deposit
check. assertHlBridgeActionIntent now requires the destination to be
Relay's Hyperliquid deposit address, captured from live quotes for all
three withdrawal routes. Both refuse before anything is signed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/bridge.js Resolved
@nansen-pr-reviewer

nansen-pr-reviewer Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

nansen-pr-reviewer summary

The diff adds fail-closed validation for Hyperliquid withdrawal destinations and bounds bridge plans to a single sendAsset leg. The previously reported resumed-plan leg-count issue is fixed by counting completed action items in totalActionCount while separately requiring exactly one pending leg. Tests cover local, Privy, repeated-leg, resumed-plan, and destination-tampering paths.

Deterministic check: success — No issues found

Risk: 3/5 (Elevated)

✅ Auto-approved — Deterministic gates passed: severity thresholds met, recommendation "approve", risk level 3/5 within threshold 3.


Token usage: 45,462 input, 1,345 output, 6,557 cache read | Usage Guide

Cooldown: for the next 10 minutes (counting from when this review finished), new pushes to this PR will not trigger another review — the next push after the window expires will. Need a fresh review sooner? Comment @nansen-pr-reviewer[bot] re-review.

A real Hyperliquid withdrawal has exactly one sendAsset leg in total, so
a plan with a completed sendAsset plus another pending one is now
refused too. Completed legs are still not re-validated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@nansen-pr-reviewer nansen-pr-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Auto-approved by Nansen review

Deterministic gates passed: severity thresholds met, recommendation "approve", risk level 3/5 within threshold 3.

  • The deterministic severity check passed: No issues found
  • Risk level 3/5 (Elevated)
  • The model recommended: approve

Approval was decided by deterministic gates, not by the model. The model's recommendation can block auto-approval but never cause it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant