fix(security): Block unauthenticated MCP tool poisoning on supply-chain write endpoints#545
Open
prince-shakyaa wants to merge 1 commit into
Conversation
prince-shakyaa
force-pushed
the
fix/mcp-tool-poisoning-544
branch
from
July 14, 2026 18:30
f623202 to
ef714ec
Compare
…in write endpoints
prince-shakyaa
force-pushed
the
fix/mcp-tool-poisoning-544
branch
from
July 14, 2026 18:34
ef714ec to
069ab18
Compare
Author
|
Hii @saikishu , @e2hln Let me know if you need any changes. Thank You. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(security): Block unauthenticated MCP tool poisoning on supply-chain write endpoints
Fixes #544
Summary
The Dark Lab supply-chain API (
/darklab/api/v1/supply-chain/servers) allowed any anonymous (temp-session) user to modify or reset the MCP tool definitions for any server (findrive,finmail,finstripe,taxcalc,systemutils). Because the server stores these overrides and immediately loads them into the AI agent, this was a fully exploitable unauthenticated prompt injection / tool poisoning channel that allowed an attacker to silently hijack the behaviour of the copilot.Root Cause
Two independent write endpoints in the darklab API were improperly authenticated:
finbot/apps/darklab/routes/api.pyPUT /supply-chain/servers/{server_type}/tools) usedget_session_context, which accepts anonymous temporary sessionsfinbot/apps/darklab/routes/api.pyPOST /supply-chain/servers/{server_type}/reset-tools) usedget_session_contextChanges -
finbot/apps/darklab/routes/api.py1. Write endpoints require an authenticated (email-bound) session
Endpoints changed:
PUT /darklab/api/v1/supply-chain/servers/{server_type}/tools- Update tool overridesPOST /darklab/api/v1/supply-chain/servers/{server_type}/reset-tools- Clear existing overridesThe read-only endpoints (
GET /supply-chain/servers,GET /supply-chain/servers/{server_type}, andGET /supply-chain/stats) remain accessible to temp sessions - they only return data and pose no security risk.What Was NOT Changed
MCPServerConfigRepository- no changes needed; the data layer was already correctly namespaced, but the route needed authentication to protect it.get_session_context(no sensitive write operations)Attack Scenarios Blocked
PUTto inject malicious instructions intosend_emailPOST /reset-toolsto wipe a legitimate user's toolsPUTto test a supply-chain attack payloadTests
New - Route-level security tests
tests/unit/apps/darklab/test_darklab_route_security.py(new file)TestDarkLabWriteEndpointsRequireAuthPUTtools,POSTreset-tools) return 401 for anonymous (temp) sessions, but succeed (200) for authenticated sessions. The read-onlyGETendpoints still correctly return 200 for anonymous sessions.Manual smoke test
Checklist
GET) unchanged - no regression for anonymous userstest_darklab_route_security.py) - 401 + 200 cases