API & Integration Reliability Audit · Security basics · SQL checks
Online shop API: a customer-data leak and pricing bugs caught before launch
API and database tests on a demo shop found 10 defects, including any customer being able to read another customer's orders. All 10 fixes verified, and the checks run on every change.
Demonstration on synthetic data in my own demo project, not client work.
Scenario
A small online shop (ShopLab, built for this demonstration) is about to launch: sign-up, login, cart, discount codes and checkout, served by a REST API with a SQLite database. Before customers arrive, the team wants to know whether the API is safe to put in front of them.
Risks
- Customers seeing each other's orders, names and postal codes (a privacy breach)
- Margin lost through stacked discount codes or negative quantities
- Selling stock the shop does not have during busy periods
- Shoppers charged a different price from the one listed
- Accounts taken over by unlimited password guessing
Tests
- 58 pytest tests: positive, negative and boundary cases for every endpoint
- JSON-schema validation of every response
- Authorization tests with two real customer accounts (OWASP A01: broken access control)
- A concurrency test: simultaneous orders for the last items in stock, followed by an SQL stock check
- SQL comparison of listed prices with the database
Defects found
| ID | Defect | Type |
|---|---|---|
| D06 | Any customer can read another customer's order | Critical |
| D01 | Account never locks after repeated wrong passwords | High |
| D03 | One discount code can be applied twice | High |
| D05 | Quantity accepts 0 and negative numbers | High |
| D08 | Stock goes negative under simultaneous orders | High |
| D02 | Sign-up accepts "a@b" and 1-character passwords | Medium |
| D04 | Tax truncated instead of rounded | Medium |
| D07 | Malformed input returns a 500 with a stack trace | Medium |
| D09 | Listed price differs from the database | Medium |
| D13 | Security headers missing | Low |
Evidence
- Defect table in the Proof Lab — Every seeded defect and the test that catches it
- Release report for v1.0 (PDF) — Open defects with evidence, generated from the test run
- Release report for v1.1 (PDF) — The same report after the fixes
Fix
Each defect fixed in v1.1 of the shop: the same code base, switched by one setting, so the fix and the defect can be compared side by side.
The whole suite rerun against v1.1, and a CI gate that fails if any defect stops being detected on v1.0 or anything fails on v1.1.
Result
- v1.0 (seeded defects)
- 10 of 10 API defects detected
- v1.1 (fixed)
- 58 of 58 tests pass
- Regression safety
- Both builds tested on every change
Lessons
- Authorization bugs need two real accounts: a suite that signs in as one user passes while any customer can read any order.
- Some defects only exist under concurrency. Overselling never shows up when orders are placed one at a time.
- Check the database, not only the API response: the price and stock mismatches were confirmed in SQL.
Need this for your product?
Get a suggested scope and starting price in four questions, or tell me about your project.
Next case study: Release decision: from 14 defects to a clear Go/No-Go →