Initial booking state is explicit
Why it matters
Skipping an explicit initial booking status causes payment-confirmation race conditions: if a booking defaults to 'confirmed' at insert time, a failed or pending payment leaves a confirmed reservation with no corresponding charge. Under CWE-841 (improper enforcement of behavioral workflow), the system's state machine collapses at the first edge case. Any downstream job that queries status = 'CONFIRMED' to send reminder emails or mark slots occupied will fire on unconfirmed bookings, producing phantom reservations, double-charges, or capacity miscounts that are extremely difficult to detect after the fact.
Severity rationale
Medium because the defect corrupts booking state and triggers downstream side-effects, but does not directly expose customer data or enable unauthorized access.
Remediation
Set status explicitly in the create call inside your booking service (e.g., src/lib/bookings.ts). Never rely on a database column default for a field whose initial value determines the entire lifecycle state machine.
const booking = await prisma.booking.create({
data: {
customerId,
slotId,
providerId,
status: 'PENDING', // explicit — never trust a DB default here
startTime,
endTime,
}
});
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 Booking Flow & Lifecycle Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-841 — Improper Enforcement of Behavioral Workflow
- cwe · CWE-20 — Improper Input Validation
- iso-25010:2011 · functional-suitability.functional-correctness
Taxons
History
- 2026-04-18·v1.0.0·Initial import from booking-flow-lifecycle·automated