Skip to content

multiscan resume skips corrupted artifacts without validating the scan contract #30

Closed

Description

@ShawnSiao

Summary

When a completed multiscan campaign is resumed, the supervisor checks only whether four required artifact paths exist and are regular files. It does not parse the JSON documents, validate their schemas, or verify the sealed artifact digests.

As a result, a corrupted artifact bundle is still counted as completed and skipped instead of being rescanned.

Affected version and environment

  • Released package: @openai/[email protected]
  • Originally reproduced at commit e94d6bef9797a192febfde89a26ec7f831bc09b2
  • Confirmed still present on current main at f22d4a36f26d16287bcdfd707b369116e02a08c3
  • Microsoft Windows NT 10.0.19045.0
  • Node.js 24.18.0

Steps to reproduce

I used a source-level test harness modeled on tests-ts/multiscan.test.ts, so the reproduction does not require an API call:

  1. Create a temporary local Git repository and commit one file.
  2. Create a one-row inventory CSV containing the repository path and full commit SHA.
  3. Provide a test createSecurity() client whose run() method increments a counter, writes the four required artifact files, and returns complete coverage.
  4. Run runMultiscan() once and confirm that the security client was called once.
  5. Replace the completed attempt's scan-manifest.json with invalid JSON while leaving all four files present:
{broken json
  1. Run runMultiscan() again with the same inventory and output directory.

Observed result:

{
  "first": {
    "completed": 1,
    "failed": 0,
    "skipped": 0
  },
  "second": {
    "completed": 1,
    "failed": 0,
    "skipped": 1
  },
  "securityRunCalls": 1,
  "corruptedArtifactPreserved": true
}

Expected behavior

The resumed campaign should validate the completed artifact bundle. If the contract or seal is invalid, the task should be treated as pending and a new attempt should be created.

Actual behavior

The task is reported as completed and skipped solely because the four paths remain regular files. The corrupted bundle is preserved as the latest successful result.

Impact

Interrupted writes, manual edits, filesystem corruption, or incomplete artifact restoration can leave a bundle that is unusable or no longer sealed. Subsequent bulk scans can still report the repository as completed without repairing or rerunning it.

Relevant code

  • Resume decision:
    const receipts = await readReceipts(ledger);
    const pending: MultiscanTask[] = [];
    let completed = 0;
    for (const task of tasks) {
    const receipt = receipts.get(task.id.toLowerCase());
    if (
    receipt?.status === "completed" &&
    receipt.outputDir ===
    join(output, "artifacts", task.id, `attempt-${receipt.attempt}`) &&
    (await hasArtifacts(receipt.outputDir))
    ) {
    completed += 1;
    } else {
    pending.push(task);
    }
  • Artifact existence check:
    async function hasArtifacts(path: string): Promise<boolean> {
    try {
    if (!(await lstat(path)).isDirectory()) return false;
    for (const artifact of REQUIRED_ARTIFACTS) {
    if (!(await lstat(join(path, artifact))).isFile()) return false;
    }
    return true;
    } catch {
    return false;
    }
  • The current test helper also treats four {} files as a completed bundle:
    async function completedScan(
    outputDir: string,
    completeness: "complete" | "partial" = "complete",
    ): Promise<ScanResult> {
    await mkdir(outputDir, { recursive: true });
    await Promise.all(
    ["scan-manifest.json", "findings.json", "coverage.json", "report.md"].map(
    (name) => writeFile(join(outputDir, name), "{}\n"),
    ),
    );
    return { coverage: { completeness } } as ScanResult;

Suggested direction

Possible approaches:

  1. Reuse the existing contract/seal validation before accepting a completed receipt.
  2. Alternatively, record artifact digests in the receipt and verify them during resume.
  3. If validation fails, preserve the old attempt for inspection and create a new attempt rather than overwriting it.
  4. Add regression cases for malformed JSON, schema-invalid JSON, and a changed sealed artifact.

Activity

  1. added
    bug
    on Aug 3, 2026
  2. added
    area:bulk-scan
    area:reports
    priority:p1
    on Aug 15, 2026
  3. added
    area:artifacts
    and removed
    area:reports
    on Oct 8, 2026
  4. removed
    area:artifacts
    on Oct 19, 2026
  5. mldangelo-oai commented on Oct 19, 2026

    @mldangelo-oai
    Collaborator

    I reproduced this using saved test results: resume still counted malformed manifest JSON and a result with a broken findings digest as completed and skipped them. The normal contract loader rejected both.

    Keeping P1. #97 and #466 propose fixes; resume needs to validate the full saved contract before reusing a result. Both corruption cases should be checked against the chosen fix before this closes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:bulk-scanbugpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions