Skip to content

Commit

Permalink
tapchannel: compare asset id of htlc records with quote
Browse files Browse the repository at this point in the history
In this commit we use the previously defined helper to fetch the asset
ID of the accepted quote, then we compare it with the asset ID of each
HTLC. This is done as an extra strict check to guard against HTLC and
RFQ asset ID mismatch, which can lead to malicious behavior where a
quote for a different asset is being accounted for when accepting an
asset HTLC.
  • Loading branch information
GeorgeTsagk committed Jan 16, 2025
1 parent e177bd2 commit ef54607
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tapchannel/aux_invoice_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,19 @@ func (s *AuxInvoiceManager) handleInvoiceAccept(_ context.Context,
// Convert the total asset amount to milli-satoshis using the price from
// the accepted quote.
rfqID := htlc.RfqID.ValOpt().UnsafeFromSome()

assetID, err := s.assetIDFromQuote(rfqID)
if err != nil {
return nil, fmt.Errorf("could not extract assetID from "+
"quote: %v", err)
}
for _, v := range htlc.Balances() {
if v.AssetID.Val != *assetID {
return nil, fmt.Errorf("mismatch between htlc asset " +
"ID and rfq quote asset ID")
}
}

assetRate, err := s.priceFromQuote(rfqID)
if err != nil {
return nil, fmt.Errorf("unable to get price from quote with "+
Expand Down

0 comments on commit ef54607

Please sign in to comment.