Repository navigation
feat(upi): M4.3 critical UPI security and financial integrity remediation - #30
Open
Satelink-Protocol wants to merge 1 commit into
Open
Satelink-Protocol wants to merge 1 commit into
Satelink-Protocol wants to merge 1 commit into
Conversation
…ings (SEC-01 - DB-01) - SEC-01: Extract Base64 response for PhonePe S2S webhook signature calculation - FIN-01: Enforce strict webhook amount verification and dispute ledger transition - DATA-01: Gate checkout with sign-in redirect, store guestToken, and add claim API - CONCUR-01: Hold unexpired intent capacity and re-verify inventory at confirmation - AUTH-01: Enforce session and guestToken authorization on payment status API - QR-01: Preserve ISO 18004 Dark Module at (size - 8, 8) and fix V8 block interleaving - UI-01: Add responsive media queries to isolate mobile intent and desktop QR - LOG-01: Namespace PhonePe rate limits to phonepe_hook: and phonepe_bad_sig: - DB-01: Add migration 016 with append-only database trigger on payment_audits - Update test suite with 8 dedicated M4.3 audit tests (453/453 tests passing) - Update audit reports and project state docs
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Nov 3, 2026
Open
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.
Summary
This PR completes Milestone M4.3 — Critical UPI Security & Financial Integrity Remediation, resolving all 9 vulnerabilities and architectural defects identified during the independent M4.2 audit (docs/UPI_SECURITY_AUDIT.md).
Remediated Findings (All 9 Resolved):
SEC-01 (Critical) — PhonePe Webhook Signature Verification:
lib/upi/adapter.js: Correctly extracts the Base64responseproperty from the incoming JSON payload and computesSHA256(base64Response + saltKey) + '###' + saltIndexper the official PhonePe S2S specification.FIN-01 (Critical) — Webhook Amount Verification:
lib/services/upi-payments.js: Ingests and validatesverifiedAmountPaiseinapplySuccessfulUpiPayment.disputed, an immutable dispute audit entry is logged, and 0 bookings are confirmed.DATA-01 (High) — Guest Checkout Schema Safety & Claim API:
lib/handlers/upi-checkout.js: Gated/checkout/:slug/upito require sign-in (redirecting to/signinunless explicit?guest=1).lib/services/upi-payments.js: Unauthenticated guest intents generate an unguessableguestToken. Webhooks mark guest paymentssucceededwithout crashing onNOT NULL bookings.user_id.lib/router.js: MountedPOST /api/checkout/upi/claimallowing authenticated attendees to claim guest orders.CONCUR-01 (High) — Concurrency Capacity Holds & Confirmation Check:
activePaymentHoldsandactiveTierPaymentHoldsinlib/services/upi-payments.jsto hold seats during active unexpired intents (expires_at > now()).refund_pendingwith dispute reasoncapacity_exceeded.AUTH-01 (High) — Status Endpoint Authorization:
getUpiPaymentStatus: registered orders require caller to matchpayment.user_idor hold an admin/staff role (super_admin,finance,event_manager,support).guestTokenvia constant-time comparison or staff role.QR-01 (Medium) — QR Generator ISO 18004 Compliance:
lib/upi/qr.js: Corrected format information bit loop (i < 7) to preserve the mandatory Dark Module at coordinate(size - 8, 8).UI-01 (Medium) — Responsive Viewport CSS Isolation:
lib/views/checkout-upi.js: Added CSS media queries hiding.checkout-desktopon mobile (<=768px) and hiding.checkout-mobileon desktop (>=769px).LOG-01 (Low) — Dedicated Rate Limiting Keys:
lib/handlers/upi-checkout.js: Separated PhonePe webhook rate limit namespaces tophonepe_hook:andphonepe_bad_sig:.DB-01 (Low) — Append-Only Immutable Audit Ledger:
migrations/016_payment_audits_immutable.sql: Added PostgreSQL triggerprevent_payment_audit_mutationpreventingUPDATEandDELETEonpayment_audits. Added partial indexidx_payments_active_holds.Verification & Testing:
test/upi-checkout.test.js(including 8 dedicated M4.3 audit tests).test/migrations.test.js(verifying all 14 migrations and trigger immutability).140/140 files OK.ENABLE_LIVE_PAYMENTS=falsestrictly preserved across all environments.