@devries-cameron20 / composio Mirror · read-only / commits / 908aad7e1
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 22:15 UTC

fix(python-sdk): address SEC-365 review — loud failure + allowlist sanitization

Addresses review on PR #3302: P2 #1 — `CustomTool.__call__` now raises `TypeError` if `user_id` appears in `**kwargs` rather than silently dropping it. Silent drop expanded the blast radius (a tenant registered as `user_id="default"` would have absorbed those calls) and swallowed prompt-injection signals. The trusted entry point is `CustomTools.execute(slug, request, user_id=...)`. P2 #2 — `CustomTools.execute` now sanitizes via an *allowlist* of fields declared on the tool's Pydantic `request_model` (canonical names + aliases), not a denylist of just `"user_id"`. Future identity-bearing keys (`tenant_id`, `org_id`, `connected_account_id`, …) cannot reopen CWE-639 by being smuggled through `request`. P3 — also: - Renamed `CustomTool._invoke` to `invoke_trusted` so the security contract is in the name, not just the docstring. - Tightened `CustomTools.execute` return type from `t.Dict` to `t.Any` (the user's tool function can return anything; `_invoke` already had `t.Any`). - Consolidated repeated SEC-365/CWE-639 docstring blocks into a single module-level note in `custom_tools.py`. - Added a load-bearing security-invariant note to `custom_tool_execution.py` (the parallel session/tool-router path): on that path `user_id` arrives via `SessionContext`, never via `arguments`. Tests: - New: `test_execute_strips_unexpected_fields_via_allowlist` — pins the durable allowlist behaviour against future identity kwargs. - New: `test_execute_keeps_aliases_declared_on_request_model` — ensures Pydantic field aliases are honoured. - New: `test_invoke_trusted_uses_explicit_user_id_over_smuggled_one` — pins the `invoke_trusted` defense-in-depth contract when a `user_id` is smuggled inside `request_kwargs`. - New: `test_tools_execute_e2e_strips_user_id_through_full_stack` — E2E through `Tools.execute → _execute_custom_tool → CustomTools.execute`. - Updated: `test_call_raises_typeerror_when_user_id_smuggled_in_kwargs` (previously codified the silent-drop behaviour). - Refactored shared mock-client/tool wiring into pytest fixtures. 639 → 642 Python tests pass. Lint, format, mypy clean on changed files. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: srujan <srujan@composio.dev>

