Beta notice. Logic Scan is in beta. Rules, severity and confidence levels, and the report format may change before release, and some findings will be false positives. The release date and plan described in section 8 are current plans and may change.
Abstract
Business logic, authentication and authorisation flaws let a user do something an application should not allow, such as read another customer's records or redeem a voucher twice. They rarely involve malformed input, so the data-flow analysis used by most static application security testing (SAST) tools does not detect them. This paper describes AquilaX Logic Scan, a static analyser that builds a model of how each request is handled and checks it against 344 rules for missing, broken or misordered checks. It explains the approach, gives eight examples with the scanner's actual output, and sets out the limitations of the current version.
1Introduction
Most security testing of source code is concerned with how data is handled. A SAST tool follows input from a request to places where it could cause harm, such as an SQL query, a shell command or an HTML page, and reports the paths on which it is not made safe. This finds injection, cross-site scripting and similar flaws, and it remains a necessary part of secure development.
Another class of flaw concerns what an application allows rather than how it handles data. A signed-in user changes the id in /invoices/1042 and receives another customer's invoice. A new account is registered with "role": "admin" in the request body. Two identical requests sent at the same moment redeem the same gift card twice. The requests are well formed, each line of code may be correct on its own, and nothing unusual reaches a dangerous function. The fault is a check that is missing, a check made in the wrong place, or a business rule the code never enforces.
Flaws of this kind are common. Broken access control is the first category in the OWASP Top 10:2025, as it was in the 2021 edition [1], and four of the first five risks in the OWASP API Security Top 10 (2023) concern authentication or authorisation [2]. They are also hard to notice in production, because the requests that exploit them look like ordinary use.
Section 2 explains why data-flow analysis does not find these flaws. Sections 3 and 4 describe how Logic Scan works and what it covers. Section 5 gives eight examples, section 6 describes the content of a finding, section 7 lists limitations, and section 8 gives the current status.
2Why data-flow analysis does not find logic flaws
A SAST rule usually has three parts: a source of untrusted data, a sink where that data could do harm, and a list of functions that make the data safe in between. A finding is a path from source to sink that does not pass through one of those functions.
A logic flaw usually has no such path. Its code may contain no sink at all, or use the database safely. To recognise the flaw, a tool needs information that data-flow analysis does not model: who is making the request, which records belong to them, which role or organisation they are acting in, what has already been checked, and how other endpoints of the same application behave.
2.1 An example
Figure 1 shows a money transfer endpoint written for this paper. It requires a login, reads the sender's balance and rejects the transfer if the balance is too low. There is no string concatenation, no shell command and no output to a page. A data-flow rule might at most note that the request's to value is used in a database query.
6app.post('/transfer', requireAuth, async (req, res) => { 7 const { to, amount } = req.body; 8 const sender = await User.findById(req.user.id); 9 if (sender.balance < amount) return res.status(400).json({ error: 'Not enough funds' }); 10 await User.updateOne({ _id: sender.id }, { $inc: { balance: -amount } }); 11 await User.updateOne({ _id: to }, { $inc: { balance: amount } }); 12 res.json({ ok: true }); 13});
Figure 1. A money transfer endpoint (JavaScript, Express). Highlighted lines have findings. Lines 1 to 5, not shown, contain imports and create the application.
Scanned with all 344 rules, Logic Scan reports the seven findings in Table 1. None of them concerns how the data is handled.
Table 1. Findings reported for Figure 1
| Rule | Title | Severity | Confidence | Line |
|---|---|---|---|---|
| LS066 | Amount can be negative | Critical | Medium | 10 |
| LS068 | Balance check and update can race | High | Medium | 10 |
| LS102 | Money can leave the account without extra verification | High | Medium | 10 |
| LS070 | Related money changes are not in one transaction | High | Medium | 11 |
| LS001 | Application has no rate limiting | Medium | High | 4 |
| LS103 | Transfers have no maximum or daily limit | Medium | Low | 10 |
| LS071 | Users can transfer to themselves | Medium | Medium | 11 |
Several of these need knowledge of the whole request. LS068 is reported because the balance is read and compared at line 9 and changed separately at line 10, so two simultaneous transfers can both pass the check. LS066 is reported because the amount comes from the client and is never required to be greater than zero, so a negative amount would move money from the recipient to the sender. LS001 refers to line 4, where the application is created without any rate limiting.
2.2 Comparison
Table 2. Data-flow SAST and Logic Scan compared
| Data-flow SAST | Logic Scan | |
|---|---|---|
| Question asked | Can untrusted data reach a dangerous function without being made safe? | Can someone do something the application should not allow? |
| What is modelled | Sources, sinks and the paths between them | Routes, middleware, the signed-in user, roles, organisations, record owners, state, and the order of steps in each request |
| Typical findings | SQL and command injection, cross-site scripting, path traversal, unsafe deserialisation | Access to other users' records, privilege escalation, second-factor bypass, reusable reset links, race conditions on balances, self-approval |
| Across endpoints | Each path is usually checked on its own | Compares endpoints, for example an owner filter or admin check present on one and missing from another |
Dynamic testing (DAST) and penetration testing can also find logic flaws, but only in the parts of a running application they reach with the accounts they are given, and usually late in development. Static analysis covers all of the code and can run on every change. The methods find different things and work best together.
3How Logic Scan works
3.1 Analysis
A scan has four stages.
- Each source file is parsed into a syntax tree and converted to a common representation, so that most rules are written once for all supported languages.
- Routes, the middleware that runs before them, and database operations are identified. Function calls are linked across files.
- For each route, the checks, database operations and responses are put in order. The origin of each value is tracked: the client, the signed-in user or the database.
- The rules are applied. Each looks for one missing, broken or misordered step, such as a record loaded without its owner, or a balance checked in one step and changed in another.
The engine is deterministic. It does not use a machine learning model, does not run the application and makes no network requests, so the same code always produces the same findings. Reports are produced as text, JSON or SARIF 2.1.0.
3.2 Rule types
Table 3. The three kinds of rule
| Kind | What the rule examines | Rules |
|---|---|---|
| Request | The steps of one request, from its route and middleware through the functions it calls. Example: whether a balance check and its update can race. | 198 |
| Project | The project as a whole, including how endpoints compare. Example: whether a limit or owner check on one endpoint is missing from another. | 87 |
| Code | Individual expressions, using what is known about the project. Example: whether a login token is decoded without its signature being checked. | 59 |
3.3 Languages and frameworks
Table 4. Supported languages and recognised web frameworks
| Language | Web frameworks |
|---|---|
| JavaScript, TypeScript | Express, Koa, Fastify, Hapi, Hono, Next.js, NestJS, TypeGraphQL, Socket.IO |
| Python | Flask, FastAPI, Django, Django REST Framework, Connexion, Graphene |
| Go | net/http, Gin, Echo, Chi, Gorilla, Fiber |
| PHP | Laravel, Slim, Symfony, plain PHP |
| Java | Spring, JAX-RS |
| Ruby | Rails, Sinatra |
| Perl | Mojolicious, Dancer, CGI |
Coverage is widest for JavaScript and TypeScript. Most rules run on every language, but not every rule has yet been tested in every language.
3.4 Scan time
Table 5 gives scan times for nine open-source projects, some of which are deliberately vulnerable training applications.
Table 5. Scan time with all 344 rules
| Project | Main languages | Lines | Routes | Seconds |
|---|---|---|---|---|
| BookStack | PHP | 216,091 | 348 | 0.90 |
| Bugzilla | Perl | 116,067 | 11 | 0.46 |
| Redash | Python, TypeScript | 76,138 | 12 | 0.23 |
| WebGoat | Java | 63,048 | 249 | 0.30 |
| OWASP Juice Shop | TypeScript | 31,205 | 279 | 0.60 |
| Healthchecks | Python | 24,445 | 132 | 0.13 |
| DVWA | PHP | 13,217 | 85 | 0.09 |
| PyGoat | Python | 8,876 | 202 | 0.06 |
| RailsGoat | Ruby | 3,384 | 47 | 0.03 |
Measured in December 2026 on an Apple M3 (8 cores, 16 GB). Median of five scans after one warm-up. Routes are those the scanner recognised.
4Coverage
The 344 rules are grouped into 24 categories in six areas (Table 6). Each rule has a severity, a confidence level and a CWE identifier [3]. There are 63 critical, 149 high, 102 medium and 30 low severity rules, mapped to 109 CWE types.
Table 6. Rules by area
| Area | Examples of what is checked | Categories | Rules |
|---|---|---|---|
| Identity, sign-in and sessions | Login, multi-factor authentication, password reset, sessions, OAuth, API keys and other tokens | 6 | 72 |
| Access control and data ownership | Access to other users' records, missing role and tenant checks, request fields that override trusted values | 4 | 73 |
| Organisations, membership and plans | Roles across organisations, invited and removed members, cancelled plans, trials and licences | 3 | 39 |
| Payments and commerce | Prices, quantities, balances, coupons, refunds, payment webhooks and order totals | 2 | 28 |
| Workflow, business controls and abuse | Status changes, approvals, skipped or repeated steps, race conditions and rate limits | 6 | 74 |
| Integrations, AI and exposed data | Outside services, output from AI models, and some injection and data exposure checks | 3 | 58 |
The last area includes some injection and data exposure rules. These overlap with SAST and are not intended to replace it.
Table 7 relates the authentication, authorisation and business flow risks in the OWASP API Security Top 10 [2] to examples of Logic Scan rules. The mapping is indicative. A rule covers particular forms of a risk, not the whole of it.
Table 7. OWASP API Security Top 10 (2023) risks and examples of related rules
| OWASP | Risk | Examples of rules |
|---|---|---|
| API1:2023 | Broken Object Level Authorization | LS039 Any user can read another user's recordLS040 Any user can change another user's recordLS041 Any user can delete another user's recordLS054 List endpoint returns everyone's records |
| API2:2023 | Broken Authentication | LS002 Login has no brute-force protectionLS010 Token is decoded but never verifiedLS013 Login can complete without the second factorLS022 Password-reset token can be reused |
| API3:2023 | Broken Object Property Level Authorization | LS031 New users can choose their own privilegesLS048 Entire request body is saved to the databaseLS049 Request body overrides a trusted fieldLS063 Complete user record is returned to the client |
| API5:2023 | Broken Function Level Authorization | LS037 Admin endpoint does not check for an admin roleLS043 Permission decision uses a role sent by the clientLS050 Roles can be changed without an admin check |
| API6:2023 | Unrestricted Access to Sensitive Business Flows | LS073 Coupon can be used without limitLS085 Reward can be claimed repeatedlyLS093 One-time item can be redeemed twice in parallel |
5Examples
The examples below were written for this paper and are deliberately vulnerable. They should not be reused. Each was scanned exactly as printed, with only the rule concerned enabled. The highlighted line is where the finding is reported. The Finding, Who and How text is the scanner's output, and the Fix text is the rule's standard advice.
5.1 Reading another customer's invoice
An invoice is loaded by the id in the URL. The route requires a login, but it accepts any id from any signed-in user.
const Invoice = mongoose.model('Invoice', new Schema({ userId: String, total: Number })); app.get('/invoices/:id', requireAuth, async (req, res) => { const invoice = await Invoice.findById(req.params.id); res.json(invoice); });
Figure 2. JavaScript (Express). The highlighted line is where LS039 is reported.
| Rule | LS039 Any user can read another user's record. High severity, medium confidence, CWE-639. |
|---|---|
| Finding | This invoice is loaded using only req.params.id. Nothing checks that it belongs to the caller. |
| Who | Any signed-in user. |
| How | Send GET /invoices/:id with another record's id, for example by counting up. The answer contains someone else's data. |
| Fix | Include the owner in the query, or compare the record's owner with the signed-in user. |
Comment. The query itself is safe, and the route requires a login. What is missing is a comparison between the owner of the invoice and the caller, and a data-flow rule has no notion of either.
5.2 Choosing a role at registration
The registration endpoint copies the role field from the request body into the new account.
app.post('/register', async (req, res) => { const { email, password, role } = req.body; await User.create({ email, password: hash(password), role }); res.sendStatus(201); });
Figure 3. JavaScript (Express). The highlighted line is where LS031 is reported.
| Rule | LS031 New users can choose their own privileges. Critical severity, medium confidence, CWE-269. |
|---|---|
| Finding | role for the new account comes from req.body.role, which the person registering controls. |
| Who | Anyone who can reach the application. People use this route before they are logged in. |
| How | Send POST /register with a role or admin field added. The new account gets that role. |
| Fix | Set the role on the server and change it only through an administrator endpoint. |
Comment. Copying fields from a request body into a record is normal. It matters here only because the field is the account's role and the caller has not yet signed in.
5.3 Checking the role in a different organisation
A middleware function checks that the caller owns the team named in a request header. The handler then updates the team named in the URL.
async function requireOwner(req, res, next) { const team = await Team.findOne({ _id: req.headers['x-team-id'], 'members.user': req.user.id }); if (!team || team.role !== 'owner') return res.sendStatus(403); next(); } app.put('/teams/:id', requireAuth, requireOwner, async (req, res) => { await Team.updateOne({ _id: req.params.id }, { name: req.body.name }); res.json({ ok: true }); });
Figure 4. JavaScript (Express). The highlighted line is where LS146 is reported.
| Rule | LS146 Role is checked in a different organisation from the one changed. Critical severity, medium confidence, CWE-639. |
|---|---|
| Finding | The caller's role is checked in the team chosen by req.headers.x-team-id, but the one changed here comes from the URL path. |
| Who | A signed-in user who has the role that this route checks. |
| How | Create their own organisation, where they are the owner, and send PUT /teams/:id for a different one. The role is checked in the wrong organisation. |
| Fix | Check the caller's role in the organisation being changed, using the same ID for both. |
Comment. The ownership check and the update are each correct. They refer to different teams, which can only be seen by comparing the id used in each.
5.4 Signing in without the second factor
Accounts can enable a second factor, but the login endpoint issues a full token after the password check alone.
const User = mongoose.model('User', new mongoose.Schema({ email: String, password: String, twoFactorEnabled: Boolean, twoFactor: Object })); app.post('/login', async (req, res) => { const user = await User.findOne({ email: req.body.email }); if (!user || !(await bcrypt.compare(req.body.password, user.password))) return res.sendStatus(401); res.json({ token: jwt.sign({ id: user.id }, KEY, { expiresIn: '1h' }) }); });
Figure 5. JavaScript (Express). The highlighted line is where LS013 is reported.
| Rule | LS013 Login can complete without the second factor. High severity, medium confidence, CWE-304. |
|---|---|
| Finding | user accounts can enable a second factor, but this login never checks for it. |
| Who | Someone who knows the user's password. |
| How | Log in with POST /login and skip the second step. The session already works without the code. |
| Fix | Check the MFA state first and issue only a short-lived, limited token until the second factor passes. |
Comment. The password check is correct. The problem is a step that never takes place. The scanner reports it because the user model has second-factor fields that this login never reads.
5.5 Reusing a password-reset link
The reset endpoint finds the user by token and saves the new password, but leaves the token in place.
app.post('/reset-password', async (req, res) => { const user = await User.findOne({ resetToken: req.body.token }); if (!user) return res.sendStatus(400); user.password = await bcrypt.hash(req.body.password, 10); await user.save(); res.json({ ok: true }); });
Figure 6. JavaScript (Express). The highlighted line is where LS022 is reported.
| Rule | LS022 Password-reset token can be reused. High severity, medium confidence, CWE-640. |
|---|---|
| Finding | The password is changed, but the reset token in user is never cleared, so the link keeps working. |
| Who | Someone who finds a reset link that was already used. |
| How | Use the link again to set another password. |
| Fix | Clear or delete the token in the same step that changes the password. |
Comment. No line here is unsafe on its own. The token should be cleared when the password changes, and the rule looks for that missing update.
5.6 Redeeming one gift card twice
A gift card is checked for use and then marked as used, in two separate steps.
app.post('/gift/redeem', requireAuth, async (req, res) => { const card = await GiftCard.findOne({ code: req.body.code }); if (card.redeemed) return res.sendStatus(409); card.redeemed = true; await card.save(); await User.updateOne({ _id: req.user.id }, { $inc: { balance: 50 } }); res.json({ ok: true }); });
Figure 7. JavaScript (Express). The highlighted line is where LS093 is reported.
| Rule | LS093 One-time item can be redeemed twice in parallel. High severity, medium confidence, CWE-367. |
|---|---|
| Finding | redeemed was checked earlier and is only set here, so parallel requests can all redeem the same gift_card. |
| Who | Any signed-in user. |
| How | Send POST /gift/redeem twice at the same moment with the same item. Both requests see it as unused. |
| Fix | Mark it used with one update that only matches unused items, then check that a row changed. |
Comment. Taken one request at a time, the code is correct. The flaw appears only with two concurrent requests that both read the card before either marks it as used.
5.7 Approving one's own expense claim
Any signed-in user can approve a pending expense claim, including a claim they submitted themselves.
app.post('/expenses', requireAuth, async (req, res) => res.json(await Expense.create({ submittedBy: req.user.id }))); app.post('/expenses/:id/approve', requireAuth, async (req, res) => { await Expense.updateOne({ _id: req.params.id, status: 'pending' }, { status: 'approved' }); res.json({ ok: true }); });
Figure 8. JavaScript (Express). The highlighted line is where LS088 is reported.
| Rule | LS088 Users can approve their own requests. High severity, medium confidence, CWE-840. |
|---|---|
| Finding | The approver is never compared with expense.submitted_by, so people can approve their own requests. |
| Who | Any signed-in user. |
| How | Make a request, then approve it themselves with POST /expenses/:id/approve. The two people are never compared. |
| Fix | Reject approvals from the person who created the request. |
Comment. The approval requires a login and only affects pending claims. The missing control is separation of duties, which is a business rule rather than a property of the data.
5.8 Keeping a paid plan after cancelling
A billing webhook handles the event for a deleted subscription by saving the subscription's plan again.
async def save_plan(event): found = stripe.Subscription.retrieve(event["data"]["object"]["id"]) await db["clubs"].update_one({"subscription_id": found.id}, {"$set": {"plan": found.plan.nickname}}) @app.post("/webhook/billing") async def billing(request: Request): event = stripe.Webhook.construct_event(await request.body(), request.headers["Stripe-Signature"], SECRET) if event["type"] == "customer.subscription.deleted": await save_plan(event) return {"ok": True}
Figure 9. Python (FastAPI). The highlighted line is where LS213 is reported.
| Rule | LS213 Cancelled subscription keeps its paid plan. High severity, medium confidence, CWE-841. |
|---|---|
| Finding | When a subscription ends, this saves its old plan again instead of removing it. |
| Who | A customer who cancels. |
| How | Cancel the subscription and keep using the paid features. POST /webhook/billing does not remove them. |
| Fix | Set the free plan and limits for events that end a subscription, and check the subscription's status. |
Comment. The webhook signature is verified, so the event is genuine. The error is in what the handler does with it.
6Content of a finding
Each finding gives the rule, category, severity, confidence and CWE type; the file, line and code; the route and any related lines; and a short description of the problem, who could misuse it, how, the likely impact and a fix. JSON and SARIF reports also include a fingerprint that does not depend on line numbers, so a finding can be tracked as the surrounding code changes. Figure 10 shows the text report for LS068 from Figure 1.
HIGH LS068 Balance check and update can race
app.js:10:9
Route: POST /transfer
await User.updateOne({ _id: sender.id }, { $inc: { balance: -amount } });
Problem: `balance` was read and checked earlier, then changed here in a separate step. Parallel
requests can all pass the check, so the same money can be spent more than once.
- app.js:9: the value is checked here
Who: Any signed-in user.
How: Send `POST /transfer` many times at the same moment. All requests see the same balance and
pass the check before it goes down.
Impact: Parallel requests can all pass the check before any of them subtracts, so the same money is
spent several times.
Fix: Use one conditional update (`WHERE balance >= amount`) or lock the row in a transaction.
payments | CWE-362 | confidence: medium
Figure 10. Text report for one finding, reproduced as printed by the scanner.
Severity describes how serious a flaw would be. Confidence describes how likely a finding is to be correct. 38 rules are rated high confidence. Four of them are logic rules that were shown to be accurate on applications they were not developed against. For the other 34, the flaw is directly visible in the code. 298 rules are rated medium and 8 low. All findings should be reviewed by someone who knows the application.
Results can be filtered by severity and confidence, rules can be enabled or disabled, folders can be excluded, and individual findings can be suppressed with a comment in the code. A pipeline can be set to fail when a finding at or above a chosen severity is reported.
7Limitations
- The scanner does not know what an application is meant to do. It finds violations of common rules, such as ownership, roles, payment and one-time use. Flaws specific to one business, such as a payment attached to the wrong order, generally need a human reviewer.
- It does not run code, so it can miss routes, queries or checks that are chosen at runtime.
- It cannot see controls outside the code, such as rate limits in an API gateway or reverse proxy. Rules that such controls cover can be disabled.
- Fields and functions are mostly recognised by common English names, such as
ownerorbalance. Unusual or non-English names can hide flaws. - Values that are stored and read back in a later request are not followed.
- Some findings will be false positives, and some flaws will be missed. During the beta, rules and confidence levels are still being adjusted.
- A scan with no findings does not show that an application is secure. Logic Scan is meant to be used alongside SAST, code review and penetration testing.
8Status and availability
Logic Scan is in beta. The current scanner version is 0.1.0. During the beta, rules are being added and adjusted, and severity, confidence levels and the report format may change between versions.
Logic Scan is planned to be released as part of the AquilaX Ultimate plan in January 2027. This is the current plan, and the date or plan may change before release.
A technical sheet listing all 344 rules, with an example of each, is available from AquilaX. Questions and feedback about the beta can be sent to your usual AquilaX contact, or through our contact page.
References
- [1]OWASP Foundation. OWASP Top 10:2025. https://owasp.org/Top10/2025/
- [2]OWASP Foundation. OWASP API Security Top 10, 2023 edition. https://owasp.org/API-Security/
- [3]MITRE. Common Weakness Enumeration. https://cwe.mitre.org/