Skip to content

fix(api): return only the team fields the app reads from GET /me - #3860

Merged
jordan-simonovski merged 1 commit into
mainfrom
jordansimonovski/me-team-allowlist
Nov 30, 2026
Merged

jordan-simonovski merged 1 commit into
mainfrom
jordansimonovski/me-team-allowlist

Conversation

@jordan-simonovski

@jordan-simonovski jordan-simonovski commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

GET /me loaded the whole Team document and returned it as team to every signed-in member, read-only users included. Today that holds nothing beyond what /team already shows members, but any sensitive field added to Team later would have reached all of them. /me now loads only the fields in MeTeamSchema: id, name and the team's ClickHouse settings.

  • team.apiKey and team.allowedAuthMethods are no longer in the /me response. The app reads both from /team and the CLI never used them, so nothing in this repo changes behaviour. A script that read them from /me should read /team instead.
  • Local app mode still returns its fixed placeholder team, because getTeam ignores the field list there. That object holds placeholder UUIDs only.
Implementation detail
  • The response schema and the Mongo projection both come from MeTeamSchema, so a field added to the schema is loaded and one left out is never fetched.
  • The CLI's hand-written MeResponse type drops the apiKey it no longer receives.
  • A new integration test fails if /me returns any Team key outside MeTeamSchema. The me suite passes, and api, app and CLI typecheck.

How to reproduce

Starting point: yarn dev, signed in.

On main:

  1. Open the browser network tab, reload, and select the me request.
  2. The team object includes apiKey, hookId, collectorAuthenticationEnforced and every other Team field.

On this branch:

  1. Same request.
  2. team has only id, name and any ClickHouse settings set on the team.

How to test on Vercel preview

N/A, non-UI change.

References

  • Linear Issue: HDX-6228

Note

Medium Risk
Narrows a high-traffic auth endpoint's payload and changes an API contract (removed team.apiKey from /me); in-repo clients are updated, but external scripts reading secrets from /me would break.

Overview
GET /me no longer returns sensitive or unused team fields such as apiKey, hookId, and allowedAuthMethods. The response team object is now limited to id, name, and team ClickHouse settings via a shared MeTeamSchema, and the handler projects the same field list when loading from Mongo so extra Team fields are not fetched or leaked to every signed-in member (including read-only users).

The app already loads apiKey and auth settings from /team; the CLI MeResponse type is updated to match. An integration test asserts that no keys outside MeTeamSchema appear on team.

Reviewed by Cursor Bugbot for commit 621d2ac. Bugbot is set up for automated code reviews on this repo. Configure here.

GET /me loaded the whole Team document and sent it to every member,
read-only users included, so any secret later added to Team would leak.
It now loads only MeTeamSchema: id, name and the ClickHouse settings.
apiKey and allowedAuthMethods are dropped from /me; the app reads them
from /team.

Refs HDX-6228
@jordan-simonovski
jordan-simonovski requested a review from a team as a code owner November 30, 2026 09:26
@vercel

vercel Bot commented Nov 30, 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 30, 2026 9:31am UTC
hyperdx-storybook Ready Ready Preview Nov 30, 2026 9:31am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 621d2ac

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

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

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

Additional context: grazes a critical path (3 lines in packages/api/src/routers/api/me.ts) inside a 17-line PR, so it is tiered on size, spans packages but only 17 prod lines — under the 100-line cross-layer bar

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

Stats
  • Production files changed: 3
  • Production lines changed: 17 (+ 23 in test files, excluded from tier calculation)
  • Branch: jordansimonovski/me-team-allowlist
  • Author: jordan-simonovski

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

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 108 in total (1.10%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

Copy link
Copy Markdown
Contributor

PR Review

✅ No issues found.

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This PR does what it claims: GET /me now narrows its team payload to an allowlist (MeTeamSchema) via a Mongo inclusion projection, and four reviewers independently traced the exposure reduction end-to-end — no app or CLI consumer reads team.apiKey/team.allowedAuthMethods from /me (both come from /team, unchanged), the removed CLI apiKey type was dead, and the new integration test guards the field set against the schema itself so it stays robust as the schema evolves.

🟡 P2 — recommended

  • .changeset/ — No changeset accompanies behavior-affecting changes to three published packages (@hyperdx/api, @hyperdx/common-utils, @hyperdx/cli), which the repo's AGENTS.md PR-hygiene rule requires for user-facing/behavioral changes.
    • Fix: Run yarn changeset and add a patch-bump entry describing the GET /me team-field narrowing.
    • project-standards, previous-comments
🔵 P3 nitpicks (1)
  • packages/api/src/controllers/team.ts:80 — In IS_LOCAL_APP_MODE, getTeam ignores the fields projection and returns LOCAL_APP_TEAM, which still serializes placeholder apiKey/hookId on /me; pre-existing and limited to process-local random UUIDs in single-user mode, so the new allowlist guarantee silently does not apply there.
    • Fix: If the allowlist should also hold in local mode, pick LOCAL_APP_TEAM down to the fields list before returning it.
    • correctness, security, testing

Reviewers (10): correctness, testing, maintainability, project-standards, agent-native, learnings-researcher, security, api-contract, kieran-typescript, previous-comments.

Testing gaps:

  • The new me.int.test.ts allowlist assertion runs only in non-local mode; no test covers the IS_LOCAL_APP_MODE path or guards against the getTeam projection being dropped/widened, which is the sole runtime guard since sendJson does not strip against MeApiResponseSchema.

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

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 482 passed • 1 skipped • 1067s

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

Tests ran across 4 shards in parallel.

View full report →

@jordan-simonovski
jordan-simonovski merged commit 1a44007 into main Nov 30, 2026
33 of 35 checks passed

This branch was successfully deployed

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

Labels

review/tier-3 Standard — full human review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants