Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions scripts/fleet-status/check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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; };
Expand Down
24 changes: 24 additions & 0 deletions scripts/fleet-status/check.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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]']);
Expand Down
Loading