Calculated totals recalculated server-side
Why it matters
A client-submitted grandTotal that the server uses directly is tamper-able: subtract $5 from the total before submitting and pay less. CWE-602 and OWASP A03 both flag trusting client-calculated aggregates. PCI DSS Req-6.2.4 requires independent server-side validation of all payment amounts. This pattern is particularly risky because the individual components (subtotal, tax, fee) may each be validated correctly while the tampered total bypasses all of them.
Severity rationale
Info because exploiting this requires deliberate request manipulation, and the mismatch is often caught by downstream payment processors — but it remains a meaningful integrity gap.
Remediation
Ignore any total field from the client and reconstruct it server-side from validated components before committing.
// src/app/api/checkout/route.ts
export async function POST(req: Request) {
const { subtotalCents, taxRateBps, feesCents } = schema.parse(await req.json());
// taxRateBps: basis points (e.g., 800 = 8%)
const taxCents = Math.round(subtotalCents * taxRateBps / 10000);
const totalCents = subtotalCents + taxCents + feesCents;
await processPayment(totalCents); // use server-calculated total only
}
Never read totalCents, grandTotal, or equivalent fields from the request body when accepting payment.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Financial Form Validation Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-602 — Client-Side Enforcement of Server-Side Security
- owasp:2021 · A03
- pci-dss:4.0 · Req 6.2.4 — Prevent common software attacks including injection and improper input validation
Taxons
History
- 2026-04-18·v1.0.0·Initial import from finserv-form-validation·automated