Repository navigation
Validation and Chains
Between phase 1 producing findings and the report being written, every finding is deduplicated, graded, and joined into exploit chains where one exists. All of it runs in AnalysisService._grade_findings, after the static and dynamic phases and before the JSON export.
Order: dedupe → gates → model review → cross-reference → chain build → chains graded → re-sort. The first three happen inside validate_findings. Validation runs first so the gates have marked chain_eligible; a confirmed chain then writes back into its components' gate results.
The whole stage is best-effort. A grading failure leaves the findings exactly as the analyzers produced them.
A finding that fails a gate is downgraded, labelled with the reason, and excluded from the security score. It still appears in the report, near the bottom.
The audience owns the app. allowBackup=true is a legitimate thing for them to know about their own build even though no attacker can use it against their users. Losing a true statement about the app is a worse failure than showing one at the wrong severity.
| Verdict | Effect |
|---|---|
PASS |
Unchanged |
DOWNGRADE |
Severity lowered one rung (or to the reviewer's proposal, if lower), reason recorded. A model review's downgrade never goes below Low or below the review floor |
CHAIN_REQUIRED |
Forced to Informational. Real, but only matters combined with another finding |
FALSE_POSITIVE |
Forced to Informational. A rule matched, the code does not support the claim |
INFORMATIONAL |
Forced to Informational. Worth knowing, not a vulnerability |
There is no KILL. Verdicts are ordered weakest to strongest and the worst one a finding collects wins, so a weak-class finding reported at LOW confidence lands on CHAIN_REQUIRED, not DOWNGRADE, and carries both reasons.
FALSE_POSITIVE is kept, not deleted, so the tool's mistakes stay auditable.
Every finding gains a gate_result:
{
"verdict": "CHAIN_REQUIRED",
"reasons": ["Backup-extractable app data. Backup is a documented platform feature and on by default. What matters is what would be in the backup: name a credential in app storage and this becomes a real extraction path."],
"warnings": ["Confirm the app's targetSdkVersion before treating this as exploitable."],
"original_severity": "Medium",
"final_severity": "Informational",
"chain_eligible": true,
"weak_class_rule": "WEAK-02",
"mechanically_refuted": false,
"severity_cap": "",
"needs_recitation": false
}original_severity is kept so a demoted finding reads as a deliberate judgement rather than the tool under-rating the issue. severity_cap is the lowest ceiling any gate imposed (empty when none did); the model passes apply it again after their own verdict, so a reviewer's PASS cannot lift a finding back over it. A cap's reason is recorded only when the cap is below the severity the finding arrived with: "too shallow to support a Critical" under a finding that was only ever High described a change that never happened.
Before validation, each analyzer's merge_findings makes a first pass over its agent and rule findings: an exact title-and-file repeat collapses, and so do two findings from one engine at the same place (same class, file and four-line bucket). A rule finding and an AI finding at one place are left for the deduplication below, which merges them with content absorbed, the merge recorded and different facts kept apart; the first pass used to keep only the richer of the two, and a Ghera scan lost a scanner's enforcePermission() finding to the agent's vaguer one on the same line with no trace.
validation/dedupe.py runs first inside validate_findings, before any gate. Grading a defect twice wastes a review slot on each copy and lands both in the report at different severities, which reads as two problems and makes the score count one defect twice.
Exact (title, file, line) matching is not enough. The same defect arrives worded twice, one line apart, or seen once from the manifest and once from the class (different files, so no path-based key can ever join them).
Findings are grouped by vulnerability class + subject, where the subject is the component name mined from the title, description and filename rather than the path. A finding citing the manifest takes the component its cited element declares (android:name in the snippet) when its title names none, since the manifest's own name says nothing: an agent's "Unprotected exported activity allows token forgery" at the activity's element used to take "exported" as its subject and stay apart from "Exported activity NewPasswordActivity". infer_vuln_class takes an explicit code from the model when it is one of ours, else infers from wording, most specific hint first (SQL injection beats content provider).
A platform API is never a subject: AsyncStorage, SharedPreferences, WebView, Logcat, FileWriter, MethodChannel and the like say how something is stored or shown, not what the finding is about, and grouping on AsyncStorage once merged a session token in one module into a credit-card finding in another.
Findings with no inferable class are never grouped, because guessing that two unclassifiable findings are the same defect deletes a real second issue.
A fact about the whole app - FLAG_SECURE never set (PLATFORM-12), backup enabled (STORAGE-04), no network security config (NETWORK-03), a debuggable build (BUILD-01) - takes the app as its subject when it cites the manifest or no file, so the scanner's copy and an agent's group by class alone. Once that app-wide statement exists, every same-class finding cited at one file joins it too (_fold_into_app_wide): an agent reporting FLAG_SECURE missing on one activity is restating part of "FLAG_SECURE is never set", and a Ghera scan listed both. Without the app-wide statement nothing moves, since two screens missing FLAG_SECURE in an app that sets it elsewhere are separate facts.
The survivor keeps the highest severity of the group and records what corroborated it. Two findings agreeing is evidence, not noise. When the survivor is the rule engine's, it keeps its class, line and severity but takes the merged AI finding's impact and exploitation, and the AI's description is appended to its own (_carry_account): a scanner knows the construct, not its consequence, and its impact is a template. A Ghera app's exported service that takes a wake lock and opens a private activity was demoted to Informational by the review pass for "failing to demonstrate a concrete impact" while the agent finding merged into it had stated it.
Before that, a location pass merges findings on nearby lines of the same file that two different passes reported. The passes are the rule engine, a region agent and the file review; the review counts as its own pass because it re-reads the files the agents read, and an agent and the review reporting one line are two passes agreeing. Findings cluster within one class family, up to twelve lines from the cluster's first member (one routine often writes two values in a row, and a rule finding citing the second write is the same fact as an agent finding citing the first). AUTH-04 and CRYPTO-02 count as SECRET-01 there and only there: the check against a hardcoded value, or its use as a key, and the hardcoded value itself are one fact. Two safeguards keep distinct facts apart. A finding that quotes a value (eight or more characters, no spaces; dotted code names such as a component or an intent action do not count) none of the cluster quotes stays out, since two secrets ten lines apart are two secrets. A secret finding and a storage finding that quote the same literal cluster together across their classes (the hardcoded secret and the database row it is seeded into). A few class pairs name one fact from two sides and merge when they cite the very same line: AUTH-03 with PLATFORM-02 (an Intent extra that decides an authorization check), PLATFORM-01 with PLATFORM-02, and AUTH-03 with AUTH-04. The pair is matched on the classes as well as the families, since AUTH-04 counts as the SECRET-01 family and the listed AUTH-03/AUTH-04 pair never matched on families alone. A listed pair on one line merges even when a single pass filed both halves (DIVA's private-notes PIN check came out as a client-side bypass and a weak local authentication on the same comparison, both from agents); otherwise one pass repeating itself is never merged here.
A hardcoded constant reported where it is declared and where it is used is one fact across files too (_collapse_by_constant). Each SECRET-01-family finding names the constants it is about: the static or final field its cited line declares, and every Class.FIELD it reads (a chain followed by a call drops its last segment; only the last two segments are kept, so a shared package never joins two fields). Findings naming exactly one constant are grouped by it, and the one at the declaration survives; a line reading two constants stays on its own, and so does a scanner finding with a fact_key, which already says what it is about (a PBKDF2 fixed-salt finding cites a line that also reads Constant.PASS as the password, and was folded into the hardcoded-password finding). A Ghera app's Constant.PASS = "password" came out as a hardcoded password at the declaration, a weak local authentication at the comparison in another activity, and a hardcoded PBKDF2 password in a third class. The quoted-value split is not applied here, because the constant is the identity: the comparison's finding quoted the activity it unlocks and was split off by it.
Findings that name different facts never merge, however close they sit (_split_by_fact). A scanner that checks separate switches puts each in fact_key: the WebView settings scanner per setting, the TLS rules per flaw (trust manager, hostname verifier, getInsecure(), socket by address, SSL-error proceed), the in-code permission-check rules per API, and the manifest's exported-without-permission finding per component. Without the last two, the specific "enforcePermission() reads the app's own identity" was folded by class and subject into the generic "Exported service MyService has no permission protection" on four Ghera benchmarks. A finding with no key joins the keyed one nearest its line. setAllowContentAccess(true) on line 19 and setAllowUniversalAccessFromFileURLs(true) on line 21 are two settings with two fixes, yet they fell in one twelve-line cluster with an agent's copy of the first, and a Ghera benchmark about content access was left with no finding naming it. Only an explicit key separates findings, because different rules can describe one fact: the trust-all and empty-checkServerTrusted rules flag one TrustManager and share a key. In the same way getInsecure() on line 31 was folded into an always-true hostname verifier on line 38, and the benchmark about getInsecure() lost its finding.
A merged finding keeps the strongest device verdict among its parts (_carry_device_verdict): verified, then refuted, then not verified. Device verification runs before grading, so findings reach deduplication already carrying verdicts, and a merge once kept only the survivor's: a receiver finding refuted on the device was merged into the scanner's finding for the same receiver, which had none, and its disproved Medium stood.
When an agent finding joins a scanner finding's fact_key group, the scanner finding survives, not the longest description: the group exists because of the fact it names, and _carry_account still gives it the agent's description, impact and the group's highest severity. An agent finding surviving instead took the scanner's fact down with it when its own wording was refuted: a receiver's "no permission protection" finding vanished inside an agent finding refuted for a title cut off mid-name.
The class-and-subject grouping uses the same value test: a group whose members quote different values is split before merging, because the subject is often just the file, and two different secrets on one screen once collapsed into one.
First of all, correct_confusable_class re-files classes models commonly confuse. A BUILD-04 titled FLAG_SECURE, screenshot or screen capture becomes PLATFORM-12, and a BUILD-02 titled cleartext becomes NETWORK-02, the classes the scanners file those facts under; agents on Ghera apps used the other two, so each app listed them twice. A NETWORK-01 whose title is about trusting user-installed CAs (and names no trust-all construct) becomes NETWORK-05, so it groups with the scanner's copy instead of being read as a TLS bypass. A CRYPTO-02 (hardcoded key) whose cited code compares input with a literal (strncmp, equals, ==) and calls no crypto API becomes AUTH-04: DIVA's native strncmp("olsdfgad;lh", …) is a check against a hardcoded secret, not a key.
Immediately after dedupe, validate_findings backfills two fields once, so gates, the chain builder and the report all see the same values: a missing vuln_class from infer_vuln_class, and a missing cvss_score from an existing vector (never overwriting a score the agent path already computed).
validation/gates.py runs first. Every check either matches a rule table or reads a field; nothing here interprets prose. apply_gates runs them in this order:
| # | Gate | Effect |
|---|---|---|
| 1 | classify_weak |
Weak-class table → CHAIN_REQUIRED (chain-eligible) or INFORMATIONAL. A cleartext finding whose cited code holds a real http:// endpoint is exempt (names_cleartext_request) |
| 2 | check_decompiler_noise |
Cited evidence is a JADX diagnostic (/* JADX ERROR:, a stack frame) → FALSE_POSITIVE
|
| 3 | check_claim_evidence |
Title names a construct from the claim table that its own cited code does not contain → FALSE_POSITIVE
|
| 4 | check_api_claim |
Title names API methods, all of them absent from the cited code → FALSE_POSITIVE. A source-file name (main.dart, Foo.java) or a data file the code writes (uinfo.tmp, notes.db) is a location, not an API: a cross-file finding names where its flow starts while citing where the damage is done, and two real deep-link findings were refuted for naming main.dart. A native library's name is still checked, since a native finding is about that one library |
| 5 | check_source_resolution |
source_unresolved: the cited basename collides and nothing disambiguates it → DOWNGRADE
|
| 6 | check_confidence |
LOW always downgrades; MEDIUM downgrades only when nothing backs it. Skipped for an Informational finding, which has nothing to lower |
| 7 | check_evidence |
Neither a file nor a code excerpt cited → DOWNGRADE. Skipped for an Informational finding: an SDK inventory note was told its claim "cannot be checked" |
| 8 | check_evidence_depth |
Caps by how much the region behind the finding actually read |
| 9 | check_citation_target |
Cited line is a package/import statement or a bare type declaration → DOWNGRADE, cap Low, flag needs_recitation. An annotation line whose name the title states (@JavascriptInterface on a finding about JavaScript interfaces) is the construct itself and passes |
| 10 | check_sql_provenance |
Concatenated operand resolves to a constant or a catalogue name → cap Informational; the app's own text-field input written into its own database (ui-write, recorded for rule and agent findings alike) → cap Low. Only injection findings (CODE-01, or an unclassified finding with "inject" in its title) are capped: a credential stored by the same INSERT is a storage finding the provenance says nothing about |
| 11 | check_webview_mitigations |
Hardening calls near the cited line lower the ceiling a rung each |
| 12 | check_device_refutation |
The device verification refuted the finding: it showed the claimed harm does not happen → INFORMATIONAL, with the device evidence as the reason. Verification runs before grading, so the verdict is there to read |
| 13 | check_protected_broadcast |
A receiver finding whose claim rests on sending a protected system broadcast (DEVICE_STORAGE_LOW, BOOT_COMPLETED and the like) that the cited code checks for with getAction() → INFORMATIONAL: only the system can send one |
| 14 | check_clipboard_literal |
A clipboard finding whose every ClipData.newPlainText copies a string literal → INFORMATIONAL: the value is already in the APK, not something the user entered |
| 15 | check_explicit_pending_intent |
A PLATFORM-08 finding whose PendingIntent's base Intent names its component (setComponent, setClass, new Intent(ctx, X.class)) → cap Low: the holder can fill in empty fields but not redirect it |
| 16 | check_vendor_code |
Finding sits in a bundled third-party SDK → cap Medium |
| 17 | check_public_identifier |
Firebase app id, native OAuth client id and similar → cap Informational, backfill SECRET-03 (or BACKEND-01 for a Firebase database URL) |
| 18 | check_class_ceiling |
Severity above the class's CVSS ceiling (max_cvss in the catalogue, the top of the class's range in the vulnerability_classes skill, kept equal by a test) → cap at the ceiling's band. Only a stated class is used. A token in app storage graded High, or a cleartext URL graded Critical, is an overstatement by definition |
| 19 | check_cleartext_host |
A NETWORK-02 finding whose cited http:// hosts are all private or loopback addresses (10.x, 192.168.x, 172.16-31.x, 127.x, localhost - the emulator's 10.0.2.2 among them) → cap Low: a development setup, not traffic that crosses the internet |
| 20 | check_provider_key_format |
A SECRET-01 finding naming a provider's key type with no value of that type's shape in its code → cap Medium (see below) |
| 21 | check_platform_context |
Adds warnings, never a downgrade |
Gates 1–7 and 12–14 set the verdict; 8–11 and 15–20 are severity caps that leave the verdict alone; 21 only adds warnings. mechanically_refuted marks a FALSE_POSITIVE reached with no model call.
validation/taxonomy.py is the single source of truth for vulnerability classes: code, label, MASVS group, whether it is reportable standalone, and what a finding of that class must prove. The model's schema description and the vulnerability_classes skill both derive from it.
Prefixes are OWASP MASVS control groups: PLATFORM, STORAGE, NETWORK, CRYPTO, SECRET, CODE, SUPPLY, AUTH, BUILD, BACKEND — the last used by check_public_identifier (gate 17 above) for a Firebase database URL.
Six splits are load-bearing:
-
NETWORK-01(TLS validation disabled by a trust-allTrustManager, a standalone High) is separate fromNETWORK-03(no pinning, defence in depth) and fromNETWORK-05(the user CA store trusted, bynetwork_security_configor by the targetSdk < 24 default). Filed asNETWORK-01, a targetSdk default once produced a standalone Medium and an auto-confirmed Critical chain claiming an "active TLS bypass" in an app with no network code. - The
BUILDgroup exists so build configuration is never tagged as a vulnerability class. Folding those notes intoPLATFORMonce letminSdkVersion 14be proposed as the WebView half of a deep-link chain. -
CODE-05(memory corruption in native code: an unboundedstrcpy/sprintf/memcpyinto a fixed buffer, with the Java or Dart caller whose input reaches it) is separate fromCODE-02(command execution), which native overflows used to be filed under. -
PLATFORM-12(screen contents not protected from capture: noFLAG_SECURE) is separate fromBUILD-04(a client-side hardening control, present or missing). Filed underBUILD-04, the missing-FLAG_SECUREnote was given the anti-tamper reason "an attacker who has rooted their own phone can always defeat them", which says nothing about screenshots. -
AUTH-03(client-side authorization decision: a premium, VIP, admin or unlock state read from a value the user controls on their own device) andAUTH-04(weak local authentication: a short PIN with no attempt limit, a hardcoded or default secret, a comparison against a constant) are both standalone. They are scored from the attacker's real position - usually someone holding the device - andAUTH-03is a finding only when the unlocked feature is delivered by the app itself, not when a server still refuses the request.
validation/weak_classes.py holds fourteen rules, each describing something true about the app that is not a vulnerability standing alone:
| Rule | Class | Chain-eligible |
|---|---|---|
| WEAK-01 | No certificate pinning | Yes |
| WEAK-02 | Backup-extractable app data | Yes |
| WEAK-03 | Debuggable release build | No |
| WEAK-04 | Client-side protection, present or absent (root, emulator, debugger, integrity, pinning checks) | No |
| WEAK-05 | Cleartext permitted by configuration | Yes |
| WEAK-06 | Missing binary hardening flags | No |
| WEAK-07 | Certificate shipped inside the app | No |
| WEAK-08 | Third-party data collection | No |
| WEAK-09 | Clipboard access | Yes |
| WEAK-10 | Code not obfuscated | No |
| WEAK-11 | Legacy platform behaviour from SDK levels | Yes |
| WEAK-12 | Permissions requested | Yes |
| WEAK-13 | User-installed CA certificates trusted (NETWORK-05) |
Yes |
| WEAK-14 | Screen contents not protected from capture (PLATFORM-12) |
No |
Chain-eligible rules become CHAIN_REQUIRED; the rest become INFORMATIONAL. WEAK-04's reason covers both directions, because the scanner reports pinning or root detection that is present as well as missing: present, it raises the cost of analysis without stopping it; absent, it exposes nothing that was not the device owner's. A confirmed chain is never matched to a weak rule: a backup-and-credentials chain's description names the backup finding, and the backup rule's wording once sent the confirmed chain to Informational. Backup enabled alone is a note; backup enabled plus a session token in SharedPreferences is account takeover. User-CA trust is handled like cleartext permitted by configuration: on its own it is a note, and with a credential on that channel it is CHAIN-09, whose entry classes include NETWORK-05.
A cleartext finding is exempt from WEAK-05 when the code it cites holds an http:// endpoint on a real host (gates.names_cleartext_request): that endpoint is the named request the rule asks for. Only the attached code counts, not the description, and XML namespace, schema and loopback hosts are not endpoints.
Matching uses the catalogue code when the finding carries one of ours, and falls back to title wording otherwise. The description is deliberately not searched. Descriptions mention other classes in passing ("unlike the backup setting, this one is exploitable") and matching those would demote real findings.
A title that ends in an ellipsis is read without the word the cut landed in (_complete_words). A model that leaves the title out gets its description's first sentence cut at 77 characters, and "... listens for android.i..." once refuted a true finding for naming android.i.
validation/claim_terms.py backs gates 3 and 4. A title is a claim about a specific API or algorithm; whatever it names must physically appear in the cited source. When it does not, the claim is refutable with no model call.
Each ClaimTerm is two-sided:
| Field | Meaning |
|---|---|
triggers |
What a title must say for the finding to be gated at all. The opt-in |
aliases |
What the code must contain for the claim to stand. Deliberately wider |
Twenty-one terms ship: aes, des, rsa, md5, sha1, ecb, rawquery, execsql, jsbridge, jsenabled, fileaccess, trustmanager, hostnameverifier, sslerror, exec, dexclassloader, pendingintent, sharedprefs, biometric, webviewload, logging.
A concept implemented differently per framework lists every framework's API among its aliases. jsbridge is supported by addJavascriptInterface/@JavascriptInterface (Java, including JADX's fully qualified @android.webkit.JavascriptInterface, which the short form does not match and which once refuted a Ghera finding citing the annotated method), a WebView onMessage/postMessage handler or a native module's @ReactMethod, ReactContextBaseJavaModule, NativeModules or TurboModuleRegistry (React Native), and JavascriptChannel/addJavaScriptHandler (Flutter). With only the Java form in the table, correct React Native findings citing an onMessage handler and a @ReactMethod were both refuted on real scans. The same holds for trustmanager (Dart's badCertificateCallback, SecurityContext, _HttpClient), hostnameverifier (SSLSession, which is all a Kotlin verifier lambda carries) and logging (console.log/warn/error/info, Dart's print( and debugPrint().
For a recovered cross-platform module (one Blutter library under asm/, a recovered Dart source file, or one Metro module under app_modules/), enrichment also records code_context.module_terms: the claim-table aliases, and the APIs the title names, that occur anywhere in that module. The evidence blob includes them alongside real context lines, never instead of them. In these files the supporting API often sits in another function of the same module, such as a WebView channel registered in initState while the finding cites its handler, or CryptoJS.AES called a few lines below the key; real findings of both kinds were refuted on four lines of context. Java/Kotlin files are unaffected.
For a Java/Kotlin citation, and for a cited res/values entry, enrichment records code_context.hop_terms: the claim vocabulary of the code one step from the citation (analyzers/evidence_hop.py). That is the method the cited lines sit in, the bodies of the app methods they call (unqualified, or qualified by the class's full name as JADX writes static calls), the code using a static or final field or a variable they declare (by name in the same file, as Class.FIELD elsewhere), and, for a resource value, the code reading R.<type>.<name>. Only the vocabulary is kept. Round 1 of the Ghera benchmark lost three crypto benchmarks to this gate with the right finding in hand: "Hardcoded AES encryption key and IV" cited at the strings.xml entries and at the call Util.Encrypt.encryptGrade(R.string.secret, R.string.IV, …) while Cipher and IvParameterSpec sat in the helper; a key cited at static final byte[] SECRET_KEY = … twenty lines above its SecretKeySpec; and a key stored with keyStore.store(fos, null) twelve lines below the KeyGenerator.getInstance("AES") in the same method. The gate still refutes an AES claim at a call to a helper with no crypto in it.
Single-token triggers match on a word boundary, so aes does not fire inside "phrases" and des does not fire inside "describes". Multi-word and punctuated triggers (runtime.exec, js bridge) match as substrings.
Abstract titles ("App requests 5 dangerous permissions", "No network security config declared") name no construct, so they never reach the gate.
The gate skips, in order: no salient term in the title; the finding is a chain (a chain's evidence lives on its components); the file could not be resolved; there is no code evidence at all (absence of evidence is check_evidence's job, not a refutation).
check_api_claim covers API names the catalogue does not know, taken from the title by shape, and refutes only when every named API is missing from the cited code. A dotted Owner.member is met when the code calls or defines member(: the owner is often a superclass the cited override never spells out, a variable, or left implicit, and the scanner's own "WebViewClient.shouldOverrideUrlLoading() checks nothing" was refuted at the override it cited.
check_provider_key_format holds a SECRET-01 finding at Medium when its title or description names a provider's key type - AWS access key, Google API key, Stripe secret key, Slack token, GitHub token - and nothing in its code has that provider's documented shape (AKIA/ASIA + 16, AIza + 35, sk_live_/sk_test_ + 24, xox…-, ghp_ + 36). A benchmark scan called AKIA-MOCK-DEV-9982 an AWS key and graded it Critical. The string is still reported; what it would unlock is what is unproven.
check_evidence_depth grades a finding by how much the region behind it actually investigated. Scanner findings carry no agent_origin and are untouched.
| Condition | Effect |
|---|---|
agent_origin == "forced_report", fewer than 3 files read and fewer than 3 searches |
INFORMATIONAL. Written up after the region stopped early, no evidence base |
cited_file_read is False |
Cap Medium. The AI never opened the file it cites. The manifest and the profile's overview file count as read: every opening context and review request shows them, and the agent is told not to open the manifest, so an exported-provider finding citing it used to lose its High |
| Fewer than 5 files read | Cap High. Too shallow to support a Critical (said only for a finding that arrived as Critical) |
The fields come from the fan-out: region_key, region_files_read, region_searches, agent_origin, cited_file_read. Findings from the file review carry them too, with agent_origin: "file_review" and region_files_read set to the files the request showed, so a single-file review cannot produce a Critical on its own.
Some Android claims depend on declared SDK levels: implicit export below targetSdk 31, PendingIntent mutability at 31, cleartext defaults at 28, user CA trust at 24. These produce warnings, not downgrades. Telling the reader what to check beats a downgrade based on a guess about a manifest the gate did not read.
validation/validator.py then reviews every finding, including the ones the deterministic scanners produced, in two separate passes (review_findings), then gives sentence-shaped titles a heading's shape (polish_titles).
Every answer is read through ai/schema.coerce_to_vuln_list, which unwraps a markdown code fence and treats an object keyed by the request's ids ({"0": {...}, "1": {...}}) as the list it is. Until that was added, every review, title and chain answer gemma4:31b sent came back fenced and was silently discarded: published scans carried no review verdicts and no model-confirmed chains, and nothing in the log said so. Reading those answers is what exposed the calibration problems the rest of this section describes.
A pattern matching in a file is evidence that a pattern matched. The WebView with setJavaScriptEnabled(true) may only load bundled local HTML; the concatenated SQL may only receive constants; the long base64 string may be a public certificate. Answering needs the code around the match.
Every finding whose source is static-analyzer or semgrep goes through a pass sent real numbered source around the cited line, taken from the enriched code_context with the matched line marked. One question: does this code actually do what the finding claims?
The prompt names the recurring false-positive shapes: a WebView that only loads bundled content, SQL from constants, a "secret" that is a public certificate or client identifier, a path behind a BuildConfig.DEBUG guard, a match inside bundled library code, a match on a comment or a similarly-named API, a call nothing reaches.
| Reviewer says | Effect |
|---|---|
CONFIRMED |
Kept, marked rule_verified, reason recorded. May lower severity, never raise it |
UNVERIFIED |
Downgraded one rung. The excerpt was too small to decide, so it stays as a lead. Ignored for an Informational note, which has nothing to lower; a missing-FLAG_SECURE note was told "no source code was provided" |
FALSE_POSITIVE |
Demoted to Informational, labelled "reviewed against the source and not confirmed" |
Confirmation does not rescue a weak class: confirming allowBackup really is true does not make it a vulnerability.
Batches of ten, not twenty-five, because each carries real source.
A finding in Blutter's asm/ output carries a code_format note in both passes: Blutter writes every disassembled instruction as a // line, and a reviewer once refuted a real pinning call because "the pattern matched comments, not executable code" (code_format_note).
These came from something that had already read the code, so the question is whether they are worth their severity. The pass applies eight questions (exploitability on an unmodified device, reachability from an entry point, build relevance, novelty against documented platform behaviour, concrete attacker gain, proof, standalone value, real mitigations), plus four follow-ups on demonstrability, specificity, distinctness and actionability.
Three rules keep the reviewer from erring in either direction:
- Name the weakest attacker who reaches it (remote, another app, physical, rooted). An exported component is another app, not remote; a deep link is remote only when a web page can fire it.
-
Only real mitigations count. Obfuscation, native code and string encryption recover nothing. A check the client makes and trusts (a root-detection result, a biometric callback with no key behind it, a local entitlement flag) mitigates nothing unless a server verifies it. A newer-Android default closes a path only for apps that target that level. Any app can send an exported receiver an explicit Intent, with any action or none, whatever its intent filter lists; registering for a protected system broadcast (
BOOT_COMPLETED,DEVICE_STORAGE_LOW,NEW_OUTGOING_CALLand the like) does not change that. Only a receiver that checksgetAction()for the protected action before acting is out of reach, since other apps cannot send that action itself. The first wording led with "cannot be sent by another app", and the reviewer set aside two Ghera receivers that act on any Intent because they listen for one. A mutablePendingIntentwhose base Intent names its component cannot be redirected by whoever holds it, only have its empty fields filled in, so it matters only when that component acts on them. A component guarded by a signature-level permission the app declares is reachable only by apps signed with the same key; one guarded by a permission the app never declares is not guarded at all. Java'snew File(dir, name)keepsdireven whennameis absolute (unlikePath.resolve), so a..check onnamedoes guard it. - Downgrade on a specific fact: a guard on the path, a platform default the app actually gets, a skipped precondition. General doubt is not a reason, and a finding naming a concrete path keeps its severity.
Each finding carries a proof_expected line from its class in the catalogue, so "does it prove what it claims" has a per-class answer.
Both review passes are told the app's declared SDK levels first (sdk_note: "The app declares minSdkVersion 16 and targetSdkVersion 27."), taken from detection's basic info. The mitigation rule separates two kinds of newer-Android protection: defaults gated on the target (cleartext off from 28, explicit export and immutable PendingIntents from 31) hold only for apps targeting that level, while protections the OS version gives whatever the target (scoped storage keeping other apps out of Android/data from Android 11, the task-hijacking fix in 11) hold only on devices running it, so an app whose minSdkVersion is lower is exposed on older ones. The prompt used to say "check the app's targetSdk" without ever giving it, and a Ghera app copying private files into its external files directory was rated Informational because those are "not world-readable by design on modern Android" while the app installs on far older versions.
Rule 7 (standalone value) was recalibrated once the answers were read. A credential in plain storage, a hardcoded key or a client-side gate is never CHAIN_REQUIRED, and its CVSS vector already scores the attacker it needs (local access, root as high privileges), so needing root or a backup is not by itself a reason to downgrade it again; the reviewer is told to downgrade when the vector claims a stronger attacker than the path supports, or when what is stored is not sensitive.
Whether a class needs a partner is the catalogue's decision, not the reviewer's. A CHAIN_REQUIRED verdict on a class the catalogue marks standalone is applied as DOWNGRADE (one level, or the reviewer's lower severity): a reviewer that thinks the attacker's position is weak - root or a backup needed for a credential in plain storage - is saying the severity is lower, not that the finding is a step. A benchmark scan lost a PIN stored in plain preferences to exactly that. Unclassified and non-standalone findings still collapse to Informational.
A claim the review passes already judged is not sent again: validate_findings reuses the earlier verdict for a finding with the same class, file, line, filed severity and code excerpt (hashed, so no source is kept), for the life of the dashboard process. That makes a rescan of an unchanged app grade the same and cost less. Reuse is scoped to the app by the SHA-256 of its APK (scope): two different apps can share a package path, a file name and a one-line excerpt such as a method signature, and before the scope existed a run of the Ghera benchmark applied the vulnerable apps' verdicts to more than half of their fixed versions' findings, including a receiver judged spoofable whose fixed version checks the action before acting. With no scope nothing is reused.
Rewording the prompt did not stop the model downgrading every local-storage finding to Low "because it requires root or a backup", including DIVA's plaintext credentials, whose own vectors scored them Medium for exactly that attacker. So _apply enforces it: a review's DOWNGRADE stops at review_floor, the severity of the finding's vector re-scored for the strongest local attacker (attack vector local if it was network or adjacent, privileges high), and never below Low. Plaintext credentials an attacker with root reads (AV:L/PR:H/C:H) are 4.4, Medium. The impact metrics are kept, so a vector that overstates what is exposed still lowers the floor.
- A downgrade the floor stops entirely leaves the verdict where it was and records the reviewer's reason followed by "Kept at Medium: the CVSS vector, scored for an attacker with local access and high privileges, still gives Medium." An unchanged severity is not labelled a downgrade.
- A
DOWNGRADEnever reaches Informational; that is whatINFORMATIONALis for. With the answers read, the labs app's five hardcoded secrets went to Informational underDOWNGRADEand the scan graded the app A with nothing left to fix. -
INFORMATIONAL,CHAIN_REQUIREDon a non-standalone class andFALSE_POSITIVEare not floored: they say the finding is not a vulnerability on its own, which is a different claim from "overstated".
Measured on the four benchmark apps with their recorded answers: without the floor, DIVA's severity accuracy dropped from 13/13 to 10/13, DVFA's from 10/10 to 9/10 and the labs app's from 5/5 to 4/5; with it, all four are back at full marks and keep the chains the same answers confirmed.
- A model refers to other findings by its batch ids ("the actual vulnerability is the SQL injection in ID 3").
name_referencesreplaces each in-range id withthe finding "<title>", and the prompt asks for titles instead of ids. - The title pass runs after the review, so a reason can name a title the report no longer has.
rename_references, called bypolish_titles, points it at the new title.
polish_titles sends every title that ends in an ellipsis, runs past 72 characters, or is a whole sentence of six or more words to the model in one batch, and asks for a noun phrase naming the weakness and where it is. A title the model leaves unusable, or every one when there is no provider, falls back to shorten_title: the opening clause, parentheticals dropped, cut at a word boundary with no dangling connective or pronoun ("… without checking where they" once survived). A mechanically refuted finding never reaches the model. No scanner writes a title long enough to be sent (a test reads every literal title in the extractors), since the fallback would cut it; five that were longer than 72 characters were shortened at the source. Every title then goes through sentence_case: a title in Title Case ("Plaintext Credentials in Temporary File") is lowered to the sentence case every other title uses, keeping identifiers, acronyms and a short list of proper names, so one list does not mix both styles.
- They see the mechanical verdict. Telling the reviewer a rule already fired stops it re-deriving a weaker answer.
- They may only weaken a finding, never strengthen it. A reviewer that can promote turns validation into a second, unanchored analysis pass.
- Every batch is independent. One failing request costs its own findings' review, not the pass and not the mechanical verdicts already recorded.
Without a provider, or when one errors, the mechanical gates still run and their verdicts stand.
annotate_related_findings (validation/chains.py) runs before the model-backed chain builder, is deterministic, and cannot fail a scan. Two sources of relatedness:
-
The chain table.
find_candidate_chainsruns with no model;build_chainsdiscards anything it cannot get confirmed, so without a provider the pairing was computed and thrown away. - Same file. Three findings on one WebView Activity are one component's problem and belong together in the reader's eye.
Deliberately not a chain finding, and carrying no severity: a cross-reference is the part that is safe to state unconfirmed.
validation/chains.py combines findings that form one attack path.
Most of what a mobile scan finds is a step, not a bug. A deep link that accepts a URL is a step; a WebView with a JavaScript bridge is a step. Together they are remote code execution reachable from a link in a text message.
Matching is deterministic; confirmation is not.
A rule table pairs findings by vulnerability class, which is reliable and cheap. Whether component A can actually reach component B in this app is a question about the code, so one model call answers it with both findings in front of it. An unconfirmed pair is dropped, not reported as a maybe; build_chains without a provider returns nothing.
Matching falls back to keywords when a finding has no vuln_class, since the field is optional in the schema and models skip optional fields constantly.
Two priority chains are evaluated first:
-
CHAIN-01: deep link → WebView → native bridge. The attacker's page runs in the WebView and calls every
@JavascriptInterfacemethod on the bound object, with the app's permissions and data. -
CHAIN-02: deep link → unfiltered router → authenticated WebView. Cookie and token theft, local file reads via
file://, script execution viajavascript:anddata:. Routers commonly checkhttp://andhttps://and forget the other three schemes.
Then CHAIN-03 to CHAIN-10: exported provider + SQL injection; exported component + unvalidated Intent data; allowBackup + stored credential; WebView file access + attacker-influenced URL; unprotected broadcast + token in the extras; mutable PendingIntent + implicit base Intent; weak TLS + credentials on that channel; weak crypto + locally extractable ciphertext.
A pattern can also require its entry's component kind (entry_component), named in the entry's title, snippet or cited file, because PLATFORM-01 covers every exported component and an impact can hold for one kind only. CHAIN-03 requires a provider: a provider hands its query's cursor back to the caller, an activity does not. It used to take a Ghera app's exported activity as its entry and publish "Exported ContentProvider exposes an injectable SQL query" at Critical over an app with no provider; that activity's SQL injection stands on its own at High.
The matcher is quadratic in findings, so candidates are priority-ordered and capped at 48 (MAX_CANDIDATES) before the model sees them.
A confirmed chain is a finding of its own: a different vulnerability from either component, with its own severity, CVSS vector and fix. Its severity is the band the pattern's CVSS vector scores, never below its components'; when a component outranks the pattern, the chain takes that component's vector as well as its severity, so the score a report prints always supports the label. A test keeps every pattern's declared severity equal to its vector's band: six disagreed, among them the backup-and-credential chain (CHAIN-05), labelled High beside a physical-access vector that scored 5.9. Re-scored as the attack is - the attacker holding the unlocked phone, no other user involved - it is 6.1, Medium; CHAIN-10 (weak crypto over locally extractable data) is Medium for the same physical-access reason; the auto-confirmed pinning-plus-TLS-bypass chain is High (8.1, an attacker on the same network), not Critical; and CHAIN-04, CHAIN-07 and CHAIN-08 stay High with vectors that no longer claim a scope change the impact does not cross.
Components stay in the report and gain a chained_into back-reference. A component demoted with CHAIN_REQUIRED gets the confirming chain appended to its gate reasons.
Chains of one pattern that start from the same entry finding are folded into one chain over all their targets (_merge_shared_entry). A backup-enabled app with four plaintext credential stores confirmed four backup chains; the generic deduplication then collapsed them by title into one naming a single store, while the backup finding still said it was part of three chains that no longer existed. One chain per entry names every target ("5 findings in this app combine into one exploitable path: …"), keeps the first chain's attack path, and repoints the folded chains' references on the components.
CHAIN-05 (backup + stored credential) takes STORAGE-01, SECRET-01 and STORAGE-03 as targets: a credential in plain app storage is filed STORAGE-01, and a table that left it out never proposed the backup chain over DIVA's plaintext credentials. Its impact says how the backup is taken for the app's target: adb backup over USB without root below Android 12 (API 31) or for a debuggable build, cloud and device-transfer backups for newer targets.
Chains are then graded by validate_findings themselves, since a chain is a claim like any other; a chain is never a weak class (see Weak classes).
{
"title": "Deep link reaches a WebView with a native JavaScript bridge",
"severity": "Critical",
"vuln_class": "CHAIN-01",
"source": "chain-builder",
"chain": {
"id": "chain-001",
"pattern": "CHAIN-01",
"priority": true,
"components": ["Exported activity accepts a deep link url parameter",
"Class exposes 142 @JavascriptInterface method(s) to WebView content"],
"flow": ["Victim opens myapp://open?url=https://attacker.example/x",
"WebViewActivity passes the url extra to loadUrl without host validation",
"The attacker's page calls AndroidBridge.getSessionToken()"]
}
}Informational carries weight 0. Validation demotes gate-failed findings to Informational rather than deleting them, so any penalty there would let a downgraded note keep dragging the score, and the number would measure how verbose the model was.
utils/scoring.py is now the single formula for every consumer (JSON exporter, HTML builder, web serializer). See Reports.
vuln_class, gate_result, chain, chained_into, related_findings, source and surface travel through three whitelists that each drop unlisted keys silently: utils/response_parser.normalize_vulnerability, report_generator/json_exporter._build_vulnerability_data, and web/serializers. A new finding field must be added to all three. confidence passes the first and is dropped by the exporter on purpose: only the gates read it.
In the HTML report a chain renders its attack path as an ordered list under a red callout; a gate result renders as the quietest block on the card. A clean PASS with nothing to say renders nothing. The web UI mirrors both.
Findings are sorted worst-first after grading, so a downgraded note sinks and a chain lands above its own components.
lu77U-MobileSec · Live demo · Benchmarks · Report an issue · Documents version 0.1.5
Start
Results
How a scan works
Reference
Help and contributing