Skip to content

[2026.9.36] fix(discord): reject oversized vendored Zod collections early - #187289

Merged
RomneyDa merged 2 commits into
extended-stable/2026.9.33from
security/discord-zod-size-guards-20261029
Oct 29, 2026
Merged

RomneyDa merged 2 commits into
extended-stable/2026.9.33from
security/discord-zod-size-guards-20261029

Conversation

@RomneyDa

Copy link
Copy Markdown
Member

Scope

Draft targeting extended-stable/2026.9.33 (observed base e93b50ad2400871616c2e6588d57488dba94ecad, package version 2026.9.35). Focused mitigation for the Zod parser embedded inside Discord’s browser SDK, not a broad dependency refresh or a claim of clean dependency audits.

The published @discord/[email protected] bundles its own Zod 3 implementation. Updating the separately installed Zod package does not change those bytes. A baseline regression invokes element refinements on an oversized array; the patch rejects the collection before element or outer-refinement work.

Implementation and provenance

  • Adapt the early upper-size rejection behavior from Colin McDonnell’s upstream Zod commit a0ebf970f2d752e5f58527cd2942ff48be4f46bd (colinhacks/zod#6652), referenced by GHSA-mrhx-c7xc-m3w5.
  • This is a local Zod-3 adaptation, not a cherry-pick or Zod-4 migration. Six small branches across the ESM/CJS vendored parsers change: oversized array max/exact-length and set max/exact-size return the existing invalid result before traversal.
  • Preserve valid parsing/transforms, lower-bound failures, SDK authentication/scope fallbacks, declarations and exports. Early abort intentionally omits element/refinement issues and may wrap a union branch in invalid_union; regression coverage and the patch documentation make that compatibility change explicit. The bundled Zod-3 map API has no upper-size constraint.
  • Register one exact-version package patch and regenerate only its lockfile identity. No unrelated dependency versions, audit exceptions, or check behavior change.
  • Authentication/browser-build test scaffolding is adapted from local aggregate commit 8e6f7bd28af9e7bebf03ff08bf0001e4fc7561be, authored by roboclaw-bot, preserved in f0a0c53aa23b80bd68267fc48cfdda020db77c26; this is not an upstream OpenClaw fix being backported. New early-rejection and compatibility coverage belongs to this isolated local adaptation.
  • Upstream alternative checked on 2026-10-29: SDK stable 2.5.0 and beta 3.0.0-beta.3 both fail the early-rejection regression. discord/embedded-app-sdk#318, authored by renovate-bot (head 81e49dfa871e935641d9b9591ed789e837dc89e1), remains open; it is not a published compatible fix. This small patch avoids the previous whole-parser replacement.

Validation

  • Unpatched published SDK: regression fails (oversized array executes 3 element refinements).
  • Patched parser: 48 direct ESM/CJS, sync/async regression assertions pass, including arrays, exact lengths, sets, nested paths, valid transforms and wrong input types.
  • node scripts/run-vitest.mjs run test/scripts/discord-sdk-zod.test.ts: 7 tests pass, including both SDK entrypoints and the actual production browser build.
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.root.scripts.json --noEmit: pass.
  • Focused repository oxlint and oxfmt checks: pass.
  • pnpm install --frozen-lockfile --ignore-scripts, package-patch guard and git diff --check: pass. Native lifecycle / packaged-plugin qualification is not claimed.
  • Byte comparison of all 196 published SDK files: exactly the two vendored parser files differ. Published/installed hashes and the patch hash are documented in patches/README.md.

Boundaries / remaining gates

This does not remove the separately installed Zod-3 dependency or claim that the advisory is globally cleared. Beta 2026.10.10-beta.5 and stable 2026.10.8 also use SDK 2.5.0 and need the embedded-parser repair; this PR includes no unqualified cross-train commits. Their direct Zod 4.6.5 pins are a separate dependency scope.

Keep draft pending full independent review, hosted checks and release/packaged-plugin qualification. No ready-for-review request, merge, tag, or release is authorized by these local checks.

Locally adapt Colin McDonnell's Zod a0ebf970f2d752e5f58527cd2942ff48be4f46bd (#6652) to the SDK's bundled Zod 3 parser. This is not a cherry-pick or a Zod major migration. Preserve valid API behavior and document intentional early-abort issue changes.

Adapt authentication/browser regression scaffolding from local aggregate 8e6f7bd (roboclaw-bot), preserved in f0a0c53. Add direct size-bound and async regression coverage.

Co-authored-by: RomneyDa <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M labels Oct 29, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 29, 2026
@RomneyDa
RomneyDa marked this pull request as ready for review October 29, 2026 04:33
@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Patch Discord’s bundled Zod parser to reject oversized bounded arrays and sets before parsing their elements.

Example: An SDK schema permits five buttons but receives six.

  • Before: Validation visits the buttons before rejecting the collection.
  • After: Validation rejects the collection without reading the buttons.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The repair is focused and source-supported with meaningful regression coverage; evidence stops at in-process parser and bundle validation.
Proof confidence 🦐 gold shrimp (3/6) This verified maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence covers direct parser regressions and the production bundler in process, with packaged-plugin qualification expressly unclaimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Oversized SDK inputs can consume unnecessary browser resources despite an existing collection-size constraint.
Reason: The maintainer-directed mitigation restores effective upper bounds in the embedded parser without new configuration, unrelated dependency updates, or broader advisory-clearance claims.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses an unfixed bundled-parser defect with a narrow, source-supported repair; no actionable patch defect was found.

Priority: P2
Reviewed head: 0c38cbb44b5edc1597d7dec30feb615638ffa9ee

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied validation does not show a running Discord Activity consuming the packaged repaired SDK.
Agent review details

How this fits together

The Discord Activities build bundles the Embedded App SDK into a browser asset served by the Gateway; its embedded Zod parser validates SDK requests and responses.

flowchart LR
  A[Exact version package patch] --> B[Embedded SDK parser]
  B --> C[Activity browser bundle]
  C --> D[Gateway asset route]
  D --> E[Discord Activity browser]
  E --> F[SDK schema validation]
Loading

Technical review

Best possible solution:

Retain the exact-version parser repair and remove it once a published SDK passes the same regression coverage without patching.

Do we have a high-confidence way to reproduce the issue?

Published ESM and CJS parser source shows oversized bounded collections reaching element traversal, and the PR reports a failing unpatched regression; no target code was executed during this review.

Is this the best way to solve the issue?

The focused adaptation repairs the embedded parser that a root Zod upgrade cannot reach, preserves valid parsing, and avoids replacing the SDK’s schema major.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 54818f9e6756.

Provenance checked

  • Embedded Zod upper-bound validation changes intended behavior with a stated reason (unknown: The published Zod 3 parser retains size failures as dirty results and continues collecting element issues; the original introduction rationale was not established.)
  • Discord Activities SDK integration keeps the original intent (ddc9ec3: The original feature bundles Discord’s SDK for opt-in interactive Activities; this change retains that build and serving owner.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The introduced diff changes three upper-bound branches in each parser format, registers one exact-version patch, and adds focused compatibility coverage. (patches/@[email protected]:8, 0c38cbb44b5e)
  • Current main remains affected: Current main resolves Discord’s SDK to unpatched version 2.5.0; upgrading the separately installed Zod package does not replace its embedded parser. (pnpm-lock.yaml:1195, 54818f9e6756)
  • Published dependency contract: The patch directly changes this dependency’s runtime, making its published parser authoritative: array and set upper-bound failures mark validation dirty and then traverse elements; set size delegates to min and max. (output/lib/zod/lib/index.mjs:2213)
  • Upstream repair intent: The merged upstream repair explains why upper-size constraints must abort before element validation and explicitly accepts omitted element issues and skipped later refinements. (e06a510b6fc1)
  • Upstream alternative remains unavailable: The Zod 4 migration remains open at fix(deps): update dependency zod to v4 - autoclosed discord/embedded-app-sdk#318 and does not establish a published compatible replacement. (81e49dfa871e)
  • Production bundle coverage: The added suite exercises both module formats, synchronous and asynchronous parsing, actual SDK schemas, authentication fallbacks, and the existing production browser bundler. (test/scripts/discord-sdk-zod.test.ts:190, 0c38cbb44b5e)

PR surface

Tests +208, Docs +36, Config +1, Other +60. Total +305 across 6 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 208 0 +208
Docs 1 36 0 +36
Config 1 1 0 +1
Generated 0 0 0 0
Other 3 62 2 +60
Total 6 307 2 +305

Root-cause cluster

Relationship: canonical
Canonical: #187289
Summary: The sibling release-train PRs explicitly preserve this source commit’s parser patch and tests.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P2: This mitigates excessive validation work in the opt-in Discord Activities browser SDK; the evidence does not establish an urgent production outage or authorization bypass.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: This mitigates excessive validation work in the opt-in Discord Activities browser SDK; the evidence does not establish an urgent production outage or authorization bypass.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add redacted runtime evidence showing a packaged Discord Activity using the repaired SDK while valid authentication still succeeds.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 29, 2026, 12:41 AM ET / 04:41 UTC.

@RomneyDa RomneyDa changed the title [2026.9] fix(discord): reject oversized vendored Zod collections early [2026.9.36] fix(discord): reject oversized vendored Zod collections early Oct 29, 2026
@RomneyDa
RomneyDa merged commit 0968630 into extended-stable/2026.9.33 Oct 29, 2026
194 checks passed
@RomneyDa
RomneyDa deleted the security/discord-zod-size-guards-20261029 branch October 29, 2026 06:01
RomneyDa added a commit that referenced this pull request Oct 29, 2026
…187296)

* fix(macos): skip passive uninstall without plist (#181257)

Passive macOS Gateway stops now preserve an absent current-profile service definition without invoking uninstall, while explicit low-level ghost recovery remains available.

Release adaptation: the 2026.10.8 backport of #180390 removed the absent-plist
guard from GatewayLaunchAgentManager's disable path without main's follow-up,
so every passive stop with no LaunchAgent plist ran `openclaw gateway uninstall`
(mac validation: GatewayProcessManagerTests "pause preserves unretainable
services" [absent]). Stable has no migration-pending custody or `.authority`
wrapper, so the guard checks `custody.definition.plist` directly. Mac-only
post-tag fix; npm, Docker and Linux bytes are unaffected.

(cherry picked from commit cb10ec4)

* fix(discord): reject oversized vendored Zod collections on stable

Port local adaptation 0c38cbb (roboclaw-bot, #187289) to release/2026.10.8.
Locally adapt Colin McDonnell Zod a0ebf970f2d752e5f58527cd2942ff48be4f46bd (#6652); not an upstream OpenClaw cherry-pick or major migration.
Test scaffolding: 8e6f7bd (roboclaw-bot), preserved in f0a0c53.

Co-authored-by: RomneyDa <[email protected]>

---------

Co-authored-by: Shakker <[email protected]>
Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 29, 2026
)

Port local adaptation 0c38cbb (roboclaw-bot, #187289) to release/2026.10.10.
Locally adapt Colin McDonnell Zod a0ebf970f2d752e5f58527cd2942ff48be4f46bd (#6652); not an upstream OpenClaw cherry-pick or major migration.
Test scaffolding: 8e6f7bd (roboclaw-bot), preserved in f0a0c53.

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants