Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(domain): stop Evidence authentication after invalid JSON

morluto713163e6442c
diff --git a/src/domain/evidence.test.ts b/src/domain/evidence.test.ts
index be923e3a6..27f395a99 100644
--- a/src/domain/evidence.test.ts
+++ b/src/domain/evidence.test.ts
@@ -488,6 +488,20 @@ describe("evidence parameter depth bound", () => {
),
).toBe(true);
});
+
+ it("stops semantic authentication when normalized JSON exceeds its depth bound", () => {
+ const evidence = createEvidence(TARGET, PROVIDER, {
+ operation: "health",
+ parameters: {},
+ result: true,
+ });
+ let value: unknown = 1;
+ for (let index = 0; index < 10_000; index += 1) value = { nested: value };
+
+ expect(() =>
+ parseEvidence({ ...evidence, normalized_result: value }),
+ ).toThrow(/maximum nesting depth/u);
+ });
});
it("preserves prototype-named raw and normalized results with aligned identity", () => {
diff --git a/src/domain/jsonValue.ts b/src/domain/jsonValue.ts
index ef09c3856..5c954ba1f 100644
--- a/src/domain/jsonValue.ts
+++ b/src/domain/jsonValue.ts
@@ -118,7 +118,7 @@ const validatedJsonValue = z
.superRefine((value, context) => {
const issue = jsonValueValidationIssue(value);
if (issue !== undefined)
- context.addIssue({ code: "custom", message: issue });
+ context.addIssue({ code: "custom", message: issue, continue: false });
})
.transform((value) => value as JsonValue);
// Keep both stages nonrecursive in public and Standard Schema projections.