🔒 Fix Unauthenticated RCE Vulnerability in execute_tool endpoint#39
🔒 Fix Unauthenticated RCE Vulnerability in execute_tool endpoint#39jakobengdahl wants to merge 1 commit into
Conversation
- Restrict `execute_tool` to read-only operations when authentication is disabled. - Implement `SAFE_TOOLS` whitelist in `backend/api_host/server.py`. - Update `frontend/web/src/components/ChatPanel.jsx` to use `api.addNodes` instead of `execute_tool` for saving views, ensuring compatibility and correct API usage. - Add comprehensive security tests in `backend/tests/test_security_execute_tool.py` covering authenticated and unauthenticated scenarios. This change mitigates the risk of arbitrary tool execution by unauthenticated users while preserving read-only access for public instances. Write operations now require authentication or use of specific REST endpoints that are subject to their own security policies. Co-authored-by: jakobengdahl <5815405+jakobengdahl@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR addresses a critical security vulnerability where the
/execute_toolendpoint allowed unauthenticated execution of arbitrary MCP tools, potentially leading to Remote Code Execution (RCE) or data loss.Changes:
Backend (
backend/api_host/server.py):SAFE_TOOLSset containing read-only tools (e.g.,search_graph,get_node_details).execute_tool_endpointto enforce a check: ifAUTH_ENABLEDis false, only tools inSAFE_TOOLSare allowed. All other tools return a 403 Forbidden.AUTH_ENABLEDis true, the existing middleware handles authentication, so no additional check is needed (authenticated users are trusted).Frontend (
frontend/web/src/components/ChatPanel.jsx):api.addNodes()(which calls the REST endpoint) instead ofapi.executeTool('add_nodes', ...). This ensures the frontend uses the appropriate, typed API method and avoids the new restriction onexecute_toolfor what is essentially a data creation operation.Tests (
backend/tests/test_security_execute_tool.py):Impact:
execute_toolis now read-only for them. This encourages enabling authentication for any write-access deployment.PR created automatically by Jules for task 4151204992036068489 started by @jakobengdahl