Zen Agent committed Apr 28, 2026 at 09:54 UTC 908aad7e1e40d0d80f6aef26677bb777d3c9232c
3 files changed +252 -128
python/composio/core/models/custom_tool_execution.py
+8
@@ -1,6 +1,14 @@
1 """Standalone functions for custom tool lookup and execution.
2
3 Extracted for reuse in SessionContextImpl (sibling routing).
4 +
5 +Security invariant (CWE-639 / SEC-365): on this code path the trusted
6 +``user_id`` arrives via ``SessionContext`` — never via ``arguments``. The
7 +``arguments`` dict is LLM-supplied and is validated through the tool's
8 +Pydantic ``input_params`` model, which discards unknown fields, so an
9 +attempt to smuggle ``user_id`` (or any other identity-bearing key) inside
10 +``arguments`` cannot reach the tool's execute function or auth lookup.
11 +Keep this property when modifying ``execute_custom_tool``.
12 """
13
14 from __future__ import annotations
python/composio/core/models/custom_tools.py
+71 -34
@@ -1,4 +1,30 @@
1 -"""Custom Tools module"""
1 +"""Custom Tools module.
2 +
3 +Security model — SEC-365 / CWE-639 (cross-tenant credential access)
4 +-------------------------------------------------------------------
5 +
6 +Custom tools execute against the caller's OAuth credentials, looked up by
7 +``user_id``. The LLM supplies the *request* arguments for a tool call; the
8 +SDK supplies the ``user_id``. These two inputs MUST stay structurally
9 +separate — if they ever collapse into one ``**kwargs`` dict, an LLM (or a
10 +prompt-injection input) can set ``user_id`` and have us load another
11 +tenant's tokens.
12 +
13 +The trust boundary is ``CustomTools.execute(slug, request, user_id)``:
14 +
15 + * ``request`` is treated as untrusted and is filtered through an
16 + *allowlist* of fields declared on the tool's Pydantic ``request_model``,
17 + so today's ``user_id`` smuggling — and any future identity-bearing key
18 + that might be added to the auth path (``tenant_id``, ``org_id``, …) —
19 + is dropped before it can reach credential lookup.
20 + * ``user_id`` is forwarded to ``CustomTool.invoke_trusted(user_id, request_kwargs)``
21 + as a structurally separate parameter.
22 +
23 +``CustomTool.__call__`` (the public ``tool(**kwargs)`` shorthand) raises
24 +``TypeError`` if ``user_id`` appears in ``kwargs`` — refusing the smuggled
25 +key loudly rather than silently using a fallback that could collide with a
26 +real tenant.
27 +"""
28
29 import functools
30 import inspect
@@ -133,29 +159,29 @@ class CustomTool:
159 def __call__(self, **kwargs: t.Any) -> t.Any:
160 """Call the custom tool with the default ``user_id``.
161
136 - ``kwargs`` is treated as untrusted LLM-supplied input. ``user_id`` is
137 - therefore NOT extracted from ``kwargs``: allowing an LLM (or
138 - prompt-injection input) to pick which tenant's ``user_id`` is used to
139 - look up OAuth credentials would let it read another tenant's tokens
140 - (CWE-639, see SEC-365). Any ``user_id`` key in ``kwargs`` is dropped
141 - before the request body is validated.
142 -
143 - To use a non-default ``user_id``, call through
144 - ``CustomTools.execute(slug, request, user_id)`` (the canonical entry
145 - point), which sanitizes the request dict and supplies the trusted
146 - ``user_id`` from server-side context.
162 + Refuses ``user_id`` in ``kwargs`` with ``TypeError`` rather than
163 + silently dropping it — see the module docstring for why. Use
164 + ``CustomTools.execute(slug, request, user_id=...)`` (the trusted
165 + entry point) when you need a non-default ``user_id``.
166 """
148 - kwargs.pop("user_id", None)
149 - return self._invoke(user_id="default", request_kwargs=kwargs)
150 -
151 - def _invoke(self, user_id: str, request_kwargs: t.Dict[str, t.Any]) -> t.Any:
152 - """Trusted internal entry point.
167 + if "user_id" in kwargs:
168 + raise TypeError(
169 + "CustomTool.__call__ does not accept user_id; "
170 + "use CustomTools.execute(slug, request, user_id=...) instead."
171 + )
172 + return self.invoke_trusted(user_id="default", request_kwargs=kwargs)
173
154 - Called by ``CustomTools.execute`` after ``request_kwargs`` has been
155 - sanitized at the LLM trust boundary. ``user_id`` is supplied here as
156 - a positional / keyword argument that is structurally separate from
157 - the ``request_kwargs`` dict, so an LLM-controlled key inside the
158 - dict cannot be promoted to override the trusted value.
174 + def invoke_trusted(
175 + self,
176 + user_id: str,
177 + request_kwargs: t.Dict[str, t.Any],
178 + ) -> t.Any:
179 + """Trusted entry point used by ``CustomTools.execute``.
180 +
181 + ``user_id`` is taken as a structurally separate parameter, so an
182 + LLM-controlled ``user_id`` key sitting inside ``request_kwargs``
183 + cannot override it (the request model's default ``extra='ignore'``
184 + means any such key is also dropped during validation).
185 """
186 request = self.request_model.model_validate(request_kwargs)
187 if self.toolkit is None:
@@ -168,6 +194,16 @@ class CustomTool:
194 )
195
196
197 +def _allowed_request_field_names(request_model: t.Type[BaseModel]) -> t.Set[str]:
198 + """Names accepted by ``request_model`` (canonical name + alias)."""
199 + allowed: t.Set[str] = set()
200 + for field_name, field_info in request_model.model_fields.items():
201 + allowed.add(field_name)
202 + if field_info.alias is not None:
203 + allowed.add(field_info.alias)
204 + return allowed
205 +
206 +
207 class CustomTools:
208 """CustomTools class
209
@@ -226,22 +262,23 @@ class CustomTools:
262 slug: str,
263 request: t.Dict,
264 user_id: t.Optional[str] = None,
229 - ) -> t.Dict:
230 - """Execute a custom tool.
231 -
232 - ``request`` is the LLM-supplied argument dict and is treated as
233 - untrusted: any ``user_id`` key it contains is stripped here so that
234 - only the explicit ``user_id`` parameter (sourced from trusted
235 - server-side context) is used to look up auth credentials. Without
236 - this sanitization an LLM (or prompt-injection input) could specify
237 - another tenant's ``user_id`` and read their OAuth tokens
238 - (CWE-639, see SEC-365).
265 + ) -> t.Any:
266 + """Execute a custom tool — the trust boundary for LLM-supplied args.
267 +
268 + ``request`` is filtered through an allowlist of fields declared on
269 + the tool's Pydantic ``request_model`` (canonical names + aliases).
270 + Anything else — including the historical ``user_id`` smuggling
271 + vector and any future identity-bearing keys — is dropped before
272 + the call reaches credential lookup. ``user_id`` is forwarded as a
273 + structurally separate parameter; see the module docstring for the
274 + full security model.
275 """
276 custom_tool = self.get(slug)
277 if custom_tool is None:
278 raise NotFoundError(f"Custom tool with slug {slug} not found")
243 - sanitized_request = {k: v for k, v in request.items() if k != "user_id"}
244 - return custom_tool._invoke(
279 + allowed = _allowed_request_field_names(custom_tool.request_model)
280 + sanitized_request = {k: v for k, v in request.items() if k in allowed}
281 + return custom_tool.invoke_trusted(
282 user_id=user_id or "default",
283 request_kwargs=sanitized_request,
284 )
python/tests/test_custom_tools_security.py
+173 -94
@@ -6,18 +6,20 @@ Before the fix, ``CustomTool.__call__`` extracted ``user_id`` from the same
6 ``**kwargs`` dict that carried LLM-supplied tool arguments, and
7 ``CustomTools.execute`` happily forwarded that LLM-controlled dict via
8 ``custom_tool(**request, user_id=user_id)``. An LLM (or prompt-injection
9 -input) could therefore set ``user_id`` to another tenant's identifier —
10 -either getting it forwarded into ``CustomTool.__call__`` directly or
11 -relying on Python's duplicate-kwarg ``TypeError`` to leak whose tokens
12 -were nearly looked up.
13 -
14 -The fix:
15 - * ``CustomTools.execute`` strips ``user_id`` from the LLM-supplied
16 - ``request`` dict at the trust boundary, so only the trusted, explicit
17 - ``user_id`` parameter reaches the credential lookup.
18 - * ``CustomTool.__call__`` exposes ``user_id`` as a keyword-only
19 - parameter and drops any ``user_id`` left in ``kwargs`` before the
20 - request body is validated.
9 +input) could therefore set ``user_id`` to another tenant's identifier and
10 +have ``CustomTool.__get_auth_credentials`` look up that victim's OAuth
11 +tokens.
12 +
13 +After the fix:
14 + * ``CustomTools.execute`` filters the LLM-supplied ``request`` through
15 + an *allowlist* of fields declared on the tool's Pydantic
16 + ``request_model`` — ``user_id`` and any other unexpected key are
17 + dropped before they can influence credential lookup or reach the
18 + tool's execute function.
19 + * ``CustomTool.invoke_trusted`` is the structurally separate trusted
20 + entry point; ``user_id`` cannot be smuggled inside ``request_kwargs``.
21 + * ``CustomTool.__call__`` raises ``TypeError`` if ``user_id`` appears
22 + in ``kwargs`` rather than silently using a fallback.
23 """
24
25 from unittest.mock import MagicMock
@@ -33,9 +35,9 @@ class _IssueInput(BaseModel):
35 issue_number: int = Field(description="GitHub issue number")
36
37
36 -def _make_mock_client() -> MagicMock:
37 - """Build a mock HttpClient suitable for CustomTool.__get_auth_credentials."""
38 -
38 +@pytest.fixture
39 +def mock_http_client() -> MagicMock:
40 + """Mock HttpClient that returns a single connected account on lookup."""
41 state = MagicMock()
42 state.val.model_dump.return_value = {"access_token": "trusted-token"}
43
@@ -52,144 +54,221 @@ def _make_mock_client() -> MagicMock:
54 return client
55
56
55 -def test_execute_strips_user_id_from_llm_request() -> None:
56 - """``CustomTools.execute`` MUST strip ``user_id`` from the request dict."""
57 - client = _make_mock_client()
58 - tools = CustomTools(client=client)
57 +@pytest.fixture
58 +def github_tool(mock_http_client: MagicMock) -> CustomTool:
59 + """A registered ``github`` custom tool whose handler echoes the auth token."""
60
61 def github_tool(request: _IssueInput, execute_request, auth_credentials):
62 """Fetch issue info."""
62 - return {"token": auth_credentials["access_token"]}
63 + return {
64 + "issue_number": request.issue_number,
65 + "token": auth_credentials["access_token"],
66 + }
67 +
68 + return CustomTool(f=github_tool, client=mock_http_client, toolkit="github")
69 +
70
64 - tools.register(toolkit="github")(github_tool)
71 +@pytest.fixture
72 +def custom_tools(mock_http_client: MagicMock, github_tool: CustomTool) -> CustomTools:
73 + """A ``CustomTools`` registry pre-loaded with ``github_tool``."""
74 + tools = CustomTools(client=mock_http_client)
75 + tools.custom_tools_registry[github_tool.slug] = github_tool
76 + return tools
77
66 - result = tools.execute(
67 - slug="GITHUB_GITHUB_TOOL",
78 +
79 +def test_execute_strips_user_id_from_llm_request(
80 + mock_http_client: MagicMock, custom_tools: CustomTools, github_tool: CustomTool
81 +) -> None:
82 + """``CustomTools.execute`` MUST drop ``user_id`` from the request dict."""
83 + result = custom_tools.execute(
84 + slug=github_tool.slug,
85 request={"issue_number": 1, "user_id": "victim-user"},
86 user_id="trusted-user",
87 )
88
72 - assert result == {"token": "trusted-token"}
73 - # Only the trusted, explicit user_id reaches the credential lookup.
74 - client.connected_accounts.list.assert_called_once_with(
89 + assert result == {"issue_number": 1, "token": "trusted-token"}
90 + mock_http_client.connected_accounts.list.assert_called_once_with(
91 toolkit_slugs=["github"],
92 user_ids=["trusted-user"],
93 )
94
95
80 -def test_execute_falls_back_to_default_when_user_id_missing() -> None:
81 - """If the caller forgets a trusted ``user_id``, fall back to ``"default"``.
96 +def test_execute_strips_unexpected_fields_via_allowlist(
97 + mock_http_client: MagicMock, custom_tools: CustomTools, github_tool: CustomTool
98 +) -> None:
99 + """The allowlist is durable: any non-declared key is dropped, not just user_id.
100
83 - Specifically, ``execute`` must NOT silently use the LLM-supplied
84 - ``user_id`` from ``request`` as a fallback — that would re-introduce
85 - the SEC-365 vulnerability under a different code path.
101 + Pins the allowlist behaviour so a future identity-bearing key in the
102 + auth path (``tenant_id``, ``org_id``, ``connected_account_id``, …)
103 + cannot re-introduce CWE-639 by being smuggled through ``request``.
104 """
87 - client = _make_mock_client()
88 - tools = CustomTools(client=client)
105 + captured: dict = {}
106
90 - def github_tool(request: _IssueInput, execute_request, auth_credentials):
91 - """Fetch issue info."""
107 + def echo_tool(request: _IssueInput, execute_request, auth_credentials):
108 + """Echo back the validated request."""
109 + captured["fields"] = request.model_dump()
110 return {"ok": True}
111
94 - tools.register(toolkit="github")(github_tool)
112 + tools = CustomTools(client=mock_http_client)
113 + tool = CustomTool(f=echo_tool, client=mock_http_client, toolkit="github")
114 + tools.custom_tools_registry[tool.slug] = tool
115
116 tools.execute(
97 - slug="GITHUB_GITHUB_TOOL",
98 - request={"issue_number": 1, "user_id": "victim-user"},
99 - user_id=None,
117 + slug=tool.slug,
118 + request={
119 + "issue_number": 1,
120 + "user_id": "victim-user",
121 + "tenant_id": "evil-tenant",
122 + "connected_account_id": "ca_evil",
123 + "extra_garbage": "xyz",
124 + },
125 + user_id="trusted-user",
126 )
127
102 - client.connected_accounts.list.assert_called_once_with(
128 + assert captured["fields"] == {"issue_number": 1}
129 + mock_http_client.connected_accounts.list.assert_called_once_with(
130 toolkit_slugs=["github"],
104 - user_ids=["default"],
131 + user_ids=["trusted-user"],
132 )
133
134
108 -def test_execute_does_not_mutate_caller_request_dict() -> None:
109 - """Sanitization MUST NOT mutate the caller's ``request`` dict in place."""
110 - client = _make_mock_client()
111 - tools = CustomTools(client=client)
135 +def test_execute_keeps_aliases_declared_on_request_model(
136 + mock_http_client: MagicMock,
137 +) -> None:
138 + """Aliases declared on the request model are honoured by the allowlist."""
139
113 - def github_tool(request: _IssueInput, execute_request, auth_credentials):
114 - """Fetch issue info."""
140 + class _AliasedInput(BaseModel):
141 + issue_number: int = Field(alias="issueNumber")
142 +
143 + captured: dict = {}
144 +
145 + def aliased_tool(request: _AliasedInput, execute_request, auth_credentials):
146 + """Echo back the validated request."""
147 + captured["fields"] = request.model_dump()
148 return {"ok": True}
149
117 - tools.register(toolkit="github")(github_tool)
150 + tools = CustomTools(client=mock_http_client)
151 + tool = CustomTool(f=aliased_tool, client=mock_http_client, toolkit="github")
152 + tools.custom_tools_registry[tool.slug] = tool
153
119 - request_dict = {"issue_number": 1, "user_id": "victim-user"}
154 tools.execute(
121 - slug="GITHUB_GITHUB_TOOL",
122 - request=request_dict,
155 + slug=tool.slug,
156 + request={"issueNumber": 5, "user_id": "victim"},
157 user_id="trusted-user",
158 )
159
126 - # The original dict is untouched (the SDK should not surprise the caller).
127 - assert request_dict == {"issue_number": 1, "user_id": "victim-user"}
160 + assert captured["fields"] == {"issue_number": 5}
161
162
130 -def test_call_drops_user_id_smuggled_in_kwargs_dict() -> None:
131 - """``CustomTool.__call__`` MUST ignore any ``user_id`` smuggled in kwargs.
163 +def test_execute_falls_back_to_default_when_user_id_missing(
164 + mock_http_client: MagicMock, custom_tools: CustomTools, github_tool: CustomTool
165 +) -> None:
166 + """If no trusted ``user_id`` is provided, ``execute`` MUST use ``"default"``.
167
133 - A caller might unpack a partially-trusted dict like ``tool(**llm_dict)``
134 - without realizing that the LLM controls every key in it. Before the fix,
135 - a ``user_id`` key in that dict was popped and used to look up OAuth
136 - credentials — letting an LLM read another tenant's tokens. After the fix,
137 - ``__call__`` always uses the safe ``"default"`` user_id and the smuggled
138 - value is dropped before request validation.
168 + Specifically, ``execute`` MUST NOT silently use the LLM-supplied
169 + ``user_id`` from ``request`` as a fallback — that would re-introduce
170 + SEC-365 under a different code path.
171 """
140 - client = _make_mock_client()
141 -
142 - def github_tool(request: _IssueInput, execute_request, auth_credentials):
143 - """Fetch issue info."""
144 - return {"ok": True}
145 -
146 - tool = CustomTool(f=github_tool, client=client, toolkit="github")
147 -
148 - smuggled_kwargs = {"issue_number": 1, "user_id": "victim-user"}
149 - tool(**smuggled_kwargs)
172 + custom_tools.execute(
173 + slug=github_tool.slug,
174 + request={"issue_number": 1, "user_id": "victim-user"},
175 + user_id=None,
176 + )
177
151 - client.connected_accounts.list.assert_called_once_with(
178 + mock_http_client.connected_accounts.list.assert_called_once_with(
179 toolkit_slugs=["github"],
180 user_ids=["default"],
181 )
182
183
157 -def test_invoke_uses_trusted_user_id_separate_from_request() -> None:
158 - """``_invoke`` takes ``user_id`` separately from the request dict.
184 +def test_execute_does_not_mutate_caller_request_dict(
185 + custom_tools: CustomTools, github_tool: CustomTool
186 +) -> None:
187 + """Sanitization MUST NOT mutate the caller's ``request`` dict in place."""
188 + request_dict = {"issue_number": 1, "user_id": "victim-user"}
189 + custom_tools.execute(
190 + slug=github_tool.slug,
191 + request=request_dict,
192 + user_id="trusted-user",
193 + )
194 +
195 + assert request_dict == {"issue_number": 1, "user_id": "victim-user"}
196 +
197
160 - This is the trusted internal entry point used by ``CustomTools.execute``.
161 - Even if the LLM-controlled ``request_kwargs`` happens to contain a
162 - ``user_id`` key (and somehow gets past the sanitization in ``execute``),
163 - the ``user_id`` argument here is structurally separate, so the trusted
164 - value is what reaches the credential lookup.
198 +def test_call_raises_typeerror_when_user_id_smuggled_in_kwargs(
199 + github_tool: CustomTool,
200 +) -> None:
201 + """``CustomTool.__call__`` MUST refuse a ``user_id`` kwarg loudly.
202 +
203 + Silent fallbacks expand blast radius: a tool that quietly transacts
204 + against ``"default"`` could end up using a real tenant who happens to
205 + be registered under that id. Failing fast also surfaces prompt-injection
206 + attempts instead of swallowing them.
207 """
166 - client = _make_mock_client()
208 + smuggled_kwargs = {"issue_number": 1, "user_id": "victim-user"}
209
168 - captured: dict = {}
210 + with pytest.raises(TypeError, match="user_id"):
211 + github_tool(**smuggled_kwargs)
212
170 - def github_tool(request: _IssueInput, execute_request, auth_credentials):
171 - """Fetch issue info."""
172 - captured["request"] = request
173 - return {"ok": True}
213
175 - tool = CustomTool(f=github_tool, client=client, toolkit="github")
176 - tool._invoke(user_id="trusted-user", request_kwargs={"issue_number": 7})
214 +def test_invoke_trusted_uses_explicit_user_id_over_smuggled_one(
215 + mock_http_client: MagicMock, github_tool: CustomTool
216 +) -> None:
217 + """``invoke_trusted``'s explicit ``user_id`` MUST win over a smuggled key.
218 +
219 + The auth-path argument is structurally separate from ``request_kwargs``,
220 + so an LLM-controlled ``user_id`` inside ``request_kwargs`` cannot
221 + override the trusted parameter. This pins the docstring contract.
222 + """
223 + github_tool.invoke_trusted(
224 + user_id="trusted-user",
225 + request_kwargs={"issue_number": 7, "user_id": "victim-user"},
226 + )
227
178 - client.connected_accounts.list.assert_called_once_with(
228 + mock_http_client.connected_accounts.list.assert_called_once_with(
229 toolkit_slugs=["github"],
230 user_ids=["trusted-user"],
231 )
182 - assert captured["request"].issue_number == 7
232
233
185 -def test_execute_unknown_slug_raises() -> None:
234 +def test_execute_unknown_slug_raises(custom_tools: CustomTools) -> None:
235 """Sanity check: unknown slugs still surface ``NotFoundError``."""
187 - client = _make_mock_client()
188 - tools = CustomTools(client=client)
189 -
236 with pytest.raises(NotFoundError):
191 - tools.execute(
237 + custom_tools.execute(
238 slug="DOES_NOT_EXIST",
239 request={"foo": "bar"},
240 user_id="trusted-user",
241 )
242 +
243 +
244 +def test_tools_execute_e2e_strips_user_id_through_full_stack(
245 + mock_http_client: MagicMock, custom_tools: CustomTools, github_tool: CustomTool
246 +) -> None:
247 + """End-to-end check through ``Tools.execute`` (the public SDK entry point).
248 +
249 + ``Tools._execute_tool`` routes custom-tool calls into
250 + ``CustomTools.execute``. The modifier-hook block can also overwrite
251 + ``arguments`` and ``user_id`` from a ``processed_params`` dict, so we
252 + pin that the sanitization still applies after that path.
253 + """
254 + from composio.core.models.tools import Tools
255 +
256 + provider = MagicMock()
257 + provider.name = "test"
258 +
259 + tools = Tools(client=mock_http_client, provider=provider)
260 + tools._custom_tools = custom_tools
261 +
262 + response = tools.execute(
263 + slug=github_tool.slug,
264 + arguments={"issue_number": 1, "user_id": "victim-user"},
265 + user_id="trusted-user",
266 + )
267 +
268 + assert response["successful"] is True
269 + assert response["data"]["issue_number"] == 1
270 + assert response["data"]["token"] == "trusted-token"
271 + mock_http_client.connected_accounts.list.assert_called_once_with(
272 + toolkit_slugs=["github"],
273 + user_ids=["trusted-user"],
274 + )