Skip to content

Commit f2de2f3

Browse files
committed
Reject outbound channels if the total reserve is larger than funding
In 2826af7 we fixed a fuzz crash in which the total reserve values in a channel were greater than the funding amount, checked when an incoming channel is accepted. This, however, did not fix the same issue for outbound channels, where a peer can accept a channel with a nonsense reserve value in the `accept_channel` message. The `full_stack_target` fuzzer eventually found its way into the same issue, which this resolves. Thanks (again) to Chaincode Labs for providing the fuzzing resources which found this bug!
1 parent 9bdce47 commit f2de2f3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1927,6 +1927,10 @@ impl<Signer: Sign> Channel<Signer> {
19271927
if msg.dust_limit_satoshis > self.holder_selected_channel_reserve_satoshis {
19281928
return Err(ChannelError::Close(format!("Dust limit ({}) is bigger than our channel reserve ({})", msg.dust_limit_satoshis, self.holder_selected_channel_reserve_satoshis)));
19291929
}
1930+
if msg.channel_reserve_satoshis > self.channel_value_satoshis - self.holder_selected_channel_reserve_satoshis {
1931+
return Err(ChannelError::Close(format!("Bogus channel_reserve_satoshis ({}). Must not be greater than channel value minus our reserve ({})",
1932+
msg.channel_reserve_satoshis, self.channel_value_satoshis - self.holder_selected_channel_reserve_satoshis)));
1933+
}
19301934
let full_channel_value_msat = (self.channel_value_satoshis - msg.channel_reserve_satoshis) * 1000;
19311935
if msg.htlc_minimum_msat >= full_channel_value_msat {
19321936
return Err(ChannelError::Close(format!("Minimum htlc value ({}) is full channel value ({})", msg.htlc_minimum_msat, full_channel_value_msat)));

0 commit comments

Comments
 (0)