Merged
Conversation
|
x402-stellar PR Preview deployed: |
Contributor
There was a problem hiding this comment.
Pull request overview
Addresses multiple security-audit findings across the paywall client, paywall builder, and example server startup validation to reduce double-submissions, stale retries, fall-through execution, startup hangs, and NaN propagation.
Changes:
- Add synchronous in-flight guard to prevent concurrent Stellar payment submissions and refresh requirements on retry from the 402 response.
- Fix insufficient-balance flow to stop before attempting payment submission.
- Add fetch timeout for facilitator validation and harden builder/amount handling (snapshot handlers; guard NaN).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/paywall/src/stellar-handler.ts | Prevent NaN paywall amounts by guarding parsed amounts with Number.isFinite. |
| packages/paywall/src/builder.ts | Snapshot handlers at build-time to prevent later mutations from affecting built providers. |
| packages/paywall/src/browser/useStellarPayment.ts | Add in-flight ref guard and use fresh payment requirements for retry. |
| packages/paywall/src/browser/StellarPaywall.tsx | Add missing return after insufficient-balance error to prevent fall-through. |
| examples/simple-paywall/server/src/config/env.ts | Add AbortController timeout to facilitator validation fetches. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
What
Addresses 6 findings from the Bug Finder Report that apply to our codebase. Each fix is a separate commit:
guard against concurrent payment submissionsuseStellarPayment.tsuseRef(false)synchronous guard to prevent double-click / rapid resubmission of the same paymentadd missing return after insufficient balance errorStellarPaywall.tsxreturnafter setting insufficient-balance error to prevent fall-through into payment submissionuse fresh 402 requirements on payment retryuseStellarPayment.tsPAYMENT-REQUIREDheader from the 402 response instead of reusing the potentially stale original propadd fetch timeout to facilitator validationenv.tsAbortControllerwith 10 s timeout tovalidateFacilitators()fetch so startup doesn't hang if a facilitator is unresponsivecopy handler array at build timebuilder.tsthis.handlerswith spread atbuild()time so later mutations to the builder don't affect already-built providersguard parseFloat NaN in paywall amountstellar-handler.tsparseFloatresult withNumber.isFinite()and fall back to0to preventNaNfrom propagating into the paywall HTMLWhy
An automated security audit (stellar/internal-agents#136) reported 15 findings (7 high, 8 medium). After triaging all 15, 6 are actionable in our code — the rest are either already fixed or require upstream changes to
coinbase/x402.Closes https://github.com/stellar/internal-agents/issues/136