Skip to content

fix: ignore team and createdBy in dashboard and saved search PATCH - #3535

Merged
kodiakhq[bot] merged 3 commits into
mainfrom
drew/backport-dashboard-reassignment
Nov 3, 2026
Merged

kodiakhq[bot] merged 3 commits into
mainfrom
drew/backport-dashboard-reassignment

Conversation

@pulpdrew

@pulpdrew pulpdrew commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Backports security fixes from EE:

  1. createdBy and team can no longer be updated by dashboard PATCH requests.
  2. createdBy can no longer be updated by saved search PATCH requests

Screenshots or video

How to reproduce

Send PATCH dashboard or saved search API requests that include createdBy or team and observe that the values are ignored.

How to test on Vercel preview

References

  • Linear Issue:
  • Related PRs:

@pulpdrew
pulpdrew requested a review from a team as a code owner November 3, 2026 18:08
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Nov 3, 2026 6:57pm UTC
hyperdx-storybook Ready Ready Preview Nov 3, 2026 6:57pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2f59b4f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/api Patch
@hyperdx/app Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the review/tier-3 Standard — full human review required label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

🟡 Tier 3 — Standard

Introduces new logic, modifies core functionality, or touches areas with non-trivial risk.

Why this tier:

  • Touches API routes or data models — hidden complexity risk

Review process: Full human review — logic, architecture, edge cases.
SLA: First-pass feedback within 1 business day.

Stats
  • Production files changed: 6
  • Production lines changed: 69 (+ 93 in test files, excluded from tier calculation)
  • Branch: drew/backport-dashboard-reassignment
  • Author: pulpdrew

