From d29564347c1a421ff2bc9aac5cabf72642accc42 Mon Sep 17 00:00:00 2001 From: askalf <263217947+askalf@users.noreply.github.com> Date: Fri, 13 Nov 2026 14:25:00 -0500 Subject: [PATCH] fleet-status check: the evaluator reads own properties only The fuzzer (run 43463587459) found `__proto__(...)` passing the function check through Object.prototype and throwing a TypeError, which the fuzz contract forbids: the evaluator returns a value or throws a plain Error. toString(), a context named constructor and paths like github.event.constructor reached Object.prototype the same way and read as built-ins where Actions has no such function, context or property. Every lookup by a name from the expression now checks own properties: an unknown function is a plain Error, a missing context or property null (or an Error under strict), and under trusted a github property the caller did not supply stays UNKNOWN. The fuzzer's crash input replays clean. --- CHANGELOG.md | 6 ++++++ scripts/fleet-status/check.mjs | 16 ++++++++++------ scripts/fleet-status/check.test.mjs | 24 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ec893e..041aaad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ names the commit's date and the pull request it came from. ## November 2026 +- The fleet-status check's expression evaluator reads only its own tables. A function, context or + property named after something every JavaScript object inherits (`__proto__(x)`, `toString()`, + a context `constructor`, `github.event.constructor`) used to reach Object.prototype: the fuzzer + found `__proto__(...)` throwing a TypeError, and the others read as built-ins where Actions has + none. They are now an unknown function (a plain Error), a missing context or property (null), + or, when trusted, UNKNOWN. - `actions/tree-tested` takes `pinned-checkouts`: other repositories a job checks out at a commit its own tree names, such as a full sha read from a file of the checkout. The job log must show each one checked out at a full commit sha, into a directory of its own under the workspace, and diff --git a/scripts/fleet-status/check.mjs b/scripts/fleet-status/check.mjs index a75efb8..016124e 100644 --- a/scripts/fleet-status/check.mjs +++ b/scripts/fleet-status/check.mjs @@ -142,6 +142,10 @@ export function evalExpr(src, ctx, { strict = false, trusted = null } = {}) { failure: () => false, cancelled: () => false, }; + // Every lookup by a name from the expression reads own properties only: `__proto__(x)`, + // `toString()`, a context named `constructor` or a path like github.event.constructor would + // otherwise reach Object.prototype, where Actions has no such function, context or property. + const own = (o, key) => o !== null && o !== undefined && Object.hasOwn(Object(o), key); // Whether a github.event path is one the sender cannot choose: a trusted path, or on the way to one. const known = (path) => trusted.some((t) => t === path || t.startsWith(`${path}.`) || path.startsWith(`${t}.`)); const primary = () => { @@ -157,22 +161,22 @@ export function evalExpr(src, ctx, { strict = false, trusted = null } = {}) { const args = []; if (peek() !== ')') for (args.push(or()); peek() === ','; p++, args.push(or())); eat(')'); - if (!fns[k.v]) throw new Error(`unknown function ${k.v}`); + if (!own(fns, k.v)) throw new Error(`unknown function ${k.v}`); if (trusted && STATUS_FNS.has(k.v)) return UNKNOWN; return args.some((a) => U(a) || S(a)) ? UNKNOWN : fns[k.v](...args); } - if (strict && !(k.v in ctx) && !(trusted && UNKNOWN_CONTEXTS.has(k.v))) throw new Error(`unknown context ${k.v}`); - let v = trusted && (UNKNOWN_CONTEXTS.has(k.v) || !(k.v in ctx)) ? UNKNOWN : ctx[k.v] ?? null; + if (strict && !own(ctx, k.v) && !(trusted && UNKNOWN_CONTEXTS.has(k.v))) throw new Error(`unknown context ${k.v}`); + let v = trusted && (UNKNOWN_CONTEXTS.has(k.v) || !own(ctx, k.v)) ? UNKNOWN : own(ctx, k.v) ? ctx[k.v] ?? null : null; const path = [k.v]; for (let depth = 0; ; depth++) { let key; if (peek() === '.') { p++; key = eat('id').v; } else if (peek() === '[') { p++; key = or(); eat(']'); } else return v; if (U(v) || S(v)) { v = UNKNOWN; continue; } if (U(key)) { v = UNKNOWN; continue; } - if (strict && k.v === 'matrix' && depth === 0 && !(key in (v ?? {}))) throw new Error(`unknown matrix.${key}`); + if (strict && k.v === 'matrix' && depth === 0 && !own(v, key)) throw new Error(`unknown matrix.${key}`); path.push(String(key)); - if (trusted && k.v === 'github' && depth === 0 && !(String(key) in (v ?? {}))) { v = UNKNOWN; continue; } - v = trusted && path[0] === 'github' && path[1] === 'event' && path.length > 2 && !known(path.slice(2).join('.')) ? UNKNOWN : v?.[key] ?? null; + if (trusted && k.v === 'github' && depth === 0 && !own(v, String(key))) { v = UNKNOWN; continue; } + v = trusted && path[0] === 'github' && path[1] === 'event' && path.length > 2 && !known(path.slice(2).join('.')) ? UNKNOWN : own(v, key) ? v[key] ?? null : null; } }; const cmp = () => { let v = primary(); while (peek() === '==' || peek() === '!=') { const op = toks[p++].t; const r = primary(); const e = eq(v, r); v = U(e) ? UNKNOWN : op === '==' ? e : !e; } return v; }; diff --git a/scripts/fleet-status/check.test.mjs b/scripts/fleet-status/check.test.mjs index 6c63e14..ece1949 100644 --- a/scripts/fleet-status/check.test.mjs +++ b/scripts/fleet-status/check.test.mjs @@ -43,6 +43,30 @@ console.log('\n the evaluator'); check('reads literals, paths and functions', evalIf("contains(fromJSON('[\"a\",\"b\"]'), x.y[0]) && x.z == null && 'A' == 'a'", { x: { y: ['B'] } }) && !evalIf("x.y != 'q' && x.y == 'q'", { x: { y: 'q' } })); +{ + // The fuzzer's crash of 2026-11-13 (askalf/ci run 43463587459): `__proto__(...)` passed the + // function check through Object.prototype and threw a TypeError calling it. + const plainError = (src, ctx, opts, msg) => { + try { evalExpr(src, ctx, opts); return false; } catch (e) { return e.constructor === Error && msg.test(e.message); } + }; + check('a name on Object.prototype is no function: a plain Error, never a TypeError or a built-in', + ['__proto__', 'toString', 'constructor', 'hasOwnProperty', 'valueOf'].every((f) => + plainError(`${f}('x')`, {}, {}, /^unknown function /) + && plainError(`${f}(a.b)`, { a: { b: 1 } }, { trusted: ['x'] }, /^unknown function /))); + check('a context or a property named after Object.prototype reads as missing', + evalExpr('constructor', {}) === null && evalExpr('toString', {}) === null + && evalExpr('x.constructor', { x: {} }) === null && evalExpr("x['__proto__']", { x: {} }) === null + && evalExpr('x.toString.name', { x: { a: 1 } }) === null + && plainError('constructor', {}, { strict: true }, /^unknown context constructor$/) + && plainError('matrix.constructor', { matrix: { os: 'a' } }, { strict: true }, /^unknown matrix\.constructor$/)); + check('own properties still read, strings and arrays included', + evalExpr('x.y', { x: { y: 'v' } }) === 'v' && evalExpr('x.y[1]', { x: { y: ['a', 'b'] } }) === 'b' + && evalExpr('x.y.length', { x: { y: 'abc' } }) === 3 && evalExpr('x.n', { x: { n: null } }) === null); + const gh = { github: { event: { constructor: 'own' } } }; + check('trusted: a github property named after Object.prototype is UNKNOWN unless the caller supplied it', + evalExpr('github.constructor', { github: {} }, { trusted: ['x'] }) === UNKNOWN + && evalExpr('github.event.constructor', gh, { trusted: ['constructor'] }) === 'own'); +} { const repo = new Other(['askalf/example'], { repo: true }); const login = new Other(['dependabot[bot]']);