fix(mesh): reject a manifest step that is not a string

decode is the mesh's trust boundary, reached before the handshake
authenticates the peer. The manifest row checked that steps was an array
but not what was in it, so {"steps":[123]} decoded cleanly and 123 would
have become a graph node name in buildRemote.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-09-12 15:40:24 -05:00
1 parent 6e66b05a41
commit 414b188792
2 files changed
+9

No files matched your search

+3
View File
@@ -97,6 +97,9 @@ const SHAPE: Record<Frame['type'], ShapeCheck> = {
manifest: (frame, bad) => {
if (!isNumber(frame.v)) bad('missing protocol version');
if (!Array.isArray(frame.steps) || !Array.isArray(frame.routes)) bad('steps and routes must be arrays');
// Array.isArray above already guarantees this, but TS does not carry that narrowing through a
// `never`-typed callback parameter — the cast is safe, not a bypass.
if (!(frame.steps as unknown[]).every(isString)) bad('every step must be a string');
},
'rpc-req': (frame, bad) => {
if (!isString(frame.id)) bad('id must be a string');