fix(ida): preserve native coverage and verify returned values (#2324)

Reject native callee successes without an explicit truncation marker while preserving provider failure reasons. Verify positive procedure inventory/search and function-result parity in the real-provider lane; support independent string/xref oracles and label their absence as unverified.

Verified with Windows IDA Pro 9.3: eight normal production CLI/MCP checks passed, and six real-provider response-fault cases reproduced old false positives and validated the correction. Windows IDA Free was not used. No personal paths or license registration information are included.

Repair inconsistent complete-file Ghidra test probe sizes after the shared ELF-header validation change, deriving sizes from the fixture buffers. Reproduced the three failures before the correction; 115 related installation/doctor and ELF tests pass afterward. Runtime parsing and installation behavior are unchanged; no real-Ghidra verification is claimed.

207 focused IDA tests and static/documentation checks passed. Automated review completed on d1e0b1095 without findings. CI run 38327862093 passed all 36 jobs, including Windows, all six test shards, coverage/timing, and real Apple CLI/MCP workflows.

Follow-up to #1544.
This commit is contained in:
Ysopwnable
2026-10-13 08:44:18 +08:00
committed by GitHub
parent c462a4ebd3
commit 37b7550ecc
7 changed files with 446 additions and 21 deletions
+14 -16
View File
@@ -5,6 +5,7 @@ import { projectGhidraDoctorInspection } from "./GhidraDoctor.js";
import {
ghidraJavaEnvironment,
inspectGhidraInstallation,
type GhidraExecutableHeaderProbe,
type GhidraInstallationHost,
type GhidraJavaObservation,
} from "./GhidraInstallation.js";
@@ -23,6 +24,11 @@ const WINDOWS_PROPERTIES = `${WINDOWS_INSTALL}\\Ghidra\\application.properties`;
const WINDOWS_HEADLESS = `${WINDOWS_INSTALL}\\support\\analyzeHeadless.bat`;
const WINDOWS_DECOMPILER = `${WINDOWS_INSTALL}\\Ghidra\\Features\\Decompiler\\os\\win_x86_64\\decompile.exe`;
const headerProbe = (bytes: Buffer): GhidraExecutableHeaderProbe => ({
bytes,
size: bytes.length,
});
const JAVA: GhidraJavaObservation = {
version: "21.0.11",
major: SUPPORTED_GHIDRA_JAVA_MAJOR,
@@ -543,7 +549,7 @@ describe("Ghidra FAT native decompiler admission", () => {
platform: "darwin",
architecture: "arm64",
},
host({ executableHeader: () => ({ bytes, size: bytes.length }) }),
host({ executableHeader: () => headerProbe(bytes) }),
);
expect(result.status).toBe(status);
expect(
@@ -561,7 +567,7 @@ describe("Ghidra FAT native decompiler admission", () => {
platform: "darwin",
architecture: "arm64",
},
host({ executableHeader: () => ({ bytes, size: bytes.length }) }),
host({ executableHeader: () => headerProbe(bytes) }),
);
expect(result.status).toBe("available");
expect(
@@ -581,9 +587,7 @@ describe("Ghidra native decompiler admission", () => {
architecture: "x64" as const,
},
executableHeader: (path: string) =>
path === LINUX_DECOMPILER
? { bytes: elf(1, 1, 8), size: 52 }
: undefined,
path === LINUX_DECOMPILER ? headerProbe(elf(1, 1, 8)) : undefined,
},
{
name: "a Linux x86-64 decompiler at the macOS arm64 path",
@@ -594,9 +598,7 @@ describe("Ghidra native decompiler admission", () => {
architecture: "arm64" as const,
},
executableHeader: (path: string) =>
path === MAC_DECOMPILER
? { bytes: elf(2, 1, 62), size: 52 }
: undefined,
path === MAC_DECOMPILER ? headerProbe(elf(2, 1, 62)) : undefined,
},
{
name: "a macOS arm64 decompiler at the Linux x64 path",
@@ -608,7 +610,7 @@ describe("Ghidra native decompiler admission", () => {
},
executableHeader: (path: string) =>
path === LINUX_DECOMPILER
? { bytes: thinMach(0xcffaedfe, 0x0100000c), size: 32 }
? headerProbe(thinMach(0xcffaedfe, 0x0100000c))
: undefined,
},
])("distinguishes $name", ({ options, executableHeader }) => {
@@ -632,9 +634,7 @@ describe("Ghidra native decompiler admission", () => {
},
host({
executableHeader: (path: string) =>
path === LINUX_DECOMPILER
? { bytes: elf(2, 1, 62), size: 52 }
: undefined,
path === LINUX_DECOMPILER ? headerProbe(elf(2, 1, 62)) : undefined,
}),
);
expect(result.status).toBe("available");
@@ -678,7 +678,7 @@ describe("Ghidra native decompiler admission", () => {
},
host({
executableHeader: (path: string) =>
path === MAC_DECOMPILER ? { bytes, size: bytes.length } : undefined,
path === MAC_DECOMPILER ? headerProbe(bytes) : undefined,
}),
);
expect(result.status).toBe("available");
@@ -701,9 +701,7 @@ describe("Ghidra native decompiler admission", () => {
},
host({
executableHeader: (path: string) =>
path === MAC_DECOMPILER
? { bytes: elf(2, 1, 62), size: 52 }
: undefined,
path === MAC_DECOMPILER ? headerProbe(elf(2, 1, 62)) : undefined,
}),
);
expect(result.status).toBe("unavailable");
+36
View File
@@ -375,6 +375,42 @@ describe("native IDA query identity", () => {
);
});
describe("native IDA callee truncation", () => {
it("rejects native successes without an explicit truncation marker and preserves upstream failures", async () => {
const { client, producer } = await fixture();
const previous = producer.overrideCall;
try {
producer.overrideCall = (name, args) =>
name === "callees"
? [{ callees: [], error: null }]
: previous?.(name, args);
for (const operation of [
"procedure_callees",
"analyze_function",
] as const) {
const result = await client.execute(operation, { procedure: "main" });
expect(result.ok).toBe(false);
if (!result.ok) {
expect(result.error).toBeInstanceOf(AnalysisProtocolError);
expect(result.error.message).toContain("truncation marker");
}
}
producer.overrideCall = (name, args) =>
name === "callees"
? [{ callees: null, error: "callee database failure" }]
: previous?.(name, args);
const result = await client.execute("procedure_callees", {
procedure: "main",
});
expect(result.ok).toBe(false);
if (!result.ok)
expect(result.error.message).toContain("callee database failure");
} finally {
await client.close();
}
});
});
describe("native IDA callee lookup batches", () => {
it("batches unique callees and binds reordered replies to their source queries", async () => {
const { client, producer } = await fixture();
+15 -1
View File
@@ -63,7 +63,21 @@ const nativeErrorSchema = z
.nullish()
.transform((value) => value ?? undefined);
export const nativeCalleesSchema = z
.array(modernCalleesSchema.element.extend({ error: nativeErrorSchema }))
.array(
modernCalleesSchema.element
.extend({ error: nativeErrorSchema })
.transform((page) => {
if (
page.error === undefined &&
page.callees !== null &&
page.more === undefined
)
throw new AnalysisProtocolError(
"Native IDA callees omitted an explicit truncation marker.",
);
return page;
}),
)
.length(1);
export const nativeXrefsSchema = z
.array(modernXrefsSchema.element.extend({ error: nativeErrorSchema }))