Skip to content

common/gossmap: don't let a route hint with a reused scid modify a known channel - #9736

Open
AkashKP02 wants to merge 1 commit into
ElementsProject:masterfrom
AkashKP02:fix-routehint-known-scid
Open

AkashKP02 wants to merge 1 commit into
ElementsProject:masterfrom
AkashKP02:fix-routehint-known-scid

Conversation

@AkashKP02

Copy link
Copy Markdown

Fixes #9672

Problem

add_routehint in xpay only drops a hint hop whose pubkey is our own. A hop that reuses the short_channel_id of a channel we already know (with different endpoints) is turned into askrene-create-channel + askrene-update-channel.

gossmap_local_addchan only checks for duplicates among the localmods, so it records a new local channel. Then gossmap_apply_localmods finds the existing channel by scid and applies the hint's update to it. The known channel's cltv_expiry_delta (and fees) get overwritten, e.g. 6 becomes 1000 in the issue's example, and the hint's own edge is never created.

Fix

In gossmap_apply_localmods, when a mod was created by gossmap_local_addchan but the scid already exists in the map, compare the endpoints in the local channel_announcement with the existing channel's. If they differ, skip the mod entirely so it can't modify the known channel.

A new skipped flag on struct localmod makes gossmap_remove_localmods skip those mods too. Otherwise it would "restore" orig[] values that were never saved and corrupt the channel.

A local channel whose endpoints match the existing channel is still applied as before (e.g. a payee hint describing a real public channel, or a layer overriding it).

Tests

  • Adds common/test/run-gossmap_local-routehint.c, the test from the issue, plus a check that gossmap_remove_localmods leaves the channel unchanged.
    • Without the fix: cltv_expiry_delta after hint: 1000, assertion fails.
    • With the fix: stays 6, passes.
  • make check-units passes, including all gossmap, askrene and xpay unit tests.
  • check-whitespace, check-includes, check-amount-access, check-discouraged-functions pass.

Not covered

A payee reachable only through such a colliding hint is still unroutable ("Unknown destination node"). Supporting that would need xpay to map the hint to a fresh fake scid for route finding and back to the real scid in the onion.

… known channel

A route hint reusing the short_channel_id of a known channel with different endpoints overwrote that channel's cltv_expiry_delta and fees in xpay route finding. Skip such localmods in gossmap_apply_localmods, and don't restore them in gossmap_remove_localmods.

Fixes: ElementsProject#9672

Changelog-Fixed: xpay: a route hint reusing a known channel's short_channel_id no longer changes that channel's CLTV delay.
@AkashKP02

Copy link
Copy Markdown
Author

Hello @Sjors @hosiawak @asoltys, Please let me know your thoughts on this implementation when you have a moment.

This branch has not been deployed

No deployments
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.

A route hint reusing a known short_channel_id changes that channel's CLTV in xpay route finding

1 participant