Insecure Design (OWASP A06:2025)
On this page
Insecure design: bug-free code that's still broken
Here's a checkout endpoint. It has no injection, no missing auth check, nothing a scanner would flag:
app.post('/v1/checkout', (req, res) => {
const { itemId, qty, price } = req.body;
res.json({ charged: qty * price });
});It does exactly what it was designed to do. The design is the problem: it trusts the browser to say what things cost.
{"itemId":"kb-01","qty":1,"price":1} -> {"charged":1}
{"itemId":"kb-01","qty":-3,"price":8900} -> {"charged":-26700}A keyboard for one cent, then a negative charge, which a payment system could treat as a refund.
Implementation bug or design flaw?
An implementation bug is a mistake inside a sound plan: a forgotten escape, a missing check. You fix it by changing a few lines.
An insecure design is a plan that never considered how a feature could be abused. Perfect code written to that plan is still insecure. Automated tools (static analysis, dynamic scanners) are good at the first kind. They can't flag the second, because no line of code is wrong.
The fixed checkout changes what the server accepts, not just how it's coded:
app.post('/v2/checkout', (req, res) => {
const { itemId, qty } = req.body; // price is no longer an input
const item = items[itemId];
if (!item || !Number.isInteger(qty) || qty < 1 || qty > 10)
return res.status(400).json({ error: 'invalid order' });
res.json({ charged: qty * item.price }); // the server owns the price
});{"itemId":"kb-01","qty":1,"price":1} -> {"charged":8900}
{"itemId":"kb-01","qty":-3,"price":8900} -> {"error":"invalid order"}The client still sends price, and it's ignored.
More insecure design examples
- Password reset that reveals accounts. "We've sent you a link" for real users, "No such account" for others. An attacker can test which emails are registered. The design should give one answer for both.
- A "remember me" token that can't be revoked. If it leaks, nobody can kill it. Revocation and expiry have to be in the design.
- Unlimited attempts on anything valuable: gift card codes, coupons, SMS codes. Without limits in the design, guessing is just a loop.
- Harmless pieces that add up. In 2018 Strava published a global heatmap of its users' anonymized activity. Each run was harmless, but together they outlined military bases where soldiers exercised with fitness trackers. No code was wrong; nobody had asked what the aggregate revealed.
Threat modeling: catching design flaws before code exists
Insecure design is fixed in process, not in a patch:
- Threat model the risky features. Spend 30 minutes on four questions: What are we building? What can go wrong? What will we do about it? Did we do a good job? Focus on login, payments, permissions, anything multi-tenant and anything that aggregates data.
- Write misuse cases next to user stories. "As a buyer I can check out" gets a partner: "A buyer can't change the price, the quantity sign, or someone else's cart."
- Make limits part of the spec: rate limits, maximum amounts, expiry times.
- Build paved roads. Shared, reviewed components for auth, payments and file upload mean each team doesn't redesign them. Secure becomes the easy path.
Check yourself
Nothing in the code is wrong by pattern. The flaw is that the design trusts a client-supplied price, which only a human asking "how could this be abused?" will notice.
It's a design issue: the page lets anyone test which email addresses have accounts, which helps attackers target phishing and credential stuffing. Return the same message, such as "If an account exists, we've sent a reset link", whether or not the address is registered, and rate-limit the endpoint.
Features where a design flaw would hurt most: authentication and account recovery, payments and anything involving money or credits, permissions and tenant boundaries, and features that combine many pieces of personal data. A short session before coding is far cheaper than redesigning after release.
An implementation bug is code that doesn't do what the design intended, such as a missing parameterization, and can be fixed in place. A design flaw is when the intended behavior itself is unsafe, such as unlimited coupon reuse, so even perfect code is vulnerable and the design must change.
For each new feature, draw how data flows between users, services and stores, then ask four questions: what are we building, what can go wrong (STRIDE helps), what are we doing about it, and did we do a good job? Record the risks and mitigations.