Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
03d2eaf
feat(flutter): identify Dart snapshot builds by pure APK parsing
Oct 10, 2026
2945f50
feat(flutter): inspect Dart AOT snapshots through the ELF symbol table
Oct 10, 2026
ddf1269
fix(flutter): own snapshots, bound image reads, and preserve cancella…
Oct 10, 2026
349b212
docs(flutter): cover the Italian README with the Flutter row
Oct 10, 2026
b8cbea9
fix(flutter): make the ABI pattern portable for v-mode validators
Oct 10, 2026
e12bfbf
refactor(flutter): reuse shared harnesses and deduplicate the vertical
Oct 10, 2026
2207cc6
fix(flutter): address review findings from real-app verification
Oct 11, 2026
93db928
fix(flutter): address the Codex review findings
Oct 11, 2026
eeb56f9
fix(flutter): address the second Codex review round
Oct 11, 2026
87ac338
fix(flutter): address the third Codex review round
Oct 11, 2026
24d61ec
fix(flutter): address rounds three and four of the Codex review
Oct 11, 2026
802bb9b
fix(flutter): address the fifth Codex review round
Oct 11, 2026
9603ecb
fix(flutter): address the sixth Codex review round
Oct 11, 2026
ef79672
fix(flutter): address the seventh Codex review round
Oct 11, 2026
8d9fd5b
fix(flutter): address the eighth Codex review round
Oct 11, 2026
dbdd7fc
fix(flutter): harden streaming, sizes, and cancellation after self-re…
Oct 11, 2026
c6e7325
fix(flutter): require structurally parseable ELF headers for complete…
Oct 11, 2026
cf18c8c
fix(flutter): validate ELF and snapshot coverage
Oct 11, 2026
61394b6
fix(flutter): resolve review findings and CI effect checks
Oct 11, 2026
248ce4c
chore(flutter): resolve upstream effects-audit conflict
Oct 11, 2026
8b88190
chore: merge main into Flutter analysis branch
morluto Oct 12, 2026
34e764d
fix(flutter): unify artifact ownership and bound ELF evidence
morluto Oct 12, 2026
98707b4
chore: merge latest main into Flutter analysis branch
morluto Oct 12, 2026
9089b98
fix(flutter): preserve ELF provenance and partial coverage
morluto Oct 12, 2026
ccfaec0
chore: merge latest main after documentation updates
morluto Oct 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(flutter): address rounds three and four of the Codex review
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.
  • Loading branch information
REA Contributor
REA Contributor committed Oct 11, 2026
commit 24d61ec6d6939da396860fa254dfb8cb73959382
23 changes: 17 additions & 6 deletions scripts/verify-flutter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,22 @@ if (options.apk !== null) {
hashes.size === 1,
[...hashes].join(", "),
);

const libappAbis = identified.abis.filter((abi) => abi.libapp.present);
check(
"engine build-ids present and hex per ABI",
identified.abis
.filter((abi) => abi.libflutter.present)
.every(
"every Flutter ABI carries an engine with a hex build-id",
libappAbis.length > 0 &&
libappAbis.every(
(abi) =>
abi.libflutter.present &&
abi.libflutter.build_id !== null &&
/^[0-9a-f]{16,40}$/.test(abi.libflutter.build_id),
),
identified.abis
.map((abi) => abi.libflutter.build_id?.slice(0, 12))
libappAbis
.map(
(abi) =>
`${abi.abi}:${abi.libflutter.present ? abi.libflutter.build_id?.slice(0, 12) : "missing"}`,
)
.join(", "),
);

Expand Down Expand Up @@ -136,6 +141,12 @@ try {
);
}

