[BUG]: Tool headers return unmasked when the caller is not identified
Summary
convert_tool_to_read decrypts tool headers, then compares the tool owner with the requester (tool_service.py:1830). A tool with no owner and a call with no requester both hold None, the comparison passes, and the decrypted headers return. The comment above states the opposite rule, mask everything when no requester is given (:1824). Export calls this path with no requester, so a bundle carries readable header values for every tool whose owner_email is null.
Proposed changes
- Mask the headers when the requester is not identified.
- Treat a null owner as no match.
Acceptance criteria
- A tool with no owner returns masked headers when the caller is not identified.
- An owner still reads their own headers.
- A platform admin still reads headers.
- A team owner still reads headers for a team tool.
- Tests cover a null owner with a null requester.
Related issues: #7408, #7420.
Implemented in PR #7537: https://github.com/IBM/mcp-context-forge/pull/7537
The fix prevents decrypted tool headers from being exposed when the stored owner or requesting user identity is missing or empty. Owner access now requires both identities to be present and equal, while admin and team-owner access remain unchanged.
Added regression coverage for missing and empty identities. Focused tests and static security checks pass.
Hi, this still reproduces on current main. In convert_tool_to_read (mcpgateway/services/tool_service.py), the comment says headers are masked when no requester context is provided, but the owner check getattr(tool, "owner_email", None) == requesting_user_email is True when both are None. So a tool with no owner_email returns decrypted headers to a caller with no identity. The team branch just below already guards against None.
#7537 had a fix but was closed by its author without merging on 24 Nov. Could a maintainer move this out of triage? If it's open for a contributor, I'm happy to send a PR that requires a non-None requester for the owner match, with tests for the None cases.