Repository navigation
Conversation
…once+chain POST /settle checks findExistingSettlement before doing any real verification. That lookup matches on nonce and chainId only, and when it finds a confirmed record it returns success: true straight away with the stored txHash and payer, using whatever network the current request sent. A confirmed settlement's nonce can be reused in a new /settle request with completely different paymentRequirements (different payTo, asset, or amount), and the cache hit still returned success without checking any of that. GET /settlements?payer= is also unauthenticated, so a nonce from any payer's past confirmed settlement is easy to look up. This adds the missing check: a cached settlement is only reused when its stored payee, token, and amount match the current request's paymentRequirements. Anything else falls through to the normal facilitator.settle() path, which does full verification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: fix: settlement cache reuse must match payee/token/amount, not just nonce+chain
Body:
POST /settlechecksfindExistingSettlementbefore doing any real verification. That lookup matches onnonceandchainIdonly (findByNonceAndChain), and when it finds aconfirmedrecord it returnssuccess: truestraight away with the storedtxHashandpayer, using whatevernetworkthe current request sent.The problem: a confirmed settlement's nonce can be reused in a new
/settlerequest with completely differentpaymentRequirements(differentpayTo,asset, oramount), and the cache hit still returns success without checking any of that. The response looks like a real settlement for the new requirements even though the on-chain transaction never paid that payee or amount.GET /settlements?payer=is also unauthenticated, so a nonce from any payer's past confirmed settlement is easy to look up.This PR adds the missing check: a cached settlement is only reused when its stored
payee,token, andamountmatch the current request'spaymentRequirements. Anything else falls through to the normalfacilitator.settle()path, which does full verification.No other behavior changes. Happy to add a test for this if useful, let me know what fixture setup you'd prefer for the DB layer.