routerrpc: Check for nil IncomingCircuitKey

The grpc stream.Recv() will decode an ForwardHtlcInterceptResponse
without an IncomingCircuit, which will leave that pointer nil,
causing a nil pointer dereferece when components of in.IncomingCircuitKey
are used in the resolveFromClient() function.

This commit checks for the nil pointer and returns an error before
the rest of the parsing.
This commit is contained in:
adiabat 2023-02-09 19:28:47 -05:00
parent f94500281f
commit 17f7b9f322
2 changed files with 8 additions and 0 deletions

View File

@ -125,6 +125,9 @@ current gossip sync query status.
update in order to use the new versioned RPC and upgrade any on-chain outputs
to the new version.
* [A bug has been fixed which could cause `lnd` to crash when parsing a
malformed HTLC intercept message](https://github.com/lightningnetwork/lnd/pull/7392).
## Wallet
* [Allows Taproot public keys and tap scripts to be imported as watch-only

View File

@ -100,6 +100,11 @@ func (r *forwardInterceptor) onIntercept(
func (r *forwardInterceptor) resolveFromClient(
in *ForwardHtlcInterceptResponse) error {
if in.IncomingCircuitKey == nil {
return status.Errorf(codes.InvalidArgument,
"CircuitKey missing from ForwardHtlcInterceptResponse")
}
log.Tracef("Resolving intercepted packet %v", in)
circuitKey := models.CircuitKey{