Skip to content

feat(flutter): identify Dart snapshot builds and inspect AOT payloads by pure APK parsing - #1582

Merged
morluto merged 25 commits into
morluto:mainfrom
3QL:feat/flutter-identification
Oct 12, 2026
Merged

morluto merged 25 commits into
morluto:mainfrom
3QL:feat/flutter-identification

Conversation

@3QL

@3QL 3QL commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

feat(flutter): identify Dart snapshot builds and inspect AOT payloads by pure APK parsing

Opens the untouched Flutter lane — no PR, issue, or roadmap entry had covered Dart/Flutter analysis before. Four commits: two features, one ownership hardening matching the bar applied across the merged JEB/ADB/Apktool PRs, and one inherited-main fix.

identify_flutter_build — build identification

Reads an APK's lib/<abi>/libapp.so and libflutter.so through the hardened ZIP reader and reports:

  • The Dart VM snapshot hash — read 20 bytes after every Dart snapshot magic (f5 f5 dc dc). The vm and isolate sections are both found and cross-checked: agreeing sections collapse to one snapshot_hash; disagreeing sections keep every value in snapshot_hash_candidates with snapshot_hash: null and partial coverage rather than silently picking one.
  • Per-ABI library digests and sizes, the engine's GNU build-id, and any labeled strings (Dart VM version: …, Android clang/LLVM toolchain lines) — verbatim; release builds strip the Dart string and absence is reported as null, not guessed.
  • A target with no libapp.so reports flutter_detected: false with complete coverage — absence is an answer.

inspect_dart_aot — AOT payload inspection

