From ce28fae3e71643e8d1b981f82436aea4f0c2431a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 8 Oct 2026 06:59:46 +0000 Subject: [PATCH 1/2] chore: tidy the #264 follow-ups (changeset ranges, a dictionary type, a shadowed list) - The pending changeset gave one affected range for both defects. The prototype pollution through `nest` affects 0.1.0-0.16.3; the filter grammar's `Object.prototype` 500 affects only 0.13.0-0.16.3, since `src/internal/filter.ts` first shipped in 0.13.0 (f59b77c, #86). - `nest`'s group literal no longer carries a `Record` annotation, a `no-unsafe-dictionary-type` site the effect `Record` import hid from the linter; the cast after `getOrElse` already types the group, so the rule's true count is back to its pre-#264 base. - `Query.filter.test.ts` drops a nested `inherited` list that shadowed the identical module-level one. No behaviour change. Refs #260. Claude-Session: https://claude.ai/code/session_0187g2QpzaHqEzX8GJxiJBVc Co-Authored-By: Claude --- .changeset/undeclared-query-params.md | 2 +- src/Query.filter.test.ts | 5 ----- src/internal/codecs.ts | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.changeset/undeclared-query-params.md b/.changeset/undeclared-query-params.md index 4ead55f5..b9997236 100644 --- a/.changeset/undeclared-query-params.md +++ b/.changeset/undeclared-query-params.md @@ -2,6 +2,6 @@ "@thomasfosterau/effect-jsonapi": patch --- -**Security:** fixes a prototype-pollution vulnerability (CWE-1321) reachable through query parameters on endpoints whose query declares no family (e.g. `Endpoint.get` of a resource without relationships), and a request-triggerable 500 in the filter grammar for field names that collide with `Object.prototype` members. Versions 0.1.0–0.16.3 are affected; upgrade. +**Security:** fixes two defects reachable through query parameters; upgrade. A prototype-pollution vulnerability (CWE-1321) on endpoints whose query declares no family (e.g. `Endpoint.get` of a resource without relationships) affects versions 0.1.0–0.16.3. A request-triggerable 500 in the `filter: true` grammar for field names that collide with `Object.prototype` members affects versions 0.13.0–0.16.3, the releases that ship that grammar. An endpoint whose query declares no family — `Endpoint.get(R)` for a resource with no relationships, or any `Query.schema(R, {})` — no longer passes undeclared query parameters through to the handler's `query` (typed `{}`). `Query.schema` now keeps only the keys it declares, whether or not it declares any, so such a query decodes (and encodes) to `{}` exactly as undeclared keys are already dropped by a query that declares something. That includes a name admitted by `Middleware.layerWith({ allowedQueryParameters })`, which now never reaches the decoded `query`, as documented. The bracket reshaper behind it writes every key as an own property and no longer throws on a bracket key whose name a bare key also holds. The `filter: true` grammar (and `Filter.normalise`) reads only a resource's own filterable fields, so any field name it does not declare is a 400 `Unknown filter field` on decode and an `InvalidFilter` on encode. Declared parameters decode and encode as before. diff --git a/src/Query.filter.test.ts b/src/Query.filter.test.ts index 6869658a..442a6611 100644 --- a/src/Query.filter.test.ts +++ b/src/Query.filter.test.ts @@ -669,11 +669,6 @@ describe("Query.Filter: rejections name the offending key", () => { ); }); - // `Resource.filterable` is a plain object, so a field name that is an - // `Object.prototype` member must read as undeclared, not as the inherited - // value (#260). - const inherited = ["constructor", "__proto__", "toString", "hasOwnProperty", "valueOf"]; - it.each(inherited)( "rejects a field named %s, an Object.prototype member, in every spelling", (name) => { diff --git a/src/internal/codecs.ts b/src/internal/codecs.ts index b6b84a65..fe39c01e 100644 --- a/src/internal/codecs.ts +++ b/src/internal/codecs.ts @@ -189,7 +189,7 @@ export const nest = (flat: { readonly [key: string]: unknown }): Record { - const made: Record = {}; + const made = {}; define(nested, name, made); return made; }) as Record; From a60ec27d354361d9a7789d1267502caf7e8e64c8 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 8 Oct 2026 07:14:23 +0000 Subject: [PATCH 2/2] chore: count the bare/bracket 500 in the changeset headline The pending changeset's headline named two defects, but the change also fixes a third request-triggerable 500: `nest`'s `??= {}` group write throws a TypeError when a bracket key follows a bare key of the same name (strict-mode assignment onto a string), the #260 title bug. It hits the same no-family endpoints over the same range. Checked against the published 0.1.0 and 0.16.3 packages: `Query.schema(R, {})` throws `TypeError: Cannot create property ... on string` for that input on both. The headline now names three defects: the prototype pollution and that 500 on no-family endpoints (0.1.0-0.16.3), and the filter grammar's 500 (0.13.0-0.16.3). Still no request payload and no fixed version. Refs #260. Claude-Session: https://claude.ai/code/session_0187g2QpzaHqEzX8GJxiJBVc Co-Authored-By: Claude --- .changeset/undeclared-query-params.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/undeclared-query-params.md b/.changeset/undeclared-query-params.md index b9997236..aa9a1d92 100644 --- a/.changeset/undeclared-query-params.md +++ b/.changeset/undeclared-query-params.md @@ -2,6 +2,6 @@ "@thomasfosterau/effect-jsonapi": patch --- -**Security:** fixes two defects reachable through query parameters; upgrade. A prototype-pollution vulnerability (CWE-1321) on endpoints whose query declares no family (e.g. `Endpoint.get` of a resource without relationships) affects versions 0.1.0–0.16.3. A request-triggerable 500 in the `filter: true` grammar for field names that collide with `Object.prototype` members affects versions 0.13.0–0.16.3, the releases that ship that grammar. +**Security:** fixes three defects reachable through query parameters; upgrade. A prototype-pollution vulnerability (CWE-1321) and a request-triggerable 500 on endpoints whose query declares no family (e.g. `Endpoint.get` of a resource without relationships) affect versions 0.1.0–0.16.3; a second request-triggerable 500, in the `filter: true` grammar for field names that collide with `Object.prototype` members, affects versions 0.13.0–0.16.3, the releases that ship that grammar. An endpoint whose query declares no family — `Endpoint.get(R)` for a resource with no relationships, or any `Query.schema(R, {})` — no longer passes undeclared query parameters through to the handler's `query` (typed `{}`). `Query.schema` now keeps only the keys it declares, whether or not it declares any, so such a query decodes (and encodes) to `{}` exactly as undeclared keys are already dropped by a query that declares something. That includes a name admitted by `Middleware.layerWith({ allowedQueryParameters })`, which now never reaches the decoded `query`, as documented. The bracket reshaper behind it writes every key as an own property and no longer throws on a bracket key whose name a bare key also holds. The `filter: true` grammar (and `Filter.normalise`) reads only a resource's own filterable fields, so any field name it does not declare is a 400 `Unknown filter field` on decode and an `InvalidFilter` on encode. Declared parameters decode and encode as before.