TLDR overview
- Business logic vulnerabilities are flaws where the code is valid but the intent is not, so an application can be used in a way it was never meant to be.
- They span three classes: broken access control including IDOR, business logic flaws, and authentication and session gaps. Pattern-based scanners rarely flag any of them.
- Finding them before release depends on reasoning about what the code should permit, not just matching known-vulnerable patterns, backed by independent verification.
- SonarQube Hunter Agent hunts these intent-based flaws across the codebase and raises confirmed findings as regular SonarQube issues.
A valid line of code can still let any user read another tenant's invoice. It can let a shopper skip a required checkout step, stack the same coupon until the margin disappears, or hold a session open long after logout. Nothing in that code looks broken. A scanner built for known patterns sees no violation, and a periodic test only looks twice a year.
That gap is widening. AI-generated code ships faster than any human review cycle can cover, and attackers do not need to break your code. They just need to use it the way it was never meant to be used.
This page explains what business logic vulnerabilities are, why scanners and reviews miss them, why they surface late, and how to detect them before release. It covers the three classes that matter most: broken access control including insecure direct object reference, business logic flaws, and authentication and session gaps.
What are business logic vulnerabilities?
Business logic vulnerabilities are flaws in which the code executes exactly as written, yet the application can be used in a way it was never intended to be used. The code is valid. The intent is not.
These flaws live in the space between what the code permits and what the business actually allows. They do not show up as malformed input or an unsafe function call. They show up when a legitimate feature, used in a legitimate-looking way, produces a result the organization never wanted. OWASP describes why they are hard to scan for: they typically involve legitimate use of the application's functionality, so automated tools struggle to flag them (OWASP Community, "Business logic vulnerability," citing CWE-840).
Three distinct classes make up most of what teams need to catch before release.
Broken access control. The application fails to enforce what a user is allowed to do. A common form is insecure direct object reference, where a user reads or modifies an object by changing an identifier in a URL or parameter because no object-level authorization check runs. Consider an endpoint that returns an invoice by its ID with no tenant check: any authenticated user can read another tenant's invoice. Related failures include missing or incorrect authorization checks, privilege escalation, sensitive data exposure, and cross-site request forgery. The OWASP Top 10 (2021 edition) describes access control failures as a user acting "outside of their intended permissions," typically leading to unauthorized disclosure, modification, or destruction of data.
Business logic flaws. The application allows a legitimate workflow to be used in an illegitimate way. A user skips a required step, repeats an action that was meant to run once, or stacks discounts that were never meant to combine. Missing rate limits fall here too, letting one actor hammer an endpoint far beyond any reasonable use. These are the flaws OWASP notes are hardest to scan for, because understanding the vulnerability requires understanding the business process behind it.
Authentication and session gaps. The application fails to establish or maintain identity correctly. Sessions that never expire, session fixation, weak password recovery, missing multi-factor authentication, and brute-force gaps all let an attacker become or stay someone they are not.
The three classes are related but distinct. Broken access control is about what an authenticated user is permitted to touch. Business logic flaws are about how a permitted workflow can be abused. Authentication and session gaps are about whether identity itself holds. A single application can carry all three at once.
Why do scanners and reviews miss these flaws?
Pattern-based analysis works by recognizing known-vulnerable shapes in code: an unsanitized input flowing into a query, an unsafe deserialization call, a hardcoded secret. That approach is strong, and it is why a modern approach to SAST catches injection, unsafe data flows, and similar pattern-based vulnerabilities on every commit.
Business logic vulnerabilities carry no such shape. The code that reads another tenant's invoice is a routine database lookup. The code that skips a workflow step is an ordinary branch. Nothing in the syntax matches a known-bad pattern, because nothing in the syntax is wrong.
Detecting these flaws requires reasoning about intent: what the application should permit versus what the code actually permits. That is a different problem from pattern matching. It means tracing how data and identity move across files and services, then asking whether a given actor should be able to reach a given result. A rule engine built to flag known patterns was never designed for that question, and a human reviewer scanning a diff rarely has the whole-codebase context to answer it either.
Why are business logic vulnerabilities found so late?
Because the usual safety nets are episodic, scope-limited, or too slow for the pace of change.
Periodic penetration tests are snapshots. Sonar's own framing notes a typical cadence of twice a year, which means everything shipped between engagements goes live unchecked until the next one. Bug bounties help, but they are scope-limited and hit-or-miss by nature: you find what a researcher happens to look for, when they happen to look. Neither is continuous.
Manual review cannot close the gap on its own. AI-generated code ships faster than any human review cycle can cover. The result is predictable: logic flaws surface in production, where they are most expensive to fix and most exposed to attackers who are already using AI to find and exploit them faster than defenders patch. How to detect business logic vulnerabilities before release
Detecting intent-based flaws before release is a practice, not a single scan. It combines explicit definitions of intended behavior, flow analysis, abuse-case testing, pattern-based and intent-based analysis, validation, and continuous re-checking.
How detection works in practice
- Define intended behavior and the authorization model. Write down who is allowed to do what, and the business rules a workflow must enforce. You cannot detect a deviation from intent without first stating the intent. This step does not find flaws on its own; it gives every later step a standard to test against.
- Map data and identity flows across files and services. Trace how a request carries identity and data from entry point to data store. Access control and IDOR failures hide in the handoffs between components. Flow mapping surfaces where a check should exist; it does not confirm the check is missing until you test the path.
- Write abuse-case tests for the riskiest workflows. For access control, use the OWASP approach: create User A and User B, each owning objects, authenticate as A, and try to read, create, update, delete, and export B's objects. Verify denial regardless of how predictable the identifier is. Abuse-case tests prove a specific path is closed; they cover only the workflows you thought to test.
- Add review checklists for authorization, workflow state, and rate limits. Give reviewers specific questions: does every object access check ownership, can any required step be skipped, is every repeatable action rate-limited. Checklists raise the floor of manual review; they still depend on the reviewer having enough context to answer.
- Run pattern-based analysis on every commit. Use a modern approach to SAST and software composition analysis to cover the known-vulnerability layer: injection, unsafe data flows, known CVEs in dependencies, and secrets. This runs consistently on every change. It does not reason about intent, so it leaves the logic-level flaws for the next step.
- Add intent-based analysis for logic-level flaws. Apply analysis that reasons about what the application should permit versus what it does permit, following data and identity flows the way a security researcher audits code. This covers the class pattern-based analysis cannot. It complements pattern-based analysis rather than replacing it.
- Validate every candidate finding before it reaches a developer. An unvalidated list of "possible" issues drains triage time and erodes trust. Confirm each candidate is real, with a severity, an explanation, and an exact location, before it lands in front of an engineer. Validation reduces noise; it cannot promise zero missed flaws, so it works alongside the other layers rather than above them.
- Gate and track findings in the workflow the team already uses. Confirmed findings should arrive as issues in your existing triage and assignment process, not a separate report in a new tool. This keeps findings actionable; it does not decide priority for you.
- Re-check on every change. Intent can drift as code changes. A workflow that was safe last sprint can open a gap this one. Continuous re-checking catches regressions; a single point-in-time pass cannot.
No single step in this list is sufficient alone. Each covers what the others cannot, which is the point.
Three classes of business logic vulnerability: examples, CWEs, and what to check
Representative CWEs, not an exhaustive list.
Why manual and periodic testing is not enough on its own
Manual review and periodic testing both find real flaws. Neither covers the gap alone, and leaning on either one creates a false sense of safety.
The deeper principle is independence. The method that verifies code should not be the method that wrote it. When the same agent or the same reviewer that produced a change also signs off on it, there is no segregation of duties and no independent check on its blind spots. This is the Verify stage: every change gets a thorough, independent review, using a different method than the one that generated the code, producing findings that are auditable and repeatable.
That independence has to be paired with a zero-trust, multilayered approach. Zero trust means no single check is assumed correct simply because it ran. Multilayered means deterministic and agentic analysis, abuse-case tests, and your CI verification each catch what the others cannot. The pairing matters: an independent method still has limits. Layers can share correlated blind spots, and analysis that uses a model can vary run to run, which is exactly why a dedicated validation step and a separate deterministic and agentic foundation sit alongside it. No tool in this arrangement verifies its own work, and none of them, alone or together, promises to find every flaw.
What does a good detection program need?
Each item below carries its own limit. A program is strong because the items compensate for one another, not because any one is complete.
- A written authorization model and intent definition. Limit: it is only as good as the rules you capture, and it needs updating as the business changes.
- Pattern-based analysis on every commit. Covers known and pattern-based vulnerabilities consistently. Limit: it does not reason about intent, so logic-level flaws pass through it.
- Intent-based analysis across the full codebase. Covers the logic-level class by reasoning about what should be permitted. Limit: it complements pattern-based analysis and does not replace it, and no analysis finds every flaw.
- Abuse-case tests for high-risk workflows. Prove specific paths are closed. Limit: they cover only the workflows you anticipated.
- An independent validation step. Confirms candidates are real before a developer sees them, cutting noise. Limit: validation lowers false positives but cannot guarantee zero missed flaws.
- Findings inside the existing workflow. Keeps triage fast and auditable. Limit: tracking does not set priority or decide ownership for you.
- Continuous re-checking. Catches regressions as intent drifts. Limit: it depends on every change actually triggering a re-check.
How can SonarQube Hunter Agent help you detect business logic vulnerabilities?
SonarQube Hunter Agent is an AI-powered security agent that hunts the intent-based vulnerabilities pattern-based analysis was never built to catch: broken access control and IDOR, business logic flaws, and authentication and session gaps. In these flaws the code is valid but the intent is not, so nothing looks wrong to a pattern-based scanner.
Hunter Agent works through playbooks, the way a security researcher works a code audit. A playbook is a curated, multi-step sequence of security prompts that encodes Sonar's application security expertise. The method runs in four steps. It hunts by exploring the full codebase and following data and identity flows across files to build hypotheses about where intent and implementation diverge. It confirms by investigating and validating every suspected vulnerability before it surfaces, so what reaches your team is high-precision rather than a queue of false positives. It explains each finding with a severity, a plain account of why it matters, and the exact location. It integrates confirmed findings into the SonarQube issue list as regular issues, tagged and ready to triage, assign, comment on, track, and fix in the workflow your team already uses, with nothing new to install.
Hunter Agent works with any language SonarQube Cloud supports. It complements, not replaces, SonarQube deterministic and agentic analysis: a modern approach to SAST and software composition analysis covers known and pattern-based vulnerabilities such as injection, unsafe data flows, known CVEs, and secrets on every commit, while Hunter Agent adds the intent-based layer. Together they form zero-trust, multilayered verification across the Verify stage, so no single check carries the whole codebase's trust, and the method that reviews the code is not the one that wrote it.
Hunter Agent finds flaws; it does not remediate them. SonarQube Remediation Agent can prepare verified fixes for confirmed findings and open pull requests for developer review. Hunter Agent covers what ships between penetration tests. It does not replace penetration tests or bug bounties.