For one ABI's libapp.so (caller-selected; default arm64-v8a → x86_64 → first available):

  • Snapshot sections — the four _kDart*Snapshot* symbols located through the ELF dynamic symbol table (ELF32 and ELF64 little-endian, bounds-checked; payloads without exported symbols are refused), each with file offset and size.
  • Data-section headers validated (magic, kind, length); instructions sections carry a different layout and report null for those fields — honestly.
  • A bounded string-pool projection from the isolate data section: distinct package: source URIs (the app's dependency inventory), dart: SDK URIs, and identifier-shaped tokens — labeled a byte-pattern projection, not deserialized cluster semantics; typed recovery needs an SDK-specific parser, which the snapshot hash unlocks.

Ownership hardening (mirrors the merged PRs' bar)

  • Owned read-only snapshots: the admitted APK is copied (EXCL, chmod 0400) before digesting and parsing; every read uses the snapshot, so concurrent modification cannot mix into one observation. Failed snapshot cleanup is retained and retried on close() (aggregate error when still owned); root removal is injectable for tests.
  • Bounded-before-allocation: the AOT image buffer is allocated at exactly the declared size before reading (256 MiB ceiling), and cancellation is checked between digest and stream chunks through a captured abort reason.
  • Tests cover paths containing spaces, cleanup retention with close retry, and cancellation before any root is created.

Inherited-main fix (first commit, independently cherry-pickable)

The merged ADB family advertises five patterns with unescaped dashes in character classes ([A-Za-z0-9._-]), which unicodeSets-mode clients reject — the advertised-patterns boundary test is red on current main for read_adb_setting and start_adb_activity. Escaped the same way the JEB fix did, and restored the Italian README's analysis-table rows (JEB/ADB/Apkktool/Flutter) that the recent merges added everywhere else, keeping its link set identical to README.md.

Verification

  • Real target: Flutter Gallery 2.9.2 (112 MB, three ABIs) via npm run verify:flutter — agreeing hash 65817c30a78bb44c3dc3771876b6010a on every ABI, per-ABI build-ids, all four snapshot symbols on both ELF64 and ELF32 images, header validation, hash agreement between both tools, and the 756/201 URI string pool; a plain aapt2-built APK reports not-detected with complete coverage.
  • 30 provider/scanner/ELF/service tests (goldens from the real libraries, real zips built in-test, chunk-boundary double-count coverage) plus CLI/MCP boundary schemas (Ajv-validated examples, unknown input rejected, v-mode portability).
  • check:fast, docs:generate, docs:check, 3,632 tests across domain/services/adapters/composition, and the product catalog all pass on this branch.

Towards the Flutter gap in the #717 Android roadmap discussion. No engine, SDK, or tool installation; no new runtime dependencies; pure parsing only.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@3QL
3QL force-pushed the feat/flutter-identification branch 3 times, most recently from f73e518 to ecf57fd Compare October 10, 2026 16:25
@CassieFox23

CassieFox23 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: On three real Flutter apps, the PR's snapshot hash, ELF sections and package list match my own checks. The control app gets no false Flutter claim. I found four small gaps: build-id, compiler line, empty library, and a truncated library.

Tested at f73e51876. The head then moved to ecf57fdd3. The Flutter files there are byte-for-byte the same, and the Flutter outputs match.

Results

All runs used Node 24.18.0, CLI and MCP. Node 22.23.1 and 26.11.1 gave byte-identical CLI output.

App PR reports My check
PocketDhamma (GPL-3.0-only), 1 ABI hash 830f4f59…, 4 sections, 482 package: URIs Same hash twice in the file. readelf and strings agree. Hash maps to Flutter 3.32.x. The pubspec says 3.32.1.
Flutter McSweepy (GPL-3.0-or-later), 3 ABIs hash d91c0e6f… on all 3, ELF32 works Same hash and offsets. Maps to 3.29.x. The pinned Flutter is 3.29.3.
cone 0.2.17 (GPL-3.0-only), 2019 hash 1d7acad1…, build-id null Same hash. Maps to 1.7.x. The recipe says v1.7.8+hotfix.4. A build-id exists.
Coffee (Apache-2.0), control flutter_detected: false Other commands match main, as they should.

Version mapping is from an outside table (reFlutter's enginehash.csv), not from the PR.

What I would fix

  • Build-id. cone's libflutter.so has an 8-byte GNU build-id on both ABIs. The PR reports null, because it only accepts 20 bytes.
  • Compiler line. The PR cuts cone's clang line at 249 of 262 characters. The docs say "verbatim".
  • Empty library. A zero-byte libapp.so makes inspect-dart-aot fail with a raw ENOENT and a temp path. The code is UNKNOWN.
  • Cut library. A libapp.so cut to 4,096 bytes still reports complete with one of two sections found.

More findings and the other robustness cases are in the folds below.

Not run

  • Flutter Gallery 2.9.2, the PR's own reference app. At 112 MB it did not fit my disk.
  • Four tests read a file under /tmp/opencode/, which only the author has. They skip on my box.
  • A device or emulator. I installed and ran no APK. Also Windows and macOS.
  • Apps with 4 or more ABIs, debug (JIT) builds, and libraries over 256 MiB.
  • The cause of 10 test failures in 5 non-Flutter files on ecf57fdd3. They fail on main 6d8f95e38 too.

Edit: On the new head 5e3edff08, those 10 failures are gone. Main changed 4 of the 5 files in between. I still did not find the cause. Retest in this comment.

Thanks, 3QL, for a clear PR with a real-APK check script.

More findings, with how I checked each
  • PR text is stale. The body says four commits and an ADB pattern fix. f73e51876 had six commits and no ADB change. The pattern test passes on main 6d8f95e38.
  • Default ABI order. The docs say arm64-v8a, then x86_64, then the first one. The schema says the first one. The code ranks arm64-v8a, x86_64, x86, armeabi-v7a, then the rest. I read this in the source and did not run it.
  • coverage: partial is normal for inspect-dart-aot. All three apps have more than 2,000 distinct tokens, and the list stops at 2,000. The note is honest, but it hides real gaps.
  • Corrupt ELF header. identify-flutter-build reports the hash and complete, because it scans bytes. inspect-dart-aot refuses cleanly.
  • verify:flutter passes with empty build-ids on cone. The check only tests that the list exists.
  • Hash to version used an outside table, not the PR. The table is reFlutter's enginehash.csv. GitHub's licence API says GPL-3.0, and I did not check only versus or-later. A hash can match many versions, so I used each app's own pin to choose.
  • Tests lean on the author's disk. Four tests read /tmp/opencode/flutter-target/extracted/.... The PR's "goldens from the real libraries" cannot run for anyone else.
  • Dart version string. In two of the three apps, libflutter.so holds a line shaped like a Dart version, such as 3.8.1 (stable) …, without the Dart VM version: label. I only looked for that label, so I do not know what else carries it. The PR reports dart_version: null for these apps, and says release engines strip the string. Reporting unlabeled lines may be out of scope.
  • Speed and memory. About 1 to 2 seconds and 330 to 410 MB for every run.
Robustness cases

I made these files from PocketDhamma. All runs ended in under 2.2 seconds. None hung or crashed.

Case identify-flutter-build inspect-dart-aot
Empty file, or a text file exit 1, "File format is not recognized" same
APK cut to 100 B, 5,000,000 B, 9,915,000 B exit 1, "End of central directory not found" same
libapp.so zero bytes present, 0 bytes, partial exit 1, raw ENOENT (see above)
ELF magic changed hash found, complete exit 1, unsupported_target
First 64 bytes zeroed hash found, complete exit 1, unsupported_target
Header offsets zeroed hash found, complete exit 1, unsupported_target
Random bytes, same size no hash, partial exit 1, unsupported_target
Cut to 4,096 bytes one section, complete exit 1, unsupported_target
Cut to half two sections, complete exit 1, unsupported_target
One hash byte flipped two candidates, hash null, partial exit 0, hash null, partial
Tests, speed and memory
Check Node 22.23.1 Node 24.18.0 Node 26.11.1
7 Flutter test files, f73e51876 29 pass, 4 skip 29 pass, 4 skip 29 pass, 4 skip
Same files, ecf57fdd3 29 pass, 4 skip 29 pass, 4 skip 29 pass, 4 skip
test:fast, f73e51876 3,936 pass, 8 skip 3,936 pass, 8 skip 3,936 pass, 8 skip
test:fast, ecf57fdd3 10 fail, 3,927 pass 10 fail, 3,927 pass 10 fail, 3,927 pass
check:fast, f73e51876 not run exit 0 not run
check:fast, ecf57fdd3 not run exit 0 not run

On ecf57fdd3 the 10 failures are in these files, and the same 10 fail on main 6d8f95e38: PlaywrightBrowserScenarioProvider.test.ts, ProcessHarness.test.ts (2), electronApplicationAnalysis.test.ts, javascriptSemanticAnalysis.member_depth.test.ts and JavaScriptApplicationTemplateLiterals.test.ts (5).

The PR body says 3,632 tests. I count 3,936 in test:fast at f73e51876, probably because of a different test set. I did not check.

Median of 3 runs on Node 24.18.0, wall time and peak memory:

App identify-flutter-build inspect-dart-aot main inspect-artifact
PocketDhamma 1.49 s, 390 MB 1.13 s, 389 MB 1.63 s, 442 MB
Flutter McSweepy 2.07 s, 395 MB 1.13 s, 386 MB 1.53 s, 424 MB
cone 1.68 s, 407 MB 1.25 s, 405 MB 1.42 s, 416 MB
Coffee 1.07 s, 327 MB refused 1.67 s, 407 MB

Main has neither Flutter command. It exits 1 with COMMAND_NOT_FOUND in 0.99 s and 320 MB. The inspect-artifact output is byte-identical on main and the PR for all four apps. The inspect-android-package output differs only in evidence id, temp folder name, key order and load time.

APK list

The first three SHA-256 values match the F-Droid index from earlier today. Coffee's chain was checked in an earlier run. Each Flutter APK holds libapp.so, libflutter.so and flutter_assets. I checked that with unzip -l.

Commands
# trees: git archive <sha> | tar -x; npm ci not run (see test setup); npm run build on Node 24
env -i HOME=<fake> TMPDIR=<own> PATH=<node bin>:/usr/bin:/bin nice -n 10 /usr/bin/time -v timeout 120 \
  node scripts/rea.mjs identify-flutter-build <apk> --format json
node scripts/rea.mjs inspect-dart-aot <apk> [--abi arm64-v8a|armeabi-v7a|x86_64] --format json
node scripts/rea.mjs capabilities --format json      # main vs PR: only the 2 new tools differ
node scripts/rea.mjs inspect-artifact <apk> --format json
node scripts/rea.mjs inspect-android-package <apk> --format json
node scripts/verify-flutter.mjs --apk <apk> --plain-apk <coffee apk>   # all checks pass on all three
# MCP: stdio, initialize, tools/list (172 tools on the PR, 170 on main), tools/call for both tools
npm run test:focused -- <7 test files>      npm run test:fast      npm run check:fast
# my checks
python3 -I: find f5f5dcdc, read 32 bytes at +20, header length and kind
readelf -W --dyn-syms / -l / -n    strings -a -n 6 on the isolate-data slice
Raw output

PocketDhamma, identify-flutter-build:

flutter_detected: true
abis:
  - abi: arm64-v8a
    libapp: { bytes: 5309344, snapshot_hash_sources: 2, snapshot_hash: 830f4f59e7969c70b595182826435c19 }
    libflutter: { bytes: 11275600, build_id: 1797803bdbdcdbd9156cf2b806201ff6b46f4a0d, dart_version: null }
coverage: complete

PocketDhamma, inspect-dart-aot, as offset and size in bytes:

  • VmData: 832 and 16,240.
  • VmInstructions: 1,966,080 and 92,288.
  • IsolateData: 17,088 and 1,923,328.
  • IsolateInstructions: 2,058,368 and 3,231,024.

Header kind is 3 and the magic is valid on both data sections. readelf gave the same values.

cone, build-ids from readelf -n: a2b5d92b0c471723 on arm64-v8a and bb45fd19f169eb54 on armeabi-v7a.

The real clang line is 262 characters and ends (based on LLVM 8.0.2svn). The PR output is 249 characters and ends (based on L. The PR's regex allows 200 characters after clang version.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head / base: f73e51876 then ecf57fdd3 / main 6d8f95e38 (main moved to 603d04ee3 at the end; I did not retest it)
  • Dependencies: npm ci ran only in the check:fast clone. The other trees reuse node_modules hard-linked from an install with the same lockfile (ac44c86b…), because /tmp hit 0 MB free. Every build ran on Node 24.
  • Other: readelf, strings 2.46.1; Python 3.14.7. No emulator, no install, no execution of any APK.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@3QL
3QL force-pushed the feat/flutter-identification branch from ecf57fd to 5e3edff Compare October 10, 2026 17:30
@CassieFox23

CassieFox23 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I retested the new head 5e3edff08. Its Flutter code is the same as the head I tested before. All five findings from my first comment are still there: four gaps and the corrupt-header note.

What changed

A rebase re-committed all six commits at 17:26 UTC, on top of main 0d8997833. The "ABI pattern", "shared harnesses" and Italian README commits were already in my first test at f73e51876. The extra format commit ecf57fdd3 is gone.

The PR touches 48 files. 47 are byte-for-byte the same as at ecf57fdd3. The last, src/server/createServer.ts, differs by one line, adbDevice.close(), from main commit 1f7e279aa.

The output of identify-flutter-build, inspect-dart-aot and inspect-artifact on the 4 apps and 14 broken-library files is byte-identical to ecf57fdd3. One error message holds a temp folder name that I chose. inspect-android-package also differs, as before. The changes are evidence id, temp folder name, key order and load time.

The five findings

Finding At 5e3edff08 Status
Build-id of cone's libflutter.so build_id is null on both ABIs. readelf -n shows 8-byte ids. Still there, same as at ecf57fdd3
Clang line 249 of 262 characters, ends (based on L Still there, same as at ecf57fdd3
Zero-byte libapp.so inspect-dart-aot exits 1 with raw ENOENT, code UNKNOWN Still there, same as at ecf57fdd3
libapp.so cut to 4,096 bytes identify-flutter-build says complete with 1 of 2 hash sources Still there, same as at ecf57fdd3
Corrupt ELF header identify-flutter-build finds the hash and says complete for 3 variants Still there, same as at ecf57fdd3

The v-mode change

The commit e0dffd820 writes the ABI pattern as ^[a-z0-9_\x2d]+$. The old form compiles in u mode but throws in v mode. A v-mode client would reject the whole tool list. Now all 1,044 patterns in the 172 advertised tools compile in v mode. Bad input to both Flutter tools gets an input validation error (details in the fold below).

Tests

Check Node 22.23.1 Node 24.18.0 Node 26.11.1
7 Flutter test files 29 pass, 4 skip 29 pass, 4 skip 29 pass, 4 skip
check:fast, fresh clone not run exit 0 not run
test:fast not run 3,937 pass, 8 skip not run

The 4 skips match the four tests that read /tmp/opencode/. The 10 test:fast failures I saw at ecf57fdd3 are gone. Main changed 4 of those 5 test files between the two heads. I did not check whether that is the cause. test:fast has 1 more pass than at f73e51876, and I did not check which test.

Still not run

  • Flutter Gallery 2.9.2, the PR's own reference app. At 112 MB it did not fit my disk.
  • A device or emulator. I installed and ran no APK. Also Windows and macOS.
  • Apps with 4 or more ABIs, debug (JIT) builds, and libraries over 256 MiB.
  • check:fast and test:fast on Node 22.23.1 and 26.11.1.
  • The four tests that read /tmp/opencode/, since only the author has those files.

Edit: The four /tmp/opencode/ tests no longer read that folder. They ran in my later comment with 0 skipped. Everything else in this list is still not run.

v-mode and MCP details

I called both tools over MCP on Node 24.18.0, 8 calls in all. Valid input works. An extra key, a missing path, abi: "ARM64!" and abi: "" are each rejected. An abi that is valid but absent from the APK gives unsupported_target.

The fix was already in f73e51876, so my first test used it. The commit 7764a0be5 says it escapes the dash, but its file still had the plain dash. The real escape arrived in e0dffd820.

Notes that did not change
  • The default ABI order in the code differs from the docs. I built a test APK from cone with lib/armeabi-v7a/ first and lib/x86/ second. The x86 entry holds the arm64 libraries, so it is not a real x86 build. inspect-dart-aot picked x86. The docs say "the first available ABI", which would be armeabi-v7a.
  • inspect-dart-aot is always partial because of the 2,000 token cap.
  • Four tests read /tmp/opencode/.
  • The PR body still says four commits, 30 tests, and an ADB fix that is not in the diff.
Broken-library cases

I made these files from PocketDhamma. Each row matches ecf57fdd3. I ran them at 5e3edff08.

Case identify-flutter-build inspect-dart-aot
Empty file, text file, or APK cut to 100 B, 5,000,000 B, 9,915,000 B exit 1 exit 1
libapp.so zero bytes present, 0 bytes, partial exit 1, ENOENT, UNKNOWN
ELF magic changed, first 64 bytes zeroed, or header offsets zeroed hash found, complete exit 1, unsupported_target
Random bytes, same size no hash, partial exit 1, unsupported_target
Cut to 4,096 bytes 1 of 2 hash sources, complete exit 1, unsupported_target
Cut to half 2 hash sources, complete exit 1, unsupported_target
One hash character changed to another hex digit 2 candidates, hash null, partial exit 0, hash null, partial
One hash character changed to a non-hex byte hash found, complete, but counts 2 sources exit 0, hash found, partial
APK list
  • PocketDhamma version 1.2.2, code 1223. One ABI, arm64-v8a.
  • Flutter McSweepy 1.1.0 (4), three ABIs.
  • cone 0.2.17 (25), arm64-v8a and armeabi-v7a, built in 2019.
    • Licence: GPL-3.0-only in the F-Droid metadata. I found no LICENSE file at the repo root.
    • SHA-256: a6001f814d26245bf6d2687d35439169c4b5471f69d395c044fb0338bccf87c9
    • Download from F-Droid
  • Coffee 2.27 (47), the control. No native code.

All four SHA-256 values match the ones in my first comment. I downloaded them again today.

Commands
# trees: git archive <sha> | tar -x; npm ci; npm run build on Node 24 (fake HOME, HUSKY=0)
node scripts/rea.mjs identify-flutter-build <apk> --format json
node scripts/rea.mjs inspect-dart-aot <apk> [--abi armeabi-v7a|x86_64] --format json
node scripts/rea.mjs inspect-artifact <apk> --format json
node scripts/rea.mjs inspect-android-package <apk> --format json   # needs REA_JADX_MCP_JAR and a JDK
node scripts/verify-flutter.mjs --apk <apk> --plain-apk <coffee apk>
node scripts/rea.mjs mcp     # stdio: initialize, tools/list, one tools/call per tool
npm run test:focused -- <7 test files>     npm run test:fast     npm run check:fast

verify:flutter passes all 8 checks on the three Flutter apps. On cone it still prints "engine build-ids reported per ABI" with empty ids.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head / base: 5e3edff08 / main 0d8997833. Compared with ecf57fdd3 / main 6d8f95e38 (fix(clients): preserve portable MCP schemas in native workflows #1580).
  • Dependencies: a fresh npm ci in each tree and in the check:fast clone, with the same lockfile (ac44c86b…). Every build ran on Node 24.
  • Other: JDK 21.0.12.1 and jadx-headless-mcp 0.7.1 for inspect-android-package; readelf and strings 2.46.1; Python 3.14.7. No emulator, no install, no execution of any APK.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@morluto

morluto commented Oct 11, 2026

Copy link
Copy Markdown
Owner

@codex

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T14:38:42.719776Z ccfaec0 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b2f1ea564

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/flutter/FlutterPayloadScan.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/server/createServer.ts Resolved
Comment thread src/flutter/FlutterPayloadScan.ts Resolved
Comment thread src/contracts/toolEffects.ts Resolved
Comment thread scripts/verify-flutter.mjs Resolved
@3QL

3QL commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the exceptionally thorough verification — testing against three real F-Droid apps plus a control, cross-checking hashes with readelf/strings, and mapping them to SDK versions through reFlutter's table is exactly the review this needed.

All five findings are fixed in 6b2f1ea5, re-verified against cone (one of your test apps, current release):

Finding Fix Verification
8-byte build-id reported null Scanner reads the descriptor length from the note header instead of assuming 20 bytes; schema accepts 8–128 hex chars cone's arm64 build_id: 372cb641f8bd80dec8dd7b5b004dc27e0067e7f3 matches readelf -n exactly, on all 3 ABIs
Clang line cut at 249/262 chars Toolchain capture bound raised from 200 → 500 characters cone's full 262-char line now captured verbatim
Zero-byte libapp.so → raw ENOENT, code UNKNOWN Extraction target is created before streaming; empty entry → inspect-dart-aot refuses with clean unsupported_target, identify-flutter-build reports elf_header_valid: false + partial coverage Built a zero-entry APK and exercised both tools
4,096-byte libapp.so → complete with 1/2 sources Fewer than two snapshot sections → coverage: partial + a limitation naming the count Truncated cone's real libapp.so to 4,096 bytes and checked
Corrupt ELF header → complete elf_header_valid per ABI; missing ELF magic gets its own limitation and partial coverage —

Two of your notes beyond the five:

  • Default ABI order: docs now state the exact code preference (arm64-v8a, x86_64, x86, armeabi-v7a, then the rest alphabetically).
  • Tests reading /tmp/opencode/: every one of those now builds a self-contained synthetic ELF64 image — real dynsym with the four snapshot symbols, two snapshot sections, a string pool with package:/dart: URIs — so the whole suite runs anywhere. An 8-byte build-id note test covers the older-toolchain case, and the verify lane now requires a present hex build-id per ABI instead of accepting null.

Also re-run on your other findings' inputs: PocketDhamma's and McSweepy's hashes (830f4f59…, d91c0e6f…) still cross-check, and Gallery re-verification is on record in docs/testing.md.

The PR body's commit count was indeed stale — it described the pre-rebase state; the branch now carries 7 commits after the merge-conflict and duplication rounds.

REA Contributor added 8 commits October 11, 2026 14:16
Add a flutter-provider family with one operation, identify_flutter_build,
that reads an APK's lib/<abi>/libapp.so and libflutter.so through the
hardened ZIP reader and reports build facts as observations:

- The Dart VM snapshot hash, read 20 bytes after every snapshot magic
  (f5f5dcdc). The vm and isolate sections are cross-checked: agreeing
  sections collapse to one snapshot_hash, disagreeing sections keep every
  candidate with snapshot_hash null and partial coverage.
- Per-ABI library digests and byte sizes, plus the engine library's GNU
  build-id note and any labeled 'Dart VM version' or Android clang/LLVM
  toolchain strings, verbatim; release builds without a version string
  report null rather than a guess.
- The APK is digested before parsing so Evidence binds the observation to
  the exact input, and a target with no libapp.so reports not-detected
  with complete coverage.

The scanner is streaming with explicit pending-magic and rescan
bookkeeping, so chunk boundaries cannot double-count or drop sections, and
magic-free streams never accumulate. No engine, no external lookups: the
hash-to-SDK mapping stays with external datasets by design.

Verified against Flutter Gallery 2.9.2 (112 MB, three ABIs): every ABI
reports the same agreeing hash 65817c30a78bb44c3dc3771876b6010a from two
sections, per-ABI build-ids, and the clang toolchain line; a plain
aapt2-built APK reports not-detected with complete coverage. Scanner
goldens come from the same libraries. READMEs carry the new 'Flutter apps'
row in every supported language.
Add inspect_dart_aot to the flutter family: for one ABI's libapp.so it
locates the four _kDart*Snapshot* symbols through the ELF dynamic symbol
table (ELF32 and ELF64 little-endian, bounds-checked reads; a payload
without exported symbols is refused), reports each section's offset and
size, validates data-section headers (magic, kind, length; instructions
sections honestly report nulls for the fields their layout does not
carry), and projects a bounded string pool from the isolate data section:
distinct package: source URIs (the app's dependency inventory), dart: SDK
URIs, and identifier-shaped tokens, each with counts, bounds, and partial
coverage when truncated.

The string pool is labeled as a byte-pattern projection, not deserialized
cluster semantics: typed class and function recovery remains an
SDK-specific parser, which the snapshot hash now unlocks. The ABI is
caller-selected with a deterministic default (arm64-v8a, x86_64, then
first available).

Verified against Flutter Gallery 2.9.2: all four symbols on both ELF64
(arm64-v8a) and ELF32 (armeabi-v7a) images, header validation, hash
agreement with identify_flutter_build, and a 756 package: / 201 dart:
URI pool from the isolate data section; goldens in DartElf.test.ts come
from the same libraries.
…tion

Mirror the ownership bar the maintainers applied across the merged JEB,
ADB, and Apktool PRs:

- Copy the admitted APK into a provider-owned, read-only snapshot (EXCL
  create, chmod 0400) before digesting and parsing; every later read uses
  the snapshot, so a concurrently modified original cannot mix into one
  observation. The result reports the snapshot's byte size and digest.
- Retain failed snapshot-root cleanup in a provider set and retry it on
  close(), throwing an aggregate error when a root is still owned; root
  removal is injectable so the retention is testable.
- Allocate the AOT image buffer at exactly the declared library size
  before reading (bounded before allocation, not concat-after-stream),
  keep the 256 MiB ceiling, and check cancellation between digest and
  stream chunks through a captured abort reason.
- Accept APK paths containing spaces (covered by a fixture test) and
  escape the ABI pattern's dash for v-mode regex compatibility.

Also add tests for cleanup retention with close retry and for
cancellation before any snapshot root is created.
The Italian translation landed between the merged feature PRs; its table
now carries every merged row plus this one, keeping its documentation-link
set identical to README.md.
Use a hex-escaped hyphen in the ABI character class, matching the form
the ADB portability fix uses, so clients compiling advertised schemas in
unicodeSets mode accept the inspect_dart_aot input schema.
The duplicate-detection gate (jscpd, 2.5% threshold) tipped to 2.51% with
the flutter files added. Reuse the existing machinery instead of repeating
it:

- FlutterBuildAnalysisService delegates to executeProviderOperation, the
  shared admission/Evidence composition, instead of restating its body.
- The CLI registers both commands from one table-driven spec.
- Boundary tests use the shared serveCli and assertAdvertisedMcpContracts
  harnesses rather than hand-rolled equivalents.
- The provider test consolidates the four payload-shape cases into one
  table-driven case; the service test uses one admission table and
  distinct phrasings.

Duplicate lines fall from 2.51% to 2.48%, back under the gate.
CassieFox23 verified the PR against three real F-Droid Flutter apps and
a control app, and found five gaps. All are fixed and re-verified against
cone (info.tangential.cone), one of the tested apps:

- Build-id: the scanner now reads the descriptor length from the note
  header instead of assuming 20 bytes, so 8-byte ids from older
  toolchains parse; the schema accepts 8-128 hex characters. Verified
  against cone's readelf-reported ids on all three ABIs.
- Compiler line: the toolchain capture bound rises from 200 to 500
  characters, keeping cone's 262-character clang line verbatim.
- Zero-byte libapp.so: the extraction target is created before streaming,
  so an empty entry yields a clean unsupported_target refusal for
  inspect_dart_aot and elf_header_valid: false with partial coverage for
  identify_flutter_build, instead of a raw ENOENT with code UNKNOWN.
- Truncated library: identify_flutter_build marks fewer than two snapshot
  sections as partial coverage with a limitation naming the count, and a
  missing ELF magic gets its own limitation.
- Docs: the default ABI preference now matches the code exactly
  (arm64-v8a, x86_64, x86, armeabi-v7a, then the rest alphabetically).

Also: every test that read the author's /tmp/opencode goldens now builds
a self-contained synthetic ELF64 image with dynsym, four snapshot
symbols, two snapshot sections, and a string pool, so the suite runs
anywhere; the verify lane now requires a present hex build-id per ABI
instead of accepting null.
Eight findings, all applied:

- P1: SnapshotHashScanner keeps candidates in a Set (no quadratic
  Array.includes) with a 64-distinct-hash cap, so a hostile payload of
  magic+hash records cannot stall the scan or bloat the response.
- P1: projectStringPool stops admitting new distinct entries once each
  category reaches twice its projection bound and reports
  collectionCapped; allocation and sorting now track the response, not
  the payload.
- P2: ZIP reader rejections during entry iteration or entry streaming
  map into the typed error algebra (cancellation vs input refusal)
  instead of escaping as unhandled exceptions in both operations.
- P2: magic_valid now marks coverage only for the *Data symbols; a
  complete four-symbol image with valid data magics reports complete
  coverage (the instruction symbols intentionally lack the magic).
- P2: the MCP server closes the Flutter provider during shutdown, so a
  retained snapshot root is retried and reported, not leaked.
- P2: LabeledStringScanner commits matches only when a printable run is
  delimiter-terminated; the carry grows to 600 bytes so a 500-character
  toolchain line survives any chunk boundary untruncated.
- P2: both Flutter tool effects declare writesFilesystem: true; the
  owned APK snapshot and extracted libapp.so are temporary writes.
- P2: the verify lane asserts every ABI agrees on exactly one snapshot
  hash instead of discarding the computed set.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c29163212f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/DartElf.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterPayloadScan.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterPayloadScan.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
@3QL
3QL force-pushed the feat/flutter-identification branch from c291632 to 93db928 Compare October 11, 2026 12:23

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 93db9281bc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread scripts/verify-flutter.mjs Resolved
Comment thread src/flutter/FlutterPayloadScan.ts Resolved
Comment thread src/flutter/FlutterPayloadScan.ts Resolved
Nine findings on the first-round fixes:

- P1: identify_flutter_build enforces a cumulative extraction budget
  (768 MiB) across every library entry, not just per library, so an APK
  with many ABIs cannot stream an unbounded total.
- P1: a single NUL-free printable run stops materializing at 1024 bytes
  and marks the pool capped, so an adversarial one-run section cannot
  allocate unbounded strings.
- P1: ELF cString bounds the NUL-terminator scan to the name maximum
  plus one, so malformed symbol tables cannot scan the whole image per
  entry.
- P2: mapReaderFailure distinguishes ArtifactReaderFailure texts —
  budget/limit rejections map to resource constraints, integrity
  failures (CRC/overlap/signature) to their own input refusal — instead
  of collapsing all reader failures into one message.
- P2: the labeled-string carry is cleared when a delimiter commits a
  run, so consecutive toolchain lines are never concatenated.
- P2: string-pool counts are renamed *_count_at_least and documented as
  lower bounds, because capped collection discards values beyond twice
  the projection bound.
- P2: inspect_dart_aot marks hash disagreements, non-pair source counts,
  and candidate-cap saturation as partial coverage.
- P2: only valid lowercase-hex hash records count as snapshot sources;
  complete magic records with non-hex fields do not inflate agreement.
- P2: the per-entry size refusal in inspect_dart_aot moves after ABI
  selection, so an oversized unselected ABI no longer refuses a small
  request.
@3QL

3QL commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

All nine round-two findings are fixed in eeb56f9. The three P1s: identify now enforces a 768 MiB cumulative extraction budget across every library entry (1), a single NUL-free printable run stops materializing at 1024 bytes and marks the pool capped (2), and ELF name scans bound the NUL-terminator search to the name maximum plus one (3). The six P2s: mapReaderFailure now distinguishes budget/limit rejections (resource constraint) from CRC/overlap/signature failures (integrity refusal) instead of collapsing them (4), the labeled-string carry clears when a delimiter commits a run so consecutive lines never concatenate (5), string-pool counts are renamed *_count_at_least with documented lower-bound semantics since capped collection discards beyond twice the projection bound (6), inspect_dart_aot marks hash disagreements, non-pair source counts, and cap saturation as partial coverage (7), only valid lowercase-hex hash records count as snapshot sources (8), and the per-entry size refusal is deferred until after ABI selection so an oversized unselected ABI no longer refuses a small request (9). Full gates green on the new head: 4,126 tests, check:ci end-to-end, and the cone verify lane.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eeb56f9d30

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/server/registerFlutterTools.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread scripts/verify-flutter.mjs Resolved
Comment thread scripts/verify-flutter.mjs Resolved
Five findings:

- P2: the owned snapshot revalidates the source after the copy (size,
  mtime, inode), so an in-place replacement or swap mid-copy refuses
  the observation instead of publishing mixed bytes.
- P2: a failed ZipArtifactReader close retains the snapshot root for
  close() retry instead of silently swallowing the descriptor leak,
  in both operations.
- P2: snapshot headers are parsed within their symbol bounds and a
  symbol smaller than the 16-byte header reports magic_valid false,
  so trailing-image bytes can no longer fake a valid data section.
- P2: the verify lane counts provider.close() cleanup failures as
  lane failures instead of certifying a run with retained roots.
- P2: LabeledStringScanner reports toolchain_capped when further
  distinct matching lines are observed past the 4-line projection;
  identify marks such results partial with a naming limitation.
@3QL

3QL commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

All five round-three findings are fixed in 87ac338: the owned snapshot revalidates the source after the copy (size, mtime, inode) so mid-copy swaps refuse the observation (1), a failed ZipArtifactReader close retains the snapshot root for close() retry instead of leaking the descriptor (2), snapshot headers parse within their symbol bounds with a minimum-16-byte requirement so trailing bytes can no longer fake a valid data section (3), the verify lane counts provider cleanup failures as lane failures (4), and a toolchain_capped flag marks results that observed more distinct lines than the 4-line projection as partial with a naming limitation (5). Full gates green on the new head.

Round three (one missed finding) plus round four (five findings):

- P2: the GNU build-id note descriptor size is decoded from all four
  bytes of the little-endian field, rejecting nonzero high bytes
  instead of masking them to 16 bits.
- P1: the Flutter MCP handlers route through createContractToolHandler
  and the session's analysisAdmission, so close_binary and snapshot
  operations drain in-flight Flutter calls instead of racing them.
- P2: the owned-snapshot copy is a streamed, abort-checked write (no
  copyFile), so cancellation stops the write promptly while the
  source-identity revalidation (size, mtime, inode) still guards
  against mid-copy replacement.
- P2: identify marks any snapshot_hash_sources value other than exactly
  two as partial, matching the inspection path's pair requirement.
- P2: the verify lane refuses to run without --apk (exit 2) instead of
  printing a false-green pass, and the engine check requires every
  libapp-carrying ABI to have a present libflutter with a valid hex
  build-id rather than filtering missing engines away vacuously.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 24d61ec6d6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/contracts/toolContractTypes.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/DartElf.ts Resolved
Comment thread src/flutter/FlutterPayloadScan.ts Resolved
Comment thread src/flutter/FlutterPayloadScan.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Six findings plus the upstream duplication baseline:

- P2: the flutter-provider kind reports available in the capability
  inventory, so binary_session no longer lists always-registered
  Flutter tools as provider_missing.
- P2: printable runs that exceed the 1024-byte cap are discarded at
  their delimiter instead of emitting their truncated prefix as a
  fabricated observation.
- P2: ELF symbols must fit inside the file-backed portion of their
  PT_LOAD segment (p_filesz), so addresses in gaps or BSS are refused
  instead of accepting unrelated bytes.
- P2: the build-id carry spans the complete 80-byte maximum note
  (16-byte header + 64-byte descriptor) so chunk-boundary splits
  cannot drop the first byte.
- P2: the labeled-string carry is sized for the toolchain pattern's
  true 605-byte maximum, not the previous 600.
- P2: the AOT completeness predicate requires exactly two sources and
  one candidate unconditionally, so zero-source images with valid data
  magics report partial instead of complete.

Also: the shared ELF fixture builder and snapshot-section helper moved
to a dedicated FlutterTestFixtures module, eliminating cross-file test
duplication; jscpd now passes at 2.50% while main sits at 2.52%.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbdd7fce3b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
… coverage

CassieFox23's third corrupt-header case: an ELF with valid magic but
zeroed section/program header offsets passes the 4-byte magic check
and the byte scanner still finds hash patterns in the data sections,
so identify_flutter_build reports complete coverage for a structurally
broken file.

The elf_header_valid check now also verifies beyond the magic:
e_type must be a known value (ET_REL/ET_EXEC/ET_DYN), at least one
of e_shoff/e_phoff must be non-zero, and at least one of
e_shnum/e_phnum must be non-zero. A file with valid magic but zeroed
structure reports partial coverage with the existing ELF-magic
limitation.
@3QL
3QL force-pushed the feat/flutter-identification branch from 66b0cbb to c6e7325 Compare October 11, 2026 16:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6e7325755

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Share bounded ELF header parsing between identification and inspection. Accumulate headers across ZIP chunks and validate table entry widths and extents before claiming complete identification coverage.

Bind AOT hashes to the exported VM and isolate headers, validate stored snapshot lengths including the magic bytes, and preserve partial evidence for missing, malformed, aliased, or overlapping data headers.

Preserve native stream cancellations and APK resource constraints across both operations. Bound snapshot copies while streaming and retain useful input-failure diagnostics and lower-bound count wording.

Validation: 72 focused tests; check:fast; check including formatting; docs:check; test discovery; jscpd; real cone APK and non-Flutter control on Linux. Verified CLI/MCP parity for valid and corrupted ELF headers and AOT inspection across three ABIs. Native Windows and macOS were not run.
@3QL

3QL commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @CassieFox23 for the careful retesting and for catching the remaining corrupt-header case.

Fixed in cf18c8c: identification now accumulates the full ELF header across chunks and validates table offsets, entry widths, and extents against the actual library size. Zeroed or out-of-bounds tables report partial coverage, while preserving the observed hashes.

This also addresses the six latest Codex findings: split-header handling, table bounds, native cancellation, APK size-limit classification, VM/isolate hash-source attribution, and declared snapshot lengths.

Validation: 72 focused tests passed, along with static checks, formatting, documentation checks, and duplication checks. On Linux, I verified CLI/MCP parity using a real three-ABI Flutter APK and corrupted variants, plus a non-Flutter control. Native Windows and macOS remain unverified.

If you have time, a retest of your offset-zeroed case against this head would be appreciated. Thanks again for the detailed reproductions—they’ve been genuinely useful.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf18c8c64a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/DartElf.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Merge upstream main at 9d8e42b and address the three latest Codex findings: enforce library limits after ABI selection, reject undefined or unsupported ELF symbol definitions, and retain ZIP read limits as resource constraints.

Also address earlier review findings: preserve complete labeled strings with separate Dart/toolchain omission flags, retain readers and file handles until cleanup succeeds, and verify snapshot hashes and source counts for every inspected ABI.

Add explicit static-analysis wording exceptions for Flutter, WASM, and Harmony in the effects audit, resolving the reported CI assertion without changing their authority declarations.

Validation: 96 focused tests including the failing effects audit; check:fast; check including formatting and architecture guards; docs:check; test discovery; jscpd. Real Linux verification covers the three-ABI cone APK, a non-Flutter control, CLI/MCP schema parity, undefined ELF32 exports, and verifier rejection of a damaged secondary ABI. Native Windows and macOS were not run.
@3QL

3QL commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks again for the detailed reviews. Pushed 61394b6, including a merge from main.

The three latest findings are fixed:

  • Library-size limits apply after selecting the ABI.
  • Undefined ELF symbols cannot masquerade as snapshot exports.
  • ZIP read-budget failures remain resource_constraint errors.

I also addressed three earlier outstanding findings: complete-label parsing with separate Dart/toolchain omission flags, retained ownership after failed resource cleanup, and hash/source-count verification for every ABI.

The failing CI assertion was the effects-wording audit interpreting “no execution” as an execution claim. Explicit static-analysis exceptions now cover Flutter, WASM, and Harmony without changing their declared authority.

Local validation: 96 focused tests passed, including that exact assertion. Static, formatting, documentation, and duplication checks passed. Real Linux verification covered a three-ABI Flutter APK, CLI/MCP parity, undefined ELF32 exports, and rejection of a damaged secondary ABI. Native Windows/macOS verification remains outstanding.

These results are local; the fresh GitHub CI run will validate the pushed head.

Merge upstream main at 601814e. Keep the upstream WASM wording exception alongside the Flutter execution-free parsing exceptions and the shared Harmony exception.

Validation: all 96 focused Flutter, CLI/MCP, and effects-audit tests pass; check:fast, format:check, and git diff --check pass.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 248ce4c737

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/DartElf.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterPayloadScan.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread scripts/verify-flutter.mjs Resolved
Comment thread scripts/verify-flutter.mjs Resolved
@CassieFox23

CassieFox23 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: I retested the head cf18c8c. All five of my findings are fixed, and 17 new broken-header files all give partial. At that head, CI was red from one test, toolEffects.test.ts (details below).

The head moved to 248ce4c after my run. Your newest comment says it fixes that CI test. I have not tested the new head yet, and I can if you'd like.

3QL asked for a retest of the zeroed-offsets case. It now gives partial with elf_header_valid: false, and the hashes stay in the output.

The five findings

Finding At 8d9fd5b (my last test) At cf18c8c Status
Build-id of cone's libflutter.so a2b5d92b0c471723 and bb45fd19f169eb54 same as 8d9fd5b Still fixed
Clang line 262 of 262 characters same as 8d9fd5b Still fixed
Zero-byte libapp.so inspect-dart-aot exit 1, unsupported_target same as 8d9fd5b Still fixed
libapp.so cut to 4,096 bytes partial, note names the count partial, same note as at 8d9fd5b. elf_header_valid is now false, it was true Still fixed
Corrupt ELF header, 3 cases magic changed: partial. First 64 bytes zeroed: partial. Offsets zeroed: complete all 3 give partial, elf_header_valid: false, hash kept Fixed

New broken headers

I made 17 more broken copies of the PocketDhamma library, plus one unmodified control. The cases include table offsets past the file end and entry width 0. Others set a count to 0 or 65,535, or break the byte order, version, header size or type. Two are cuts to 64 and 40 bytes. At 8d9fd5b, 15 of the 17 said complete and the two cuts said partial with a valid header. At cf18c8c, all 17 say partial with elf_header_valid: false. The control still says complete. The full table is in the first fold.

A header split across small chunks: I could not build an APK that does this. The ZIP reader hands over 65,536-byte chunks, stored or deflated. So I re-sliced the first chunk of each library in code, as the PR's own test does. At the 9 sizes I tried, from 1 to 65 bytes, the unmodified library stays complete and valid. At 8d9fd5b, a 1-byte first chunk made the good library read as invalid. Its coverage fell to partial. cf18c8c fixes the 1-byte case. The broken files stay partial at every size.

No regressions found

  • The three Flutter apps and the control give the same hashes and sections as at 8d9fd5b. Their package: and dart: counts and flutter_detected are the same too. The JSON differs only in three added or reworded note lines.
  • CLI output is byte-identical on Node 22.23.1, 24.18.0 and 26.11.1, across 81 outputs. No UNKNOWN code appears. Exit codes are only 0 and 1.
  • The 6 PR test files pass on all three Node versions: 72 tests, 0 skipped. That matches 3QL's count.

Mergeable, and one red check

The PR diff applies to main dfe3117 (#1917) with git apply --check, exit 0. GitHub shows the PR as mergeable but blocked. When I looked, gh pr checks showed 28 passed and 3 failed.

The 3 failures come from one test, src/contracts/toolEffects.test.ts, which is not in the PR. I applied the PR to main dfe3117 and ran that file: 4 pass, 1 fails. It says identify_flutter_build and inspect_dart_aot have no declared exception for execution wording. The word "execution" is in both tool descriptions. Main alone passes all 5. The CI run at 17:25 UTC listed 4 tools. #1917 later added the Wasm and Harmony ones, so these 2 are left.

Still not run

Edit: I tested the struck items at 248ce4c. The results are in my new comment. Still not run: a device, Windows and macOS, 4 or more ABIs, JIT builds, a real app with a library over 256 MiB, and check:fast.

  • Flutter Gallery 2.9.2, the PR's own reference app.
  • A device or emulator. I installed and ran no APK. Also Windows and macOS.
  • Apps with 4 or more ABIs, debug (JIT) builds, and libraries over 256 MiB. I used a made-up 257 MiB library. A real app is still not run.
  • The APK size-limit change (the limit is 2 GiB) and native cancellation, two of the six Codex items. I did not try either by hand. Now tried on a sparse file, by CLI and by MCP.
  • test:fast and check:fast. test:fast passed. A local hook blocked check:fast, so it is not run.
  • Hand calls over MCP.
  • Speed and memory. Timed on a shared box.

Thanks, @3QL, for the quick fix and for the clear note on what changed.

Other changes I saw
  • inspect-dart-aot now refuses 5 of the new files with unsupported_target (exit 1). It read them at 8d9fd5b (exit 0): ELF type 9, version 0, big-endian, header size 32, and count 0 with an offset set.
  • Library cut to half: complete at 8d9fd5b, partial now. The section-header table sits at byte 5,308,640. The cut ends at byte 2,654,672.
  • Declared snapshot length: I set it to 0, 16 or 2^40 in four files. inspect-dart-aot now adds a note. The note names the bad header and its declared length. The coverage was partial at both heads anyway. The token cap causes that, so only the note is new. For identify-flutter-build, both heads say complete with 2 hash sources.
  • The token note now reads "2000 of at least 4000", not "first 2000 of 4000".
  • Empty, text and cut APKs still give invalid_request with the generic message. The cause now sits in details.issues, such as "End of central directory not found". At 8d9fd5b, details was empty.
All 18 new header cases, one row each

I changed one field at a time in PocketDhamma's lib/arm64-v8a/libapp.so and rebuilt the APK. The first two result columns are identify-flutter-build. The last two are the exit codes of inspect-dart-aot.

Case identify-flutter-build at 8d9fd5b identify-flutter-build at cf18c8c inspect-dart-aot at 8d9fd5b inspect-dart-aot at cf18c8c
Program-header offset 4,096 bytes past the file end complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 1 exit 1
Program-header offset 2^64-1 complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 1 exit 1
Section-header offset 4,096 bytes past the file end complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 1 exit 1
Section-header offset 8 bytes before the file end complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 1 exit 1
Section-header offset 2^63 complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 1 exit 1
Program-header entry width 0 complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 1 exit 1
Section-header entry width 0 complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 1 exit 1
Section-header entry width 8 (minimum is 64) complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 1 exit 1
Program-header count 0 complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 1 exit 1
Section-header count 65,535 complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 1 exit 1
Section-header count 0, offset still set complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 0 exit 1
Byte-order byte set to big-endian complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 0 exit 1
ELF version byte 0 complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 0 exit 1
Header-size field 32 complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 0 exit 1
ELF type 9 complete, elf_header_valid: true partial, elf_header_valid: false, hash found exit 0 exit 1
Library cut to the first 64 bytes partial, elf_header_valid: true partial, elf_header_valid: false, no hash exit 1 exit 1
Library cut to the first 40 bytes partial, elf_header_valid: true partial, elf_header_valid: false, no hash exit 1 exit 1
Control: PocketDhamma library, unmodified complete, elf_header_valid: true complete, elf_header_valid: true, hash found exit 0 exit 0

My earlier broken files give the same answers at cf18c8c as in my last comment, except these. Header offsets zeroed: now partial. Cut to 4,096 bytes: elf_header_valid now false. Cut to half: now partial, elf_header_valid: false. Empty, text and cut APKs: same invalid_request, exit 1.

Tests and checks
Check Node 22.23.1 Node 24.18.0 Node 26.11.1
6 PR test files (test:focused) exit 0, 72 pass, 0 skip exit 0, 72 pass, 0 skip exit 0, 72 pass, 0 skip
verify:flutter on 3 apps, Coffee as plain APK not run exit 0 not run
toolEffects.test.ts on main dfe3117 alone not run exit 0, 5 pass not run
toolEffects.test.ts on main dfe3117 plus the PR diff not run exit 1, 4 pass, 1 fail not run

CLI output is byte-identical on all three Node versions. That covers 81 files: 15 from the four apps and 66 from 33 test files, after I drop evidence ids, timings and my temp paths.

I ran the toolEffects file with the PR tree's node_modules linked into the main tree. The two lockfiles differ, so treat that run as close, not exact. The CI log shows the same failure.

verify:flutter on cone prints "every Flutter ABI carries an engine with a hex build-id". I used the 2019 build of cone, which has 8-byte ids.

At 8d9fd5b, no test or script read /tmp/opencode. A grep at cf18c8c exits 1, so none does now.

APK list

All four SHA-256 values match my earlier comments. I checked the saved files again today.

Commands
# trees: git archive <sha> | tar -x; npm ci; npm run build; npm run test:prepare (Node 24, fake HOME, HUSKY=0)
env -i HOME=<fake> TMPDIR=<own> PATH=/usr/bin:/bin node scripts/rea.mjs identify-flutter-build <apk> --format json
node scripts/rea.mjs inspect-dart-aot <apk> [--abi armeabi-v7a|x86_64] --format json
node scripts/rea.mjs inspect-artifact <apk> --format json
node scripts/verify-flutter.mjs --apk <apk> --plain-apk <coffee apk>
npm run test:focused -- <the 6 PR test files>
npm run test:focused -- src/contracts/toolEffects.test.ts     # in main dfe31172c, with and without the PR diff
git apply --check <diff from merge base 30787297d to cf18c8c64>     # run against main dfe31172c
readelf -n lib/<abi>/libflutter.so      strings -a lib/<abi>/libflutter.so | grep 'clang version'
# split header: wrap ZipArtifactReader.prototype.open to re-slice the first chunk, then call FlutterBuildProvider.execute
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head / base: cf18c8c (18 commits, 50 files) / 8d9fd5b, my last tested head. Merge base 3078729. Main was dfe3117 (fix(test): audit static Wasm and Harmony tool wording #1917) when I checked the diff applies.
  • Dependencies: a fresh npm ci in each tree. Every build ran on Node 24.
  • Other: readelf and strings 2.46.1. Other test agents may have shared the box; I did not check the load. No emulator, no install, no execution of any APK.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I retested the head 248ce4c. Nothing broke, and all three of your newest fixes hold when I test them one at a time. One new thing: an APK that holds two files with the same name is now read two different ways, with no warning.

Results at 248ce4c

Check Result
My five earlier findings All still fixed. Same results as at cf18c8c.
17 broken headers, plus 1 control All 17 say partial with elf_header_valid: false. The control says complete.
Header split across 1 to 65 byte chunks The good library stays complete. Broken ones stay partial.
Output against cf18c8c 81 files. The only change is a new field, dart_version_capped: false.
Three Node versions (22.23.1, 24.18.0, 26.11.1) Output is identical. Exit codes are only 0 and 1.
Library size limit after the ABI is picked Holds for inspect-dart-aot. See below.
Undefined ELF symbols Hold for inspect-dart-aot. identify-flutter-build does not read symbols.
ZIP read budget Holds. The error is now resource_constraint.
Flutter Gallery 2.9.2 Works on all 3 ABIs. The hash, build ids and compiler line match readelf and strings.
MCP by hand against the CLI 10 calls on 6 files. Same data, same error codes.
Cancelling at 1.5 seconds CLI and MCP both stop at once. Nothing is left in the temp folder.
toolEffects.test.ts 5 of 5 pass. It passes on main 72489a9 (#1915) with the PR diff applied too.
npm run test:fast 402 files, 4,949 pass, 3 skipped, exit 0. The 3 skips are not in Flutter code.
7 changed test files 96 of 96 pass on all three Node versions. That matches your count.

Your three new claims hold. One small test for each is in the first fold. For the library size claim, identify-flutter-build still refuses when any ABI is oversized. Your docs limit the pick rule to AOT inspection, so I count that as fine.

New finding: two files with one name

I built an APK with two lib/arm64-v8a/libapp.so entries. One is the real library and one is cut to 64 bytes.

Order in the ZIP identify-flutter-build inspect-dart-aot
Real first, cut second reads the cut one: partial, 64 bytes reads the real one: partial (the token cap)
Cut first, real second reads the real one: complete reads the cut one: unsupported_target

At cf18c8c all four runs failed with invalid_request: "Artifact path collision". Now neither tool says it saw two entries. inspect-artifact still refuses the file with artifact_operation_failed.

The cause is in the code. Main changed ZipArtifactReader in #1865 (bcd350c). It now keys each member by its position. So repeats pass through. identify-flutter-build stores entries by path. So the last one wins. inspect-dart-aot sorts the candidates. It takes the first. A fix could add a limitation, or refuse, when a path repeats.

CI, secondhand: 29 of 31 checks pass. All 4 test shards pass, so the toolEffects test is green. The 2 failures come from a Chrome start-up timeout on the runner, which is in a web lane. Details are in the CI fold.

Not run

  • npm run check:fast. Its lint step lists files with git. My copy was not a repo, so I ran git init. Then a local safety hook on my box blocked git add .. I stopped there.
  • A device or emulator. I installed and ran no APK. Also Windows and macOS.
  • Apps with 4 or more ABIs, and debug (JIT) builds.
  • A real app with a library over 256 MiB. The big library above is synthetic.
  • A multi-ABI app with one damaged ABI. Your note says you tried one. I did not.
  • APKs that need Zip64 beyond the one large-directory file.

Thanks, 3QL, for the fast fixes.

Your three new claims, one test each
  • Library size after the ABI pick. I made an APK with a small real arm64-v8a library and a 257 MiB library (zeros) in x86_64. At cf18c8c, inspect-dart-aot gave resource_constraint. Now it reads arm64-v8a and gives partial, the same as the unmodified file. It still refuses if I ask for --abi x86_64. It also refuses if the oversized library is the only one. identify-flutter-build still refuses when any ABI is oversized. Your docs limit the pick rule to AOT inspection, so I count that as fine.
  • Undefined ELF symbols. I set st_shndx to 0 on the four snapshot symbols. I did it in PocketDhamma's library (ELF64) and in McSweepy's armeabi-v7a library (ELF32). With all four set, inspect-dart-aot now says unsupported_target. At cf18c8c it read them. With one set, that section drops out and the hash shows 1 source. Index 0xfff1 (absolute) is still accepted. Index 0xfff2 (common) is refused.
  • ZIP read budget. An APK with a 15.7 MB central directory now gives resource_constraint. At cf18c8c it gave invalid_request. A 5 MB directory still reads fine.
CI details

Secondhand, from gh pr checks just now: 29 pass and 2 fail. All 4 test shards pass, so the toolEffects test is green. One failure is web_runtime / real-web-runtime, where Chrome did not start in 20 seconds on the runner. The other is CI required, which fails because of that lane. I did not rerun them.

Other changes I saw
  • Two different Dart VM version: strings in one libflutter.so: partial now, with dart_version_capped: true. It was complete at cf18c8c. The same string twice stays complete.
  • A Dart VM version: string over 700 characters: partial, no version shown, dart_version_capped: true. Five distinct compiler lines: partial, 4 shown, toolchain_capped: true. Both were already partial at cf18c8c.
  • inspect-dart-aot on Gallery is partial on all 3 ABIs. The cause is the token cap, "2000 of at least 4000 distinct tokens". PocketDhamma, McSweepy and cone show the same.
  • The ZIP budget error says resource: memory and its advice talks about worker memory limits. The real cause is a metadata budget of 8,388,608 bytes. The message itself is clear.
  • An APK of exactly 2 GiB (2,147,483,648 bytes, sparse) is copied, then fails as invalid_request since it is not a ZIP. One byte more gives resource_constraint before any copy.
Gallery, MCP, cancel, speed

Gallery. Hash 65817c30a78bb44c3dc3771876b6010a on all 3 ABIs, 2 sources each, complete. That is the value in your docs/testing.md. Build ids from identify-flutter-build match readelf -n on each libflutter.so (arm64-v8a e8d907ef…, armeabi-v7a 727423f9…, x86_64 74513875…). Each library has one 179-character compiler line (Android (5900059 based on r365631c) clang version 9.0.8), the same as strings. The Dart VM version string is absent, so dart_version is null. I also searched each libapp.so by hand for the snapshot magic. It has two hits per ABI, with the same 32 hash characters. verify:flutter passes on Gallery and on my other three apps.

MCP. I started this PR build's own server over stdio. The command is scripts/rea.mjs mcp, and it lists 174 tools. I made 10 calls to identify_flutter_build and inspect_dart_aot. The files were PocketDhamma, cone and Gallery. The rest were the undefined-symbol file, the 15.7 MB directory file and one broken header. The 8 successes have the same structuredContent as the CLI JSON, after I drop evidence ids. The 2 errors carry the same codes and messages (unsupported_target, resource_constraint).

Cancelling. I stopped runs on a 2 GiB sparse file, 1.5 seconds in. The CLI got SIGINT. The CLI exits 130 with cancelled and cleanup: complete for both tools. The copy had written 781 MB at 1.5 s and 1.8 GB at 2.5 s. For MCP, I sent notifications/cancelled at 1.5 seconds. The server logged both tools as ended with an error at about 1.6 seconds and sent no reply. The MCP cancellation page says the receiver SHOULD NOT reply to a cancelled request, so I take that as correct. The temp folder was empty after every run.

Speed and memory. This was a shared box. The load average counts programs that are running or waiting for a CPU, averaged over a minute. This box has 24 threads. The load was 3.84 before and 4.92 after. Three runs each, Node 24, median seconds and peak memory:

App (APK size) identify-flutter-build inspect-dart-aot
PocketDhamma (9.9 MB) 1.10 s, 380 MiB 0.98 s, 377 MiB
McSweepy (19.7 MB) 1.32 s, 405 MiB 0.93 s, 380 MiB
cone (12.5 MB) 1.25 s, 410 MiB 1.05 s, 407 MiB
Flutter Gallery (117.8 MB) 2.10 s, 442 MiB 1.44 s, 442 MiB

A refusal that does no parsing takes 0.8 seconds and 304 MiB, so most of the small-app time is Node start-up.

APK list
  • Flutter Gallery 2.9.2, three ABIs, the flutter_gallery_Android.apk asset of the official release.
    • Licence: BSD-3-Clause. I read the file at tag v2.9.2. The old flutter/gallery address now redirects here.
    • SHA-256: 659b5fc6a4319dfe4f117d00ad4e7ec004915ebcadcb96628797fb3544040e29
    • Size: 117,817,550 bytes.
  • PocketDhamma, McSweepy, cone and Coffee are the same four files as in my previous comment. The licences and SHA-256 values are the same too.
Commands
# trees: git archive <sha> | tar -x; npm ci; npm run build; npm run test:prepare (Node 24, fake HOME, HUSKY=0)
npm run test:focused -- src/contracts/toolEffects.test.ts
npm run test:fast
npm run test:focused -- <the 7 changed test files>        # Node 22, 24 and 26
env -i HOME=<fake> TMPDIR=<own> PATH=/usr/bin:/bin node scripts/rea.mjs identify-flutter-build <apk> --format json
node scripts/rea.mjs inspect-dart-aot <apk> [--abi armeabi-v7a|x86_64] --format json
node scripts/verify-flutter.mjs --apk <apk> --plain-apk <coffee apk>
# fixtures, all built with Python's zipfile from the four apps:
#   17 header edits + control; library 257 MiB of zeros in x86_64; st_shndx set to 0, 0xfff1 or 0xfff2 on the four snapshot symbols (ELF64 and ELF32)
#   120,000-entry APK (15.7 MB central directory); label strings appended to libflutter.so; two entries named libapp.so
truncate -s 2147483648 exact.apk; truncate -s 2147483649 over.apk
# cancel: start the CLI in the background, kill -INT <pid> after 1.5 s; MCP: JSON-RPC over stdio, then notifications/cancelled
readelf -n lib/<abi>/libflutter.so      strings -a lib/<abi>/libflutter.so | grep 'clang version'
git apply --check <diff from merge base 601814ed0 (#1927) to 248ce4c73>     # run against main 72489a944 (#1915)
Test setup

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@dandgabr dandgabr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consolidated review — current head 248ce4c737ca8bf6f9b34eaef1157dfbbca06e33

The following unresolved findings are already covered by open inline threads; this comment consolidates them without adding duplicate inline threads.

P2

  • Reject duplicate Flutter ZIP members. src/flutter/FlutterBuildProvider.ts selects duplicate relevant paths inconsistently: identification keeps the last entry while AOT inspection can select the first. Reject duplicate relevant paths before processing so both operations use the same bytes.
  • Bound stripped ELF symbol walks. In src/flutter/DartElf.ts, the PT_DYNAMIC fallback can walk dynsym to EOF when DT_STRTAB precedes DT_SYMTAB, interpreting later bytes as symbols. Derive a trustworthy symbol bound or reject this layout.
  • Cap relevant ZIP entries and ABIs. src/flutter/FlutterBuildProvider.ts has no count limit for relevant library entries. A bounded central directory can still contain tens of thousands of empty ABI libraries, expanding processing and response size. Apply an explicit entry/ABI budget.
  • Preserve access-denied errors. Map EACCES and EPERM from file admission/reads to access_denied, rather than invalid_request.
  • Preserve artifact-change errors. When source identity changes during snapshotting, return the tagged artifact_changed error instead of a generic Error that becomes invalid_request.
  • Validate the opened source identity. The source race check compares pathname stat values before and after copying; a same-size write with restored mtime can evade it. Validate identity through the opened descriptor using the shared project primitive.
  • Keep ELF string scans inside the table. DartElf.ts asks cString to scan one byte beyond the remaining string-table range, so a NUL immediately after the table can terminate a fabricated symbol name. Bound the scan at the table's exclusive end.
  • Report candidate truncation. FlutterPayloadScan.ts caps snapshot-hash candidates at 64 without marking the result as truncated. Expose the cap/partial status so the returned list cannot appear complete.

P3

  • Include five-character class-like tokens. FlutterBuildProvider.ts filters for at least six characters before projection, although the token rule accepts five. Align the filter with the rule so valid tokens are not omitted under complete coverage.
  • Use the caller's APK path in diagnostics. ZIP errors currently expose the temporary snapshot path, which is removed after the operation. Report the caller-selected path while retaining the snapshot path internally for reading.
  • Validate snapshot headers in the real verifier. scripts/verify-flutter.mjs checks data-symbol magic but not kind, header_length, or the declared section extent. Assert those fields for each data symbol and ABI.
  • Verify the documented toolchain strings. The real verifier checks build IDs but not the documented clang/LLVM lines or the absence of a Dart label. Add those assertions, or clarify that this workflow does not verify those outputs.

No P0 or P1 findings were confirmed. Security and binary reviewers found no additional distinct issues.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 34e764db1f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/flutter/FlutterPayloadScan.ts Resolved
Comment thread src/flutter/DartElf.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread src/flutter/FlutterBuildProvider.ts Resolved
Comment thread scripts/verify-flutter.mjs Resolved
Comment thread scripts/verify-flutter.mjs Resolved
Read GNU build IDs only from bounded ELF note ranges and retain conflicting candidates. Preserve source versus owned storage failures and honor cancellation through parsing and final cleanup.

Separate snapshot structure from string-pool coverage. Verify every Gallery ABI with digest-bound engine labels and URI counts, and document the supported snapshot-kind layout.
@morluto
morluto merged commit e4d3e13 into morluto:main Oct 12, 2026
32 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
3 tasks done

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ccfaec06a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/flutter/DartElf.ts
Comment on lines +228 to +232
const segment = segments.find(
(candidate) =>
vaddr >= candidate.vaddr &&
vaddr - candidate.vaddr <= candidate.filesz &&
size <= candidate.filesz - (vaddr - candidate.vaddr),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject conflicting PT_LOAD mappings

When a malformed ELF declares overlapping PT_LOAD ranges with different file-offset deltas for a requested symbol, this find silently picks the first mapping. Valid-looking headers at that file range can then make inspect_dart_aot return all four sections and coverage: "complete" even though the symbol address has conflicting file interpretations; detect all matching segments and fail or mark coverage partial unless they map to the same offset.

AGENTS.md reference: AGENTS.md:L46-L46

Useful? React with 👍 / 👎.

Comment thread src/flutter/ElfBuildId.ts
size > totalBytes - offset
)
return failure("ELF note range is not file-backed");
ranges.set(`${offset}:${size}`, { offset, size });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound the number of declared ELF note ranges

When malformed engine ELFs keep their PH/SHT bytes under 8 MiB but declare tens of thousands of distinct one-byte PT_NOTE/SHT_NOTE ranges, this map retains every range and the loop below performs a separate file.read for each. Because examined charges only bytes, the 32 allowed ABIs can drive millions of reads while all byte and ABI caps pass, stalling identify_flutter_build; impose a note-range representation cap or coalesce/reject pathological overlaps before insertion.

AGENTS.md reference: AGENTS.md:L46-L46

Useful? React with 👍 / 👎.

morluto added a commit that referenced this pull request Oct 13, 2026
* fix(flutter): reject ambiguous mappings and bound ELF notes

Resolve PT_LOAD interpretations once for symbols and dynamic tables, including partial overlaps. Preserve equivalent mappings and leave conflicting or invalid alternate definitions unresolved.

Bound distinct nonempty ELF note ranges before retention and reads, deduplicate shared ranges, preserve observed build-ID candidates and report partial coverage on exhaustion. Correct shared verifier workspace ownership and structured Windows path assertions.

Addresses the two post-merge review findings on PR #1582. Validation: 147 focused cases across Linux, macOS Sonoma 14.8.9 and non-administrator Windows 11 build 26300.9457; real Gallery CLI/MCP checks on all three hosts; six compiler-produced ELF32/ELF64 hash-layout cases; static, docs, discovery and duplication checks. Full string-pool projections remain explicitly bounded.

* test(flutter): parse complete facts through named result schemas

---------

Co-authored-by: me <me@medz.org>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
@morluto morluto added enhancement New feature or request area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants