htlcswitch: add CheckCircularForward to handlePacketForward

Add a CheckCircularForward function which detects packets which are
forwards over the same incoming and outgoing link, and errors if the
node is configured to disallow forwards of this nature. This check is
added to increase the cost of a liquidity lockup attack, because it
increases the length of the route required to lock up an individual
node's bandwidth. Since nodes are currently limited to 20 hops,
increasing the length of the route needed to lock up capital increases
the number of malicious payments an attacker will have to route, which
increases the capital requirement of the attack overall.
This commit is contained in:
carla committed 2020-01-30 10:13:40 +02:00
1 parent c08377d303
commit a3478f1d99
3 files changed
+225

No files matched your search

+8
View File
@@ -29,6 +29,11 @@ const (
// FailureDetailInsufficientBalance is returned when we cannot route a
// htlc due to insufficient outgoing capacity.
FailureDetailInsufficientBalance
// FailureDetailCircularRoute is returned when an attempt is made
// to forward a htlc through our node which arrives and leaves on the
// same channel.
FailureDetailCircularRoute
)
// String returns the string representation of a failure detail.
@@ -52,6 +57,9 @@ func (fd FailureDetail) String() string {
case FailureDetailInsufficientBalance:
return "insufficient bandwidth to route htlc"
case FailureDetailCircularRoute:
return "same incoming and outgoing channel"
default:
return "unknown failure detail"
}