From aada535deabfca3ad42f276295cd3b16b36ae5fe Mon Sep 17 00:00:00 2001 From: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com> Date: Mon, 12 Oct 2026 15:37:56 +0000 Subject: [PATCH] fix(experiments): verify DOS load-image target identity Reject stale verified load-image facts before deriving an entry address, retain the original source reference, and verify session cleanup with a focused recording-port regression. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .../analysis-efficiency/native-entry-views.md | 3 +++ .../analysis-efficiency/native-entry.mjs | 2 ++ .../cli/nativeEfficiencyComparison.test.ts | 22 +++++++++++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/experiments/analysis-efficiency/native-entry-views.md b/experiments/analysis-efficiency/native-entry-views.md index 61f36a58a1..05388707b8 100644 --- a/experiments/analysis-efficiency/native-entry-views.md +++ b/experiments/analysis-efficiency/native-entry-views.md @@ -151,6 +151,9 @@ fingerprints are not treated as a comparable current driver. The reviewed `entry-views` answer separates selected facet facts from run-specific references: `evidence_ids.retained_views` retains each facet's original view and parent ID, while `retained_views` holds its item, coverage, limitations and unknowns. +DOS load-image facts retain their source ID and must match the selected carrier +digest before their entry address can be used; a stale result closes the session +without querying a procedure. The comparator preserves both runs' reference maps and compares the facts. Existing `entry`/`entry-and-main` answers keep their ID arrays. Historical SDK receipts above retain their original pre-review representation; no replies or measurements were diff --git a/experiments/analysis-efficiency/native-entry.mjs b/experiments/analysis-efficiency/native-entry.mjs index f8a6db2563..3f61e5ea21 100644 --- a/experiments/analysis-efficiency/native-entry.mjs +++ b/experiments/analysis-efficiency/native-entry.mjs @@ -162,6 +162,8 @@ export const measureNativeEntry = async ({ throw new Error( "The shipped DOS load image was not independently verified", ); + if (loadImage.target_sha256 !== inputSha) + throw new Error("The DOS load image belongs to a different target"); loadImageEvidenceId = imageEvidence.evidence_id; seed = loadImage.entry.linear_address; } diff --git a/tests/boundary/cli/nativeEfficiencyComparison.test.ts b/tests/boundary/cli/nativeEfficiencyComparison.test.ts index 17d68a600d..1f9b1bf63c 100644 --- a/tests/boundary/cli/nativeEfficiencyComparison.test.ts +++ b/tests/boundary/cli/nativeEfficiencyComparison.test.ts @@ -15,15 +15,17 @@ const generate = ` import {measureNativeEntry} from './experiments/analysis-efficiency/native-entry.mjs'; const sha='0'.repeat(64); const duplicate=process.argv[1]==='duplicate'; -const dos=process.argv[1]==='dos'; +const stale=process.argv[1]==='stale-dos'; +const dos=process.argv[1]==='dos'||stale; const dossier={procedure:{address:'0x1000'},pseudocode:'return;',callers:[],callees:[]}; class ToolFailure extends Error {} const build=async digit=>{ const parent='ev_'+digit.repeat(63)+'0'; let ordinal=0; const call=async(name,args)=>{ + if(stale)process.stdout.write(name+'\\n'); if(name==='open_binary'||name==='close_binary')return {}; - if(name==='inspect_native_load_image')return {evidence_id:'ev_'+digit.repeat(63)+'6',normalized_result:{status:'verified',entry:{linear_address:'0x1000'}}}; + if(name==='inspect_native_load_image')return {evidence_id:'ev_'+digit.repeat(63)+'6',normalized_result:{status:'verified',target_sha256:stale?'f'.repeat(64):sha,entry:{linear_address:'0x1000'}}}; if(name==='resolve_containing_procedure')return {evidence_id:parent,normalized_result:{found:true}}; if(name==='analyze_function')return {evidence_id:parent,subject:{digest:{sha256:sha}},normalized_result:dossier}; const id='ev_'+digit.repeat(63)+(duplicate?1:++ordinal); @@ -52,6 +54,22 @@ it("retains the DOS load-image source for its facts and derived entry seed", asy }); }); +it("rejects a stale DOS load image before using its entry and closes the session", async () => { + await expect( + execute(process.execPath, [ + "--input-type=module", + "-e", + generate, + "stale-dos", + ]), + ).rejects.toMatchObject({ + stdout: "open_binary\ninspect_native_load_image\nclose_binary\n", + stderr: expect.stringContaining( + "The DOS load image belongs to a different target", + ), + }); +}); + it("rejects a producer that reuses a view identity across facets", async () => { await expect( execute(process.execPath, [