Install
openclaw skills install bookforge-application-logic-flaw-testingTest web application business logic for vulnerabilities that automated scanners cannot detect. Use this skill when: performing a penetration test or security assessment and automated tools have been run but logic-layer coverage is still needed; testing multistage workflows (checkout, account creation, approval flows, insurance applications) for stage-skipping or cross-stage parameter pollution; probing authentication and password-change functions for parameter-removal bypasses (deleting existingPassword to impersonate an admin); testing numeric business limits for negative-number bypass (submitting -$20,000 to avoid approval thresholds); probing discount or pricing logic for timing flaws (add items to qualify, remove before payment); investigating whether shared code components allow session object poisoning across unrelated application flows; hunting for encryption oracles where a low-value crypto context can be used to forge high-value tokens; probing search functions that return match counts as side-channel inference oracles; testing for defense interaction flaws where quote-doubling plus length truncation reconstructs an injection payload; checking whether debug error messages expose session tokens or credentials cross-user via static storage; testing race conditions in authentication that cause cross-user session assignment under concurrent login. Logic flaws arise from violated developer assumptions — assumptions that users will follow intended sequences, supply only requested parameters, omit parameters they were not asked for, and not cross-pollinate state between application flows. Each flaw is unique and application-specific, but the 12 attack patterns documented here provide a reusable taxonomy that transfers across application domains. Maps to OWASP Testing Guide (OTG-BUSLOGIC-*), CWE-840 (Business Logic Errors), CWE-841 (Improper Enforcement of Behavioral Workflow), CWE-362 (Race Condition), and OWASP Top 10 A04:2021 (Insecure Design).
openclaw skills install bookforge-application-logic-flaw-testingUse this skill when you need to discover business logic vulnerabilities that no automated scanner will find. Automated tools identify vulnerabilities with recognizable signatures — SQL injection payloads that produce database errors, cross-site scripting payloads that reflect in responses. Logic flaws have no signature. Each instance is a unique one-off tied to the specific assumptions a development team made when building a particular feature.
Logic flaws arise when a developer reasons: "If A happens, then B must be the case, so I will do C" — and fails to ask "But what if X occurs?" The flaw is not in a library or protocol; it is in the developer's mental model of how users will behave. Testing for logic flaws therefore requires getting inside that mental model, understanding what the developers assumed, and then deliberately violating those assumptions.
This skill applies to authorized penetration tests, appsec audits, and security code reviews. It is not a substitute for legal authorization to test a target application.
Logic flaws differ from injection or authentication vulnerabilities in three critical ways:
The defining characteristic of every logic flaw is a violated assumption: a condition the developer believed could never occur, which the attacker can deliberately engineer.
For each area of functionality under test, apply this analytical frame:
Step 1: Map all multistage workflows. Identify every process that spans more than one HTTP request or page: checkout flows, account registration, password change, loan/insurance applications, approval chains. Document the intended sequence and the mechanism by which stages are linked (URL parameters, POST fields, session state).
Why: Logic flaws concentrate in workflows because developers mentally simulate users following the intended path. Every stage transition is a potential assumption violation point.
Step 2: Identify all user roles and shared components. Determine what roles exist (anonymous, authenticated user, administrator, underwriter, etc.) and whether any server-side code components are shared across roles. Note any functionality that allows one role to trigger server-side state that another role reads.
Why: Shared components are the most dangerous logic flaw surface. A component designed for Role A that is reused for Role B often carries assumptions that are valid in one context and exploitable in the other.
Step 3: Document all parameters in each workflow. For each request in a workflow, record every parameter name and value. Note which parameters are hidden, which are read from session vs. the request, and which differ between user roles performing the same operation.
Why: Parameter names that differ between roles (e.g., existingPassword present for users, absent for admins) reveal assumption-based branching in server logic.
Work through each pattern below as a lens. For each pattern, identify which application areas are plausible candidates, then design a targeted test.
Violated assumption: The encryption algorithm and key used to protect a high-value token are not accessible to users through any other mechanism.
Test approach: Identify every location where the application encrypts or decrypts data supplied by or returned to the user. Look for low-value encrypted values (screen name cookies, preference tokens) that use the same algorithm/key as high-value tokens (authentication tokens, session identifiers). Submit a high-value encrypted token in a field expecting a low-value encrypted token. Observe whether the application decrypts and processes it.
Hack steps:
Impact: Complete authentication bypass. Attacker forges a session token for any user, including administrators.
Violated assumption: The presence or absence of a parameter in a request reliably indicates the user's role or privilege level.
Test approach: For every request in a sensitive workflow, remove each parameter entirely (not just blank it — delete the name/value pair). Observe whether the server's behavior changes. Pay special attention to parameters that differ between roles performing the same function.
Hack steps:
Impact: Authentication bypass, privilege escalation, or constraint removal depending on which parameter controls which check.
Violated assumption: Users will always access multistage functions in the intended sequence because the browser presents them in that order.
Test approach: Map the intended sequence of a multistage workflow. Attempt to access later stages directly without completing earlier stages. Try accessing stage N+2 from stage N (skip one), accessing the final confirmation step from the first step, and re-accessing early stages after completing later ones.
Hack steps:
Impact: Payment bypass, authorization bypass, approval bypass — any business rule enforced in a skipped stage is evaded.
Violated assumption: Users will only submit the parameters that the HTML form at each stage requests; they will not supply parameters from other stages or roles.
Test approach: In a multistage workflow, identify parameters submitted at each stage. During a later stage, additionally submit parameters that belong to an earlier stage (or that belong to a different user role). If the server maintains a shared state object that is updated with any parameter supplied at any stage, out-of-sequence parameters will be accepted and processed.
Hack steps:
Impact: Price manipulation, approval bypass, privilege escalation, cross-site scripting stored against privileged reviewers.
Violated assumption: A code component reused across multiple features creates independent session objects in each context; using it in one flow does not affect the session state in another.
Test approach: Identify features that allow a user to input data that is stored in the session (registration, profile update, account switch). After completing such a flow, navigate to a completely different area of the application and observe whether the session state accumulated in the first flow affects the second flow's behavior or output.
Hack steps:
Impact: Full account takeover — attacker accesses another user's financial data, statements, and transactional functionality.
Violated assumption: The value supplied for a quantity or amount will always be positive; the approval threshold check (amount <= threshold) will always catch large transfers.
Test approach: For any numeric input that controls a business limit, pricing calculation, or approval threshold, submit negative values. Observe whether the server accepts them, how it processes them, and what downstream effect occurs.
Hack steps:
Impact: Financial fraud, approval bypass, inventory manipulation.
Violated assumption: A user who qualifies for a discount at the time of adding items to a cart will purchase all the qualifying items; discount adjustments applied at add-time are final.
Test approach: In any application that applies discounts, pricing adjustments, or promotions based on the composition of a user's cart or order, add items to qualify for the adjustment, then remove some qualifying items after the discount has been applied. Observe whether the discount persists on remaining items.
Hack steps:
Impact: Unauthorized price reductions, financial loss to the application owner.
Violated assumption: Escaping all potentially dangerous metacharacters in user input provides complete protection against injection; the escape character itself is not dangerous.
Test approach: When probing for command injection or other metacharacter-sensitive injection points where escaping is applied, prefix each dangerous character with a backslash. If the application escapes the semicolon in foo;ls to produce foo\;ls but does not also escape the backslash, then input foo\;ls will be transformed to foo\\;ls — where the shell interpreter treats the first backslash as escaping the second, leaving the semicolon unescaped.
Hack steps:
foo\;ls → after escaping: foo\\;ls → shell sees: literal backslash + unescaped semicolon = command injection.Impact: Command injection, cross-site scripting — complete bypass of the escaping defense.
Violated assumption: Two independently sound defense mechanisms (quote-escaping and length truncation) are still sound when applied in sequence.
Test approach: When an application doubles single quotes to prevent SQL injection and also truncates input to a maximum length, the two defenses interact destructively. A payload of 127 a's followed by a single quote: the doubling adds one character (making it 129), then truncation to 128 removes the doubled second quote, leaving a single unescaped quote that breaks query syntax.
Hack steps:
a characters followed by a single quote. Observe whether an error occurs after either even or odd numbers of characters are submitted.SELSELECTECT — removing the inner SELECT leaves SELECT.Impact: SQL injection bypass, authentication bypass despite defense-in-depth measures.
Violated assumption: A search function that returns only document titles (not content) provides no meaningful access to the documents' protected content.
Test approach: When a search function returns the count of matching documents (or a binary match/no-match indication) rather than full document content, it can be exploited as an oracle. Issue a large number of targeted queries, narrowing down the content of protected documents through binary search — similar to blind SQL injection inference.
Hack steps:
[topic] [subtopic] returns 1 match and [topic] [subtopic] [candidate phrase] returns 0, the document does not contain that phrase.Impact: Unauthorized disclosure of protected content, credential leakage, competitive intelligence exposure.
Violated assumption: Debug information returned to a user only contains data about that user's own session and request; it is harmless to display because the user already has access to this information.
Test approach: Identify any conditions that cause verbose error messages, debug dumps, or diagnostic responses containing user-specific information (session tokens, usernames, request parameters). Determine whether the storage mechanism for this information is session-scoped or stored in a static (application-global) container. If static, poll the error message endpoint repeatedly across time — it will intermittently expose other users' session data.
Hack steps:
Impact: Mass credential harvesting — session tokens, usernames, and user-supplied input (possibly passwords) exposed across the entire user base.
Violated assumption: The login process, which has been reviewed and tested, is thread-safe; it cannot produce cross-user session assignment.
Test approach: Race conditions in authentication arise when a key identifier (user ID, session object) is briefly written to a static (non-session) variable during the login flow. If two login requests execute concurrently, one thread may overwrite the static variable before the other thread reads it, causing the earlier thread's session to be established with the second user's identity. Testing requires generating high volumes of concurrent requests against security-critical functions.
Hack steps:
Caution: Remote black-box race condition testing is a specialized undertaking appropriate only for the most security-critical applications. It generates high request volumes that may resemble a load test.
Impact: Complete authentication bypass, cross-user account access, financial fraud.
Step 1: Classify each finding by flaw pattern. For each confirmed vulnerability, identify which of the 12 patterns it instantiates (or describe a new pattern if none applies). State the violated developer assumption explicitly.
Step 2: Document reproduction steps. Capture the exact HTTP requests needed to reproduce the flaw. For multistage exploits, number each step.
Step 3: Rate business impact. Logic flaws often have severe business impact (payment bypass, account takeover, financial fraud) even when the technical complexity of exploitation is low. Rate impact in business terms, not just technical severity.
Step 4: Produce remediation recommendations. Map each finding to the relevant defensive principle from the Avoiding Logic Flaws section below.
These principles apply to developers building secure applications and to testers verifying that defenses are adequate.
Scenario: Authorized penetration test of an online retail platform.
Trigger: Application implements a four-stage checkout: browse, basket review, payment, delivery. Tester has mapped the workflow and confirmed each stage is served from a distinct URL.
Process:
Output: Finding: "Checkout Stage Skip — Payment Bypass." Violated assumption: users always access checkout stages in sequence. Business impact: attackers can generate fulfilled orders without paying. Remediation: enforce that payment stage has been completed server-side (session flag set only after successful payment processing) before accepting the delivery stage request.
Scenario: Security assessment of a financial services insurance web application with applicant and underwriter roles.
Trigger: Application processes a multi-dozen-stage insurance application. Tester notices that the application uses a shared server-side component that updates application state with any name/value pair received in a POST request.
Process:
underwriterDecision=accept).Output: Finding: "Cross-Stage Parameter Pollution — Applicant Self-Underwriting." Violated assumption: only underwriters submit underwriter parameters. Business impact: applicants can accept their own insurance applications at arbitrary premium values. Remediation: enforce role-based access control at the parameter level; the server must validate that each parameter is appropriate for the authenticated user's role before updating application state.
Scenario: Penetration test of a recently deployed financial services web application that exhibits intermittent errors.
Trigger: During normal testing, an error page appears containing the current user's username, session token, and request parameters. The tester notes this is returned as a redirect to a static URL (/app/error?id=last).
Process:
/app/error?id=last from Account B./app/error?id=last every few seconds over a 30-minute window, logging all responses.Output: Finding: "Static Debug Storage — Cross-User Session Token Disclosure." Violated assumption: each user sees only their own debug information because they follow the redirect to their own error. Business impact: an attacker who polls the error endpoint over time accumulates session tokens for other users and can hijack those sessions. Remediation: store debug information in session-scoped storage, not a static global container; or disable verbose debug messages in production entirely.
This skill is licensed under CC-BY-SA-4.0. Source: BookForge — The Web Application Hacker's Handbook: Finding and Exploiting Security Flaws by Dafydd Stuttard, Marcus Pinto.
This skill is standalone. Browse more BookForge skills: bookforge-skills