From 3e866567394d2571f75bdbef9ae4f799c0193279 Mon Sep 17 00:00:00 2001 From: "Sharad." Date: Sat, 12 Sep 2026 14:13:39 +0000 Subject: [PATCH] fix: reject static manifests with non-array tools Validate tools during manifest normalization so invalid values like strings fail fast instead of being iterated as characters. Fixes AgentPostmortem/MCP-audit#25 Co-authored-by: Sharad. --- src/static/manifest.ts | 6 ++++++ test/static.test.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/static/manifest.ts b/src/static/manifest.ts index f846c5f..3548f13 100644 --- a/src/static/manifest.ts +++ b/src/static/manifest.ts @@ -55,6 +55,12 @@ export function normalize(parsed: unknown, source: string): AuditTarget { const serverInfo = manifest.serverInfo ?? manifest.server ?? {}; const declaredHttp = manifest.transport === "http"; + if (manifest.tools !== undefined && !Array.isArray(manifest.tools)) { + throw new Error( + `Invalid manifest ${source}: tools must be an array`, + ); + } + return { transport: declaredHttp ? "http" : "static", source, diff --git a/test/static.test.ts b/test/static.test.ts index 18b593d..a05708a 100644 --- a/test/static.test.ts +++ b/test/static.test.ts @@ -36,6 +36,12 @@ describe("loadManifest", () => { expect(target.transport).toBe("static"); }); + it("rejects a manifest with non-array tools", () => { + expect(() => normalize({ tools: "MCP001" }, "bad.json")).toThrow( + /tools must be an array/i, + ); + }); + it("rejects a missing manifest file", async () => { await expect(loadManifest(resolve(root, "does-not-exist.json"))).rejects.toBeTruthy(); });