fix(mesh): validate the manifest's route entries, not just its steps

decode is the mesh's trust boundary, and the steps array gained a per-element
check on this branch while the routes array beside it kept only its
Array.isArray. A peer sending `{ method: 5, pattern: {} }` got past decode and
died in compilePattern as a boot TypeError — it failed closed, so nothing was
exposed, but the error blamed green-tea for what was a malformed frame from
the other side. Both fields reach compilePattern, so both are checked.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-09-12 15:40:26 -05:00
1 parent e69f604053
commit 8ef7c3ee14
2 files changed
+19

No files matched your search

+12
View File
@@ -38,6 +38,18 @@ describe('protocol codec', () => {
);
});
it('rejects a manifest whose routes array contains a malformed entry', () => {
// Not a hole that was open — `compilePattern` would have thrown downstream — but it threw a
// `TypeError` at boot instead of naming the peer's frame as the malformed thing it is.
const routes = [{ method: 5, pattern: {} }];
expect(() => decode(JSON.stringify({ type: 'manifest', v: V, steps: [], routes }))).toThrow(
/every route must have a string method and pattern/,
);
expect(() => decode(JSON.stringify({ type: 'manifest', v: V, steps: [], routes: ['GET /x'] }))).toThrow(
/every route must have a string method and pattern/,
);
});
it('throws on malformed json', () => {
expect(() => decode('{not json')).toThrow();
});