Skip to content

Conversation

@wjayesh
Copy link
Contributor

@wjayesh wjayesh commented Sep 3, 2025

Fix: Require explicit user_id for toolkit-backed custom tools

Summary

Removes unsafe default-fallback behavior in custom tool execution and clarifies CrewAI integration patterns.

Changes

Security fix in python/composio/core/models/custom_tools.py:

  • Removed silent fallback to "default" in CustomTool.__call__
  • Now raises ValueError("user_id is required when invoking toolkit-backed custom tools") when user_id is missing
  • Normal (prebuilt) tools unchanged

Problem solved

  • Security risk: Custom tools silently used "default" user when user_id was omitted, potentially accessing wrong connected accounts

Breaking change

  • Toolkit-backed custom tools now require explicit user_id
  • Migration: Always pass user_id in composio.tools.get(user_id=...) calls

Files changed

  • python/composio/core/models/custom_tools.py - Enforce explicit user_id, remove default fallback

Note

Enforces explicit user_id for toolkit-backed custom tools and raises an error if missing, removing the previous "default" fallback.

  • Core:
    • Custom tools (python/composio/core/models/custom_tools.py):
      • In CustomTool.__call__: remove fallback to "default" for user_id.
      • Require user_id when toolkit is set; raise ValueError if omitted.

Written by Cursor Bugbot for commit 444bfb9. This will update automatically on new commits. Configure here.

@wjayesh wjayesh requested a review from haxzie as a code owner September 3, 2025 13:52
"""Call the custom tool."""
user_id = kwargs.pop("user_id", None) or "default"
user_id = kwargs.pop("user_id", None)
# For toolkit-backed custom tools, an explicit user_id is required to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it a mandatory field while calling custom tools?

Sushmithamallesh

This comment was marked as duplicate.

Copy link
Contributor

@Sushmithamallesh Sushmithamallesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Thank you for the update! This PR modifies the behavior in CustomTool calls to require an explicit user_id when invoking toolkit-backed custom tools, instead of defaulting to 'default' if a user_id is not provided. This change improves safety by preventing unexpected account usage.


Pros:

  • Eliminates the risk of unintentionally using the default account for sensitive tool executions.
  • Raises clear exceptions when required parameters are missing, improving robustness.

Suggestions:

  • Consider adding or updating unit tests for this path to ensure that the ValueError is raised in the correct scenario and that backwards compatibility is maintained where expected.
  • Add a note to the relevant documentation (or docstrings) about this breaking change, especially if there are scripts or clients that might rely on the previous default behavior.

I will leave inline comments for specific lines below.

Sushmithamallesh

This comment was marked as off-topic.

@haxzie haxzie closed this Oct 7, 2025
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.

4 participants