Skip to content

fix(security): tool results carry a teammate as id, name, email and picture only - #3

Open
boehlerlukas wants to merge 1 commit into
mainfrom
fix/mcp-results-public-user-shape
Open

boehlerlukas wants to merge 1 commit into
mainfrom
fix/mcp-results-public-user-shape

Conversation

@boehlerlukas

Copy link
Copy Markdown
Contributor

Moved from the private archive (MCP-server-archive PR #119) when this repo was published with a fresh history. Original author: @floooat.


Problem

The Gleap API fills in tickets and messages with the whole dashboard user record of the assignee (processingUser) or sender (a message's user), and the tools passed it straight on. assign_ticket, close_ticket, get_ticket and send_message (and every other tool that returns a ticket or message) put these fields into each MCP client's context and transcript:

  • token: the one-time reCAPTCHA response that old sign-ups still store
  • gaClientId
  • notificationSettings and notificationPreferences
  • onboardingFlow, lastAutoAssign and similar

Change

  • src/utils/userRecordRedaction.ts holds one serialiser, toPublicUser (_id, id, email, firstName, lastName, profileImageUrl), and a walk that finds user records at any depth. A user record is an object with an identity field plus a field that only the Server's User model has. Contacts have name and none of those fields, and the slim get_users entries (role, availability) don't match either, so both pass through unchanged.
  • applyShareTokenRedaction, the outermost result wrapper, also runs it. That covers every tool, current and future, on both success and error results, without touching src/index.ts.
  • When text isn't JSON as a whole (prose around JSON, or JSON escaped in a string), the token and gaClientId values are replaced, the same way the share-token redaction does it.
  • AGENTS.md: the "Secrets in results" bullet names the new module.

AGENTS.md lists the redaction under "stop and ask". This PR is that change, made on purpose.

Tests

  • tests/user-record-redaction.test.ts calls the real endpoint and was committed first. It failed on the four named tools and on 68 tools in a sweep where the API stub returns full user records everywhere. It also checks that a ticket's contact and the get_users role and availability are left alone.
  • src/utils/userRecordRedaction.test.ts covers the module itself: detection, input not changed, running it twice gives the same result, the text fallbacks, and text without a user record left as is.

Results:

  • npm run typecheck: exit 0
  • npm run test:coverage: 1383 of 1383 pass, coverage floors met
  • npm run build: exit 0
  • npm run quality: 0 problems, 0 warnings

Not in this PR

  • Server side: GleapSDK/Server#3176 keeps token out of UserProjection FULL, INTERNAL and SECURE. The other user fields still go out wherever those projections are used:

    • dashboard ticket and message routes
    • outgoing customer webhooks: MESSAGE_RECEIVED and the TICKET_UPDATED that contact.updated sends

    An inclusion projection for those populates would fix it at the source.

  • The reporter's contact on get_ticket: eventData and outboundHistory are still returned in full. The widget credentials were already stripped. Trimming the rest changes what get_ticket returns, so it's left for a product decision.

🤖 Generated with Claude Code

…icture only

Moved from the private archive repo (PR #119 there).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant