getroutes: don't crash on source==destination
What changed, and why it matters
This commit fixes a crash in Core Lightning's routing plugin (cln-askrene). When a user called the getroutes command with the same node as both source and destination, the plugin hit an internal assertion and aborted. The fix adds a simple input check that rejects source==destination with a normal RPC error instead of crashing the plugin.
Apply the patch to add the source/destination equality check and enable the regression test. No further immediate action is required; this is a straightforward input-validation hardening fix.
Security signals we found
Denial-of-service via malformed RPC input causing plugin abort
Assertion failure in routing plugin child process
Input validation gap in JSON-RPC command handler
Evidence from the diff
The askrene child process crashed in final_hop() because tal_count(hops) was 0 when source and destination were identical. The patch adds an explicit node_id_eq(source, dest) validation in json_getroutes() before processing, returning JSONRPC2_INVALID_PARAMS. A test that was previously marked as expected-to-fail (xfail) is now enabled, confirming the crash is resolved.
Changed components
plugins/askrene/askrene.cplugins/askrene/child/child.ccln-askrene pluginInspect captured patch +5 / −1
diff --git a/plugins/askrene/askrene.c b/plugins/askrene/askrene.c
index 736054eb..70247c1e 100644
--- a/plugins/askrene/askrene.c
+++ b/plugins/askrene/askrene.c
@@ -943,6 +943,11 @@ static struct command_result *json_getroutes(struct command *cmd,
maxdelay_allowed);
}
+ if (node_id_eq(source, dest)) {
+ return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
+ "source and destination must be different");
+ }
+
if (command_check_only(cmd))
return command_check_done(cmd);
diff --git a/tests/test_askrene.py b/tests/test_askrene.py
index 6d05583f..4474ec32 100644
--- a/tests/test_askrene.py
+++ b/tests/test_askrene.py
@@ -2669,7 +2669,6 @@ def test_impossible_payment(node_factory):
)
-@pytest.mark.xfail(strict=True)
def test_bad_user_entries(node_factory):
"""Test bad user entries that should result in an RPC error and not crash
lightningd."""
Why this scored 59/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.