Skip to content

repro + fix: rgb forward checks - #42

Open
orbitalturtle wants to merge 4 commits into
RGB-Tools:rgbfrom
orbitalturtle:fix/rgb-forward-check
Open

orbitalturtle wants to merge 4 commits into
RGB-Tools:rgbfrom
orbitalturtle:fix/rgb-forward-check

Conversation

@orbitalturtle

@orbitalturtle orbitalturtle commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Stops a sender from draining a router's RGB channel balance by making the router forward RGB it never received. The test hooks let RLN reproduce each attack (RGB-Tools/rgb-lightning-node#181).

Variants:

  1. HTLC carries less than the onion asks the router to forward.
  2. HTLC carries no RGB, but the onion asks for some.
  3. HTLC carries asset A, but the onion asks for asset B.
  4. HTLC claims asset B on a channel colored with asset A.
  5. A swap maker adds outbound RGB to a BTC → asset swap (fixed in RLN's swap handler; documented at is_swap).

Fixes:

  • Forward check (1–3): outgoing RGB must be the same contract as the incoming RGB, with out <= in, or there must be no RGB on either side. Swaps are exempt and rely on the node's intercept handler.
  • Channel binding (4): update_add_htlc and send_htlc reject a contract that doesn't match the channel's asset.
  • Failure reasons: forwarders now report invalid_onion_payload (forward check) or temporary_channel_failure (send_htlc), instead of the final-node code final_incorrect_htlc_amount.

🚨 CI depends on #41, so please merge that first.

@orbitalturtle
orbitalturtle force-pushed the fix/rgb-forward-check branch from 3cd71a2 to 5bd445e Compare October 9, 2026 19:52
@orbitalturtle
orbitalturtle force-pushed the fix/rgb-forward-check branch 4 times, most recently from bb8e3bd to f68028e Compare October 13, 2026 20:30
@orbitalturtle orbitalturtle changed the title repro + fix: rgb forward check repro + fix: rgb forward checks Oct 13, 2026
Test-only hooks that let RLN integration tests simulate attacks which
allow a sender to drain a router node's RGB channel balance.
FORCE_FIRST_HOP_RGB_PAYMENT_ON_NODE puts an arbitrary RGB payment, or
none, into the first hop's update_add_htlc while leaving the onion
payloads untouched. FORCE_UPDATE_ADD_HTLC_RGB_CONTRACT_TO_PEER rewrites
the contract of the RGB payment in the update_add_htlc sent to a peer.
FORCE_SECOND_HOP_RGB_PAYMENT_ON_NODE sets the RGB payment the first hop
is asked to forward, without changing what it receives.
Add RgbForwardNotCoveredByIncoming, reported as invalid_onion_payload,
for a forwarding node whose onion asks for more RGB than the HTLC it
received carries, and RgbAssetNotCarriedByChannel, reported as
temporary_channel_failure, for a channel that isn't colored with the
HTLC's asset.

Co-Authored-By: Claude
For a forwarded HTLC the incoming RGB amount and contract travel in
update_add_htlc while the outgoing ones sit in the sender-controlled
onion payload, and nothing compared the two. A sender could ask a
router node to forward more of one asset (or a different asset) than
the router node received, effectively stealing the routing node's
funds.

Add check_forwarded_rgb in create_fwd_pending_htlc_info requiring both
sides to either carry no RGB at all or carry the same contract with
outgoing <= incoming.
Commitment coloring uses the channel's own asset, so an HTLC naming
another contract was accepted and forwarded as if it carried that one.
Reject mismatches on update_add_htlc and send_htlc.

Co-Authored-By: Claude
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