if (options.apk === null) {
process.stderr.write(
"No Flutter APK was provided; pass --apk PATH to run the real verification.\n",
);
process.exit(2);
}
if (failures > 0) {
process.stdout.write(`\n${failures} check(s) failed\n`);
process.exit(1);
Expand Down
19 changes: 15 additions & 4 deletions src/flutter/FlutterBuildProvider.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { createHash } from "node:crypto";
import { createReadStream } from "node:fs";
import {
chmod,
copyFile,
constants as fsConstants,
mkdtemp,
open as openFile,
rm,
stat,
writeFile,
} from "node:fs/promises";
import { createReadStream } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";

Expand Down Expand Up @@ -225,8 +224,20 @@ export class FlutterBuildProvider {
// Pin the admitted source: capture its identity before the copy and
// revalidate after, so an in-place replacement or swap mid-copy is
// refused instead of publishing mixed bytes under the original path.
// The copy itself is streamed and abort-checked so cancellation
// stops the write promptly instead of draining the whole file.
const before = await stat(path);
await copyFile(path, snapshotPath, fsConstants.COPYFILE_EXCL);
const output = await openFile(snapshotPath, "wx");
try {
const abortSignal = signal;
for await (const chunk of createReadStream(path)) {
if (abortSignal?.aborted === true)
throw new AnalysisCancelledError(operation);
await output.write(chunk as Buffer);
}
} finally {
await output.close();
}
const after = await stat(path);
if (
before.size !== after.size ||
Expand Down Expand Up @@ -467,7 +478,7 @@ export class FlutterBuildProvider {
(entry) =>
(entry.libapp.present &&
(entry.libapp.snapshot_hash === null ||
entry.libapp.snapshot_hash_sources < 2 ||
entry.libapp.snapshot_hash_sources !== 2 ||
entry.libapp.elf_header_valid !== true)) ||
entry.libflutter.toolchain_capped ||
entry.libapp.present !== entry.libflutter.present,
Expand Down
8 changes: 6 additions & 2 deletions src/flutter/FlutterPayloadScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,12 @@ export class BuildIdScanner {
for (;;) {
const prefix = findBytes(joined, BUILD_ID_NOTE_PREFIX_FIXED, probe);
Comment thread
morluto marked this conversation as resolved.
Resolved
if (prefix === -1) break;
if (prefix + 6 <= joined.length) {
const described = joined[prefix + 4]! + joined[prefix + 5]! * 0x100;
if (prefix + 8 <= joined.length) {
const described =
joined[prefix + 4]! +
joined[prefix + 5]! * 0x100 +
joined[prefix + 6]! * 0x10000 +
joined[prefix + 7]! * 0x1000000;
if (
described >= BUILD_ID_MIN_BYTES &&
described <= BUILD_ID_MAX_BYTES &&
Expand Down
1 change: 1 addition & 0 deletions src/server/createServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ export const createServer = (
new FlutterBuildAnalysisService(flutter),
toolLogger,
recordEvidence,
analysisAdmission,
);
registerApktoolTools(
server,
Expand Down
51 changes: 20 additions & 31 deletions src/server/registerFlutterTools.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,35 @@
import type { EvidenceMcpServer } from "./EvidenceMcpServer.js";
import type { EvidenceWriter } from "../application/investigation/InvestigationRecordPort.js";
import type { ServerContext } from "@modelcontextprotocol/server";
import { FlutterBuildAnalysisService } from "../application/flutter/FlutterBuildAnalysisService.js";
import { toolContract } from "../contracts/toolContracts.js";
import type { ToolContract } from "../contracts/toolContractTypes.js";
import type { FlutterOperation } from "../domain/flutter/flutterBuildAnalysis.js";
import type { WithAdmittedAnalysis } from "./analysisAdmission.js";
import type { Logger } from "pino";
import { logToolExecution } from "./toolLogging.js";
import { createContractToolHandler } from "./contractToolHandler.js";
import { toolRegistrationOptions } from "./toolRegistrationOptions.js";

/** Bind Flutter handlers to their exact named contracts. */
/** Bind Flutter handlers to their exact named contracts through admission. */
export const registerFlutterTools = (
server: EvidenceMcpServer,
service: FlutterBuildAnalysisService,
logger: Logger,
recordEvidence?: EvidenceWriter["recordEvidence"],
withAdmittedAnalysis?: WithAdmittedAnalysis,
): void => {
const handler = (contract: ToolContract<FlutterOperation>) => {
const name = contract.name;
return async (input: unknown, context: ServerContext) => {
const result = await logToolExecution(logger, name, () =>
service.execute(name, input, { signal: context.mcpReq.signal }),
);
if (!result.ok) return server.delivery.toCallToolResult(result, contract);
const recorded = recordEvidence?.(result.value);
return server.delivery.toEvidenceToolResult(
result.value,
contract,
recorded,
);
};
};
const identifyContract = toolContract("identify_flutter_build");
server.registerTool(
identifyContract.name,
toolRegistrationOptions(identifyContract),
handler(identifyContract),
);
const aotContract = toolContract("inspect_dart_aot");
server.registerTool(
aotContract.name,
toolRegistrationOptions(aotContract),
handler(aotContract),
const handler = createContractToolHandler(
server,
service,
logger,
recordEvidence,
withAdmittedAnalysis,
);
for (const contract of [
toolContract("identify_flutter_build"),
toolContract("inspect_dart_aot"),
] as const) {
server.registerTool(
contract.name,
toolRegistrationOptions(contract),
handler(contract),
);
}
};
Loading