To override this classification, remove the review/tier-3 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 114 in total (1.40%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

// A smuggled `team`/`createdBy` here would move the document between
// tenants / forge ownership (the model marks them immutable, but the
// write below reaches Mongo directly).
const {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — Controller guard can't be reached, throws (a 500) where the PR says the fields are ignored, and uses an as cast

updates is typed Partial<DashboardWithoutId>, which has no team/createdBy. The only caller (routers/api/dashboards.ts) re-parses and strips them, and the model now marks both immutable. So this branch never runs. If it ever did, it would return a 500, which contradicts the changeset's 'ignore' wording and the silent drop in controllers/savedSearch.ts. The as Record<string, unknown> cast also erases the type of safeUpdates, which breaks the 'avoid as casts' convention. Remove the block and spread updates, or at least drop the keys silently without the cast.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

5 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 5 minor

1 posted as inline comment(s) on the changed lines. 4 listed below.

Findings outside the changed lines

4 minor
  • 🔵 packages/api/src/routers/api/__tests__/dashboard.int.test.ts:141 — Removing _.omit(req.body, 'provisioned') leaves provisioned protected only by the re-parse, and no test covers it → The PATCH handler no longer drops provisioned by name. It now relies on DashboardWithoutIdSchema.partial().parse() stripping it. Unlike team/createdBy, the model does not mark provisioned immutable, so the re-parse is the only guard. If someone later adds provisioned to DashboardSchema in common-utils/src/types.ts, or swaps the re-parse back to req.body, callers can hand their dashboard to the provisioner again. Add provisioned: true to the smuggled PATCH body in this test and assert that stored.provisioned stays false.
  • 🔵 packages/api/src/routers/api/__tests__/dashboard.int.test.ts:149 — New tests still pass if the router re-parse is removed → The new immutable: true on team/createdBy in models/dashboard.ts and models/savedSearch.ts already makes Mongoose drop those paths from findOneAndUpdate. The saved-search controller also overwrites team: teamId on its own. So these PATCH tests pass whether or not the router re-parse exists, and the saved-search team assertion passed before this PR too. To actually pin the router layer, assert on the updates that reach the controller, or smuggle a field that is not immutable, such as provisioned.
  • 🔵 packages/api/src/controllers/savedSearch.ts:53 — Comment claims callers pass merged stored documents, but none do, so the strip and its as cast can't matter → All three callers build fresh objects with no createdBy: routers/api/savedSearch.ts (re-parsed body), routers/external-api/v2/savedSearches.ts (toSavedSearchInput) and mcp/tools/savedSearches/saveSavedSearch.ts (an object literal). The SavedSearchWithoutId parameter type has no createdBy, and the model now marks it immutable. Remove the destructure and the as SavedSearchWithoutId & { createdBy?: unknown } cast, which breaks the 'avoid as casts' convention, or fix the comment.
  • 🔵 packages/api/src/routers/api/dashboards.ts:179 — POST still strips server-owned keys by name while PATCH now re-parses → The PATCH comment says re-parsing replaces 'omitting keys by name', yet the POST handler right above still uses _.omit(req.body, 'provisioned') on the raw, un-replaced body. That leaves two ways of enforcing the same rule. Use DashboardWithoutIdSchema.parse(req.body) in POST as well so both handlers drop undeclared keys the same way.

Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

The change correctly closes the reported vulnerability on the primary PATCH paths. For both resources the handler now re-parses the request body against a zod schema that does not declare team/createdBy (and provisioned for dashboards), so zod's default key-stripping drops them before the update; this is backed by controller-level stripping/guards and immutable: true on the model fields. I verified that DashboardSchema and SavedSearchSchema in packages/common-utils/src/types.ts declare none of the server-owned fields, that the sole caller of the updateDashboard controller passes already-parsed updates (so its new throw is unreachable defense-in-depth, not a regression), and that the external-api v2 and MCP mutation paths build explicit payloads and route through the same stripping controller, so no alternate bypass remains.

🟡 P2 -- recommended

  • packages/api/src/routers/api/__tests__/dashboard.int.test.ts:2642 -- the new comment lists provisioned as a server-owned field dropped by the same re-parse mechanism, but no test asserts a smuggled provisioned: true is ignored, leaving part of the new security surface uncovered.
    • Fix: add an assertion in the new PATCH /:id server-owned fields block that a PATCH with provisioned: true does not persist to the stored document.
🔵 P3 nitpicks (2)
  • packages/api/src/routers/api/dashboards.ts:222 -- the comment claims "the schema's optional fields are .nullable()," but tags, tiles, filters, savedFilterValues, and containers are optional-but-not-nullable in DashboardSchema; the null-removal guarantee actually holds only because the preceding validateRequest already rejects nulls on those fields, not because every field is nullable.
    • Fix: reword the comment to state that only the already-nullable fields retain null and that nulls on non-nullable fields are rejected earlier by validateRequest.
  • packages/api/src/routers/api/__tests__/savedSearch.int.test.ts:192 -- the regression tests cover the internal /dashboards and /saved-search PATCH routes but not the external-api v2 PUT or MCP mutation paths, which rely on the same controller strip for the server-owned-field guarantee.
    • Fix: add a lightweight test exercising the external-api v2 update path to lock in the server-owned-field behavior against future refactors.

Reviewers (9): correctness, security, adversarial, testing, maintainability, api-contract, kieran-typescript, project-standards, reliability.

Testing gaps: provisioned smuggling is not asserted on dashboard PATCH; external-api v2 and MCP update paths lack regression coverage for the server-owned-field property.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 462 passed • 1 skipped • 1774s

Status Count
✅ Passed 462
❌ Failed 0
⚠️ Flaky 0
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@kodiakhq
kodiakhq Bot merged commit 769c0de into main Nov 3, 2026
28 checks passed
@kodiakhq
kodiakhq Bot deleted the drew/backport-dashboard-reassignment branch November 3, 2026 19:04

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 2f59b4fe Deployed Nov 3, 2026 by vercel[bot]
Preview – hyperdx-storybook — 2f59b4fe Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-3 Standard — full human review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants