Skip to content

fix: redact sensitive data in MCP resource endpoints#295

Merged
RyanNg1403 merged 1 commit intomainfrom
fix/mcp-resource-redaction
Mar 16, 2026
Merged

fix: redact sensitive data in MCP resource endpoints#295
RyanNg1403 merged 1 commit intomainfrom
fix/mcp-resource-redaction

Conversation

@RyanNg1403
Copy link
Copy Markdown
Collaborator

Summary

  • Apply redactSensitiveData() to cipher://agent/card resource to mask sensitive fields before serialization
  • Replace raw error messages in cipher://agent/stats failed connections with generic "Connection failed" — prevents leaking API keys, URLs, or credentials via error strings
  • Stop exposing raw error details in the stats error handler catch block

Uses the existing redactSensitiveData() utility from src/app/api/utils/security.ts, already used by the REST API /api/config route.

Test plan

  • All 11 MCP endpoint tests pass
  • pnpm run format:check passes
  • TypeScript compiles (no new errors)
  • Response shape unchanged — same JSON keys, sanitized values only

Fixes #292

- Apply redactSensitiveData() to agent card resource to mask any
  sensitive fields (apiKey, token, secret, etc.) before serialization
- Replace raw error messages in failed MCP connections with generic
  "Connection failed" to prevent leaking API keys, URLs, or credentials
- Stop exposing raw error details in stats error handler
- Fix pre-existing prettier formatting in neo4j.ts

Fixes #292
@RyanNg1403 RyanNg1403 merged commit 9ffb8da into main Mar 16, 2026
5 checks passed
@RyanNg1403 RyanNg1403 deleted the fix/mcp-resource-redaction branch March 27, 2026 02:14
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.

🚨 Security Vulnerability: API Key Exposure in MCP Resources

1 participant