Skip to content
Back to Blog
·9 min read·technology

Business Logic Flaws: The Bugs Automated Scanners Never Find

Business logic flaws like negative quantities, coupon stacking, and wallet race conditions slip past automated scanners. Learn how to test for and fix them.

BR

Bachao.AI Research Team

Cybersecurity Research

Scan Your Attack Surface

Security exposure this creates

Unpatched vulnerabilities in your tech stack are the #1 entry point for breaches targeting Indian businesses. Here's what to watch.

Business logic flaws are defects in an application's workflow rules — not in its code syntax — that let an attacker manipulate legitimate features to produce illegitimate outcomes: negative-quantity refunds, stacked coupons, wallet double-spends, or skipping a payment step entirely. Automated scanners cannot find them because there is no malformed payload to signature-match against; every request is syntactically valid. Finding them requires a tester who understands what the workflow is supposed to enforce, then breaks that assumption on purpose. For Indian SMBs running e-commerce, fintech, and SaaS billing flows, this class of bug is now where real financial loss concentrates.

Why Automated Scanners Are Structurally Blind To This

A scanner is built to recognise patterns: a <script> tag reflected in a response, a SQL error string after an injected quote, a missing security header. It compares your application's responses against a library of known-bad signatures. That works well for OWASP Top 10 categories like injection and misconfiguration, where the flaw is visible in a single request-response pair.

Business logic flaws don't work that way. The request quantity=-3 is not malformed — it's a perfectly valid integer, and the scanner has no idea that your inventory system will interpret a negative quantity as a credit rather than a rejection. The scanner cannot know that your coupon endpoint should reject a second redemption of the same code, because "should" is a business rule that lives in your product specification, not in the HTTP protocol. This is precisely why OWASP separated API Security into its own Top 10 in 2023, with Broken Object Level Authorization (BOLA) ranked as the single most common API weakness — a category that is, by definition, a logic and authorization design failure rather than a payload injection (OWASP API Security Top 10, 2023).

ℹ️
INFO
OWASP's own Top 10:2021 data set found that 94% of the applications it tested had at least one instance of broken access control — the parent category under which most business logic and workflow-abuse flaws sit (OWASP Top 10:2021, A01).

The Flaw Families Scanners Consistently Miss

Negative Quantity and Integer Abuse

Cart and inventory systems built to trust the client for quantity math are a recurring pattern in Indian D2C and marketplace apps. If the backend computes total = price * quantity without a server-side floor check, a request with quantity=-1 can turn a purchase into a credit, or a bulk-order discount tier into a negative-cost line item that inflates a wallet balance. The same bug class shows up in loyalty-points redemption, where a negative "points to redeem" value increases the balance instead of decreasing it.

Coupon and Discount Stacking

A single-use coupon is only single-use if the redemption is checked and marked atomically. Common failure patterns include: applying the same code across multiple concurrent tabs or API calls before the "already used" flag commits; chaining a percentage coupon with a flat-value coupon the UI never intended to combine; or replaying a cached checkout request after a coupon has technically expired server-side but the session token was issued before expiry. None of these produce an error a scanner would recognise — the checkout completes successfully every time.

TOCTOU Double-Spend in Wallets and Refunds

This is the highest-value flaw family for fintech and wallet-enabled apps. Time-of-check to time-of-use (TOCTOU) race conditions occur when a system reads a balance, evaluates whether a debit or refund is permitted, and only later writes the updated balance — leaving a window where a second concurrent request can pass the same check before the first write commits. Fire two refund or withdrawal requests at the same endpoint within milliseconds of each other, and many naive implementations will approve both, because both read the "before" balance.

graph TD A[Two Refund Requests Arrive] --> B{Balance Check Locked} B -->|No Lock| C[Request 1 Reads Balance] B -->|No Lock| D[Request 2 Reads Balance] C --> E[Request 1 Passes Check] D --> F[Request 2 Passes Check] E --> G[Request 1 Writes Refund] F --> H[Request 2 Writes Refund] G --> I[Double Refund Committed] H --> I B -->|Row Lock Plus Idempotency Key| J[Single Transaction Holds Lock] J --> K[Second Request Blocked Until Commit] K --> L[Balance Re-checked After Wait] L --> M[Single Refund Committed Safely] style A fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style B fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style C fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style D fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style E fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style F fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style G fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 style H fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 style I fill:#5f1e1e,stroke:#EF4444,color:#e2e8f0 style J fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style K fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style L fill:#1e3a5f,stroke:#3B82F6,color:#e2e8f0 style M fill:#1e3d2f,stroke:#10B981,color:#e2e8f0

The unguarded path on the left is what most wallet and refund incidents look like in post-mortem: two valid, individually-authorised requests that should never have been allowed to both succeed. The fix is not a WAF rule — it's a database-level row lock or serializable transaction, combined with an idempotency key that rejects the second write outright, shown on the right.

🚨
DANGER
If your refund, wallet-topup, or withdrawal endpoint does not use row-level locking, a SELECT ... FOR UPDATE equivalent, or an idempotency key on the write, assume it is exploitable by concurrent requests today — this requires no special tooling, just two browser tabs or a simple script firing requests in parallel.

IDOR-Adjacent Workflow Abuse

Classic IDOR is "change the ID in the URL and see someone else's record." The workflow-abuse variant is subtler: it's calling a legitimate endpoint out of its intended sequence. Examples seen repeatedly in Indian SaaS and e-commerce audits: hitting an order-confirmation endpoint directly, skipping the payment-capture step because the backend trusts the client to have called it first; re-opening a "submitted" KYC form by replaying an earlier draft-save request; or calling an admin-approval webhook with a valid but stale token because the state machine never re-validates the object's current status before acting. The object ID is correct and belongs to the right user — the flaw is that the backend never checks what stage the workflow should be in before executing the action.

Why These Survive Code Review Too

Business logic flaws aren't just invisible to scanners — they're frequently invisible to code review as well, because the code executes exactly as written. The bug is in the design, not the implementation. This is why OWASP added Insecure Design as its own Top 10 category in 2021: "a missing or ineffective control design" is a distinct root cause from a broken control that was implemented incorrectly (OWASP Top 10:2021, A04). A developer reviewing the coupon-redemption function will see that it checks if coupon.used == false — that line is correct. What's missing is the transaction boundary that makes the check-then-set atomic against a concurrent request. No linter flags that. No unit test written against a single-threaded test harness catches it either, because the bug only exists when two requests interleave.

Know your vulnerabilities before attackers do

Run a free VAPT scan — takes 5 minutes, no signup required.

Book Your Free Scan

How to Actually Test for These Bugs

Finding business logic flaws requires abuse-case testing against your own workflow specification, not a generic payload library. The table below contrasts what a scanner covers against what needs a human tester or a purpose-built concurrency test.

Test typeDetects negative quantityDetects coupon stackingDetects TOCTOU double-spendDetects workflow-order abuse
Automated DAST/scannerNoNoNoRarely
Static code analysis (SAST)PartialNoNoNo
Manual functional QAPartialPartialNoPartial
Concurrency/race-condition testing (parallel request tooling)NoYesYesNo
Manual abuse-case penetration testYesYesYesYes
pie title Illustrative Risk Surface On A Typical App "Scanner Detectable Issues" : 35 "Business Logic And Workflow Abuse" : 40 "Needs Manual Code Review" : 25

The chart above is illustrative, not a measured statistic — but it captures a pattern seen consistently across audits: the largest slice of exploitable risk in a mature application is often the part no scanner touches at all.

💡
TIP
Race-condition testing does not require exotic tooling. Firing the same authenticated request 10–20 times in a tight parallel batch against a refund, redemption, or withdrawal endpoint — using something as simple as a scripted loop with concurrent HTTP calls — will expose most unguarded TOCTOU windows within minutes.
⚠️
WARNING
Negative-quantity and integer-abuse bugs are frequently reintroduced after a "fix," because the fix is applied at the UI layer (disabling the minus button) instead of the API layer. Always re-test the raw API endpoint directly, not just the rendered form.

Building a Business-Logic-Aware Testing Program

A scanner-only security program will pass compliance checklists while leaving this entire flaw class open. A workable program adds three things on top of automated scanning: first, a per-workflow threat model that lists every state transition (cart to order to payment to confirmation to refund) and asks "what happens if this step is called out of order, twice, or with an inverted value"; second, scripted concurrency tests against every endpoint that reads-then-writes a balance, quota, or single-use token; third, a recurring manual penetration test — not a one-time exercise — because new features reopen new logic gaps every release cycle. This is also the layer where DPDP Act 2023 accountability bites hardest: financial and workflow-abuse incidents typically involve exactly the kind of unauthorised data and monetary exposure the Act's "reasonable security safeguards" obligation was written to prevent (Digital Personal Data Protection Act 2023, MeitY).

250 croreMaximum penalty in rupees under DPDP Act 2023 for failure to take reasonable security safeguards (MeitY, Digital Personal Data Protection Act 2023)
94%Applications with at least one broken access control instance in OWASP's own testing data (OWASP Top 10:2021)
1Rank of Broken Object Level Authorization among API-specific weaknesses (OWASP API Security Top 10, 2023)
🎯Key Takeaway
Business logic flaws — negative quantities, coupon stacking, TOCTOU wallet double-spends, and out-of-sequence workflow calls — produce zero malformed payloads for a scanner to flag, because every individual request is valid. They are only found by testing the workflow's rules directly: threat-model each state transition, run concurrent-request tests against every balance or single-use check, and pair automated scanning with a recurring manual penetration test.

Bachao.AI runs automated VAPT scanning alongside structured manual abuse-case testing so that negative-quantity, coupon-stacking, and TOCTOU-class findings surface before an attacker finds them — delivered with a CERT-In empanelled partner for engagements that require empanelled sign-off. Dhisattva AI Pvt Ltd built the platform specifically because scanner-only coverage was leaving this exact flaw class unaddressed across Indian SMB stacks. You can review sample findings from a free VAPT scan, read more testing methodology on the blog, or check how these findings map to Indian data-protection obligations at DPDP compliance.

🛡️
SECURITY
If your application has never had a manual, abuse-case-driven penetration test — only automated scans — treat every refund, coupon, and quantity field as unverified until tested. Compliance scans and security posture are not the same thing.

Frequently Asked Questions

What is a business logic flaw in web application security?
A business logic flaw is a defect in an application's workflow rules that lets a user manipulate a legitimate feature to produce an outcome the business never intended, such as a negative-quantity refund or a reused single-use coupon. Every individual request involved is syntactically valid, which is what makes it invisible to signature-based scanners.
Why can't automated vulnerability scanners find business logic flaws?
Scanners detect known-bad patterns like injected script tags or SQL error strings in a single request-response pair. Business logic flaws involve valid requests that violate a workflow rule the scanner has no knowledge of, so there is no signature to match against.
What is a TOCTOU race condition in a wallet or refund system?
TOCTOU stands for time-of-check to time-of-use. It occurs when a system checks a balance or condition and only writes the updated value afterward, leaving a window where a second concurrent request can pass the same check before the first request's write commits — enabling a double-spend or double-refund.
How do you test for coupon stacking or double-redemption bugs?
Fire the same coupon redemption request multiple times in quick, concurrent succession against the live API endpoint, and check whether the backend enforces atomicity on the check-then-set redemption flag. UI-level restrictions like a disabled button do not prevent this at the API layer.
Are business logic flaws covered under DPDP Act 2023 obligations?
Indirectly. The DPDP Act requires reasonable security safeguards to prevent unauthorised access to personal data, and financial or workflow-abuse incidents involving wallets, refunds, or account records commonly expose exactly that kind of data, making these flaws relevant to an organisation's compliance posture.
Does fixing the frontend UI fix a negative-quantity or workflow-abuse bug?
No. If the validation is only applied in the browser or app UI, the underlying API endpoint remains callable directly with the same manipulated values. The fix must be enforced server-side on every request, independent of what the client sends.
BR

Bachao.AI Research Team

Cybersecurity Research

AI-powered security research and threat intelligence from the Bachao.AI team. Covering the latest vulnerabilities, CVEs, and cybersecurity developments affecting Indian businesses.

Get cybersecurity insights for Indian SMBs

Weekly vulnerability alerts, DPDP compliance tips, and security guides. No spam — unsubscribe anytime.

We respect your privacy. Your email is never shared.

Find out if you're exposed to this class of threat

Free automated scan — risk score in under 2 hours. No credit card required.

Scan Your Attack Surface
Find your vulnerabilitiesStart free scan →