Skip to content

audit(path-payment): security + query audits + metrics fallback fix (#598, #600, #601)#838

Open
davedumto wants to merge 1 commit into
emdevelopa:mainfrom
davedumto:audit/path-payment-service-598-600-601
Open

audit(path-payment): security + query audits + metrics fallback fix (#598, #600, #601)#838
davedumto wants to merge 1 commit into
emdevelopa:mainfrom
davedumto:audit/path-payment-service-598-600-601

Conversation

@davedumto
Copy link
Copy Markdown

Summary

A thorough audit of the Path Payment Service and the referenced Trustline Manager, with findings documented under backend/docs/audits/ (following the repo's existing *_SECURITY_AUDIT.md convention), plus the one genuine, safe code optimization the review surfaced.

Disclosure: prepared with AI assistance (Claude) and reviewed before submission.

closes #598
closes #600
closes #601

#598 — Trustline Manager security audit → TRUSTLINE_MANAGER_SECURITY_AUDIT.md

There is no trustline-management code in the repo — zero changeTrust/allowTrust/trustline matches across backend/src. The Stellar surface is native asset + Operation.payment + read-only path quoting only. The audit documents the absence, explains why it's the safer default (trust decisions remain in the user's wallet, so the server-side trustline attack surface doesn't exist), and provides an audit checklist for any future implementation. This issue should be re-scoped to "build a Trustline Manager" before code work is meaningful — there is nothing to audit today.

#600 — Cryptographic signature verification → PATH_PAYMENT_SIGNATURE_VERIFICATION_AUDIT.md

Already implemented and enforced: verifyTransactionSignature (src/lib/stellar.js:731) performs full Ed25519 verification — rejects unsigned envelopes, accumulates signer weight against the account's medium threshold, and prevents signer replay — and is wired into the verify flow (payments.js:601, paymentService.verifyPayment) with existing test coverage. The public read-only quote endpoint is intentionally unauthenticated (customer checkout calls it with no API key — frontend/.../pay/[id]/page.tsx:304). Audit confirms coverage; no code change warranted.

#601 — Optimize SQL queries → PATH_PAYMENT_QUERY_PERFORMANCE_AUDIT.md

The quote lookup is a single primary-key maybeSingle(), and the 7-day metrics are aggregated in-database (date_trunc('day') + GROUP BY + totals CTE). No N+1 or unbounded scans. The one genuine, safe optimization — removing a redundant ORDER BY created_at from the Supabase metrics fallback (results are bucketed by day, so order is irrelevant) — is applied in src/services/paymentService.js.

Test plan

  • vitest run src/services/paymentService.test.js5/5 passing after the change.

Honest caveats

  • These were vague auto-generated "system optimization" issues; the audit's honest conclusion is that the Path Payment Service is already secure (signatures) and already optimized (queries), and the Trustline Manager does not exist. Rather than fabricate speculative changes (or break the intentionally-public checkout endpoint), this PR delivers the evidence-based audits the repo's convention calls for plus the single safe optimization found. Happy to do deeper work on any of these if a maintainer can point to a concrete target.

…emdevelopa#598, emdevelopa#600, emdevelopa#601)

closes emdevelopa#598
closes emdevelopa#600
closes emdevelopa#601

Thorough audit of the Path Payment Service and the (referenced) Trustline
Manager, with findings documented under backend/docs/audits/ following the
repo's existing *_SECURITY_AUDIT.md convention.

emdevelopa#598 (Trustline Manager security audit): there is no trustline-management code
in the repo (zero changeTrust/allowTrust/trustline matches); the platform only
does native asset + Operation.payment + read-only path quoting. Documented the
absence, why it's the safer default (trust decisions stay in the user's wallet),
and an audit checklist for any future Trustline Manager. The issue needs
re-scoping to "build" before code is meaningful — see
TRUSTLINE_MANAGER_SECURITY_AUDIT.md.

emdevelopa#600 (cryptographic signature verification): already implemented and enforced —
verifyTransactionSignature (lib/stellar.js) does full Ed25519 verification with
account medium-threshold weight accumulation and signer-replay prevention, wired
into the verify flow (payments.js:601, paymentService.verifyPayment) and covered
by tests. The public read-only quote endpoint is intentionally unauthenticated
(customer checkout). Documented in PATH_PAYMENT_SIGNATURE_VERIFICATION_AUDIT.md.

emdevelopa#601 (optimize SQL queries): the quote lookup is a single primary-key
maybeSingle(), and the 7-day metrics are aggregated in-DB via date_trunc + GROUP
BY. The one genuine, safe optimization — dropping a redundant ORDER BY in the
Supabase metrics fallback (results are bucketed by day, so order is irrelevant)
— is applied. Details in PATH_PAYMENT_QUERY_PERFORMANCE_AUDIT.md.

Verified: `vitest run src/services/paymentService.test.js` passes (5/5).

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

@davedumto is attempting to deploy a commit to the Emmanuel's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@davedumto Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant