Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Demand-driven automatic channel opening - #615

Draft
markettes wants to merge 10 commits into
mainfrom
feat/auto-opening-channels
Draft

markettes wants to merge 10 commits into
mainfrom
feat/auto-opening-channels

Conversation

@markettes

Copy link
Copy Markdown
Contributor

Turns forwards refused for lack of outbound into per-peer ChannelOpenRecommendation rows: burst-collapsed failure evidence, a profitability gate, and Buffer/Draining sizing with explicit clamps.
Operators review and promote them from the Routing Management panel; in Auto mode AutoChannelOpenJob promotes under a per-node budget — promotion removes the human decision, never the signature.
A promoted channel opens at the fee policy we already charge that peer rather than the global default, captured alongside the evidence it was gated on.
Adds per-node wallet/mode/budget/cost-to-earn config, three migrations, and unit tests for the planner, the job, the promotion service and the repositories.


Stack created with GitHub Stacks CLI • Give Feedback 💬

@markettes
markettes added this pull request to stack #617 October 1, 2026 16:31
@markettes
markettes requested a review from Jossec101 October 1, 2026 17:05
@markettes
markettes force-pushed the feat/auto-opening-channels branch from 5ea755f to 889dd00 Compare October 2, 2026 08:46

@Jossec101 Jossec101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I do think we can make this simpler, that burst detection is something we can avoid imho and just do a histeresys on what worked in the past and what's failing recently and just open channel.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As feedback consolidate all in one next time pls :P

Comment on lines +59 to +66
public enum ChannelOpenBindingClamp
{
None = 0,
WumboCeiling = 1,
NodeMax = 2,
WalletBalance = 3,
Budget = 4
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please have enums describe what's each thing?

/// <see cref="ChannelsInvolved"/> channels.
public ulong OutgoingChannelId { get; set; }

public int ChannelsInvolved { get; set; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this needed? there are some pure display-level info-level fields we store, are we sure we need them?

@lunar-patrol lunar-patrol 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.

🔒 Automated security review

This PR turns link-fail (insufficient-balance) forward events into channel-open recommendations and, in Auto mode, promotes them into ChannelOperationRequests that hot wallets dispatch to ChannelOpenJob without a human signature. The core risk is inherent to the design: the demand signal is produced by untrusted routing peers who pay nothing for failed HTLCs, and the missed-fee profitability evidence is computed from the sender-offered fee, which the same peer controls. Per-node budget, cooldown and a cost-to-earn gate based on the node's own policy bound the damage, so the finding is MEDIUM, not higher.

Reviewed Lunar-Rails/NodeGuard #615 at d4a6771 — 1 inline finding(s), 0 not anchorable, 1 below the posting threshold.

1 lower-severity observation(s)
  • LOW · dos — Failure-window query loads unbounded attacker-influenced row set (src/Jobs/AutoChannelOpenJob.cs line 150)
    GetInsufficientBalanceFailures has no LIMIT: every InsufficientBalance link-fail row in the 24h window is materialized, ordered and collapsed in memory on every 30-minute run. A peer generating link-fail HTLCs at high rate inflates job memory/CPU and the ForwardingHtlcEvents table. Each HTLC attempt is cheap for the attacker, but they must sustain volume and the job already touches the same table for ingest, so impact is degraded job runs rather than an outage.

🤖 Automated security review. It never pushes, approves or blocks; a suggestion applies only when you click Commit suggestion.

return false;
}

var (promoted, promotionError) = await _promotionService.Promote(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

MEDIUM · input_validation — Untrusted peers can trigger automatic channel opens at zero cost

A peer holding a channel to a managed node (Auto mode, hot funding wallet) repeatedly routes HTLCs exceeding the channel's outbound balance. Each failure is recorded as an InsufficientBalance LinkFail event, which is the job's entire demand signal (AutoChannelOpenJob.cs:150). The attacker offers a high fee on each failing HTLC, and CollapseBursts prefers that sender-offered FeeMsat, so the MinMissedFeeMsat gate is passed with attacker-chosen numbers (ChannelOpenInitiatorService.cs:251). Burst, size and cost-to-earn gates use only the attacker's failure stream and the node's own policy, all satisfiable. The job promotes via _promotionService.Promote, and DispatchIfNoSignaturesNeeded schedules ChannelOpenJob with no human signature for a hot wallet, so the node pays on-chain fees and locks budgeted capital into a channel to the attacker, who gains inbound liquidity they never paid to open. Bounded by per-node budget and 24h peer cooldown, hence MEDIUM.

Threat: A Lightning Network peer with an existing channel to a managed node, starting from unauthenticated network access as a routing peer; the target node must have Auto mode enabled with a hot funding wallet → Victim-funded channels opened to the attacker: on-chain fees paid by the victim and inbound liquidity obtained without the attacker paying to open it

Checks

Ruled out: Budget cap, 24h peer cooldown, MinBursts, cost-to-earn ratio on the node's own earnPpm, and wallet-balance clamp all exist (AutoChannelOpenJob.ProcessNode, ChannelOpenInitiatorService.Size); none distinguishes fabricated failures from real demand because failed HTLCs are free to generate. UI path is role-gated but the Auto job path is not.

Verified: All links verify. NodeHtlcSubscribeJob.cs:147-180 persists LinkFail events with FailureDetail=InsufficientBalance and FeeMsat=incoming−outgoing (sender-chosen); AutoChannelOpenJob.cs:150 feeds these to BuildPlans; ChannelOpenInitiatorService.cs:250-253 prefers the attacker-offered FeeMsat for the MinMissedFeeMsat gate, and burst/size/cost-to-earn gates use only the failure stream and the node's own policy, all satisfiable by fabricated failures (failed HTLCs pay no fee). RecordAndMaybePromote (AutoChannelOpenJob.cs:393) promotes in Auto mode when not dry-run, and DispatchIfNoSignaturesNeeded (ChannelOpenPromotionService.cs:183-219) schedules ChannelOpenJob with no human signature for hot wallets. Spend is bounded only by operator budget and the 24h peer cooldown, matching the claimed MEDIUM. "Auto removes the human decision" is in-repo comment, which doesn't count as a deliberate-design refutation, and the feature is introduced by this PR.

🤖 automated review — reply not-an-issue to dismiss

@markettes
markettes marked this pull request as draft November 25, 2026 12:10

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.

2 participants