Skip to content

fix: rename CacheHandler 'input' parameter to avoid shadowing builtin - #9642

Open
Santosh Todkar (todkarsant) wants to merge 1 commit into
crewAIInc:mainfrom
todkarsant:fix/cache-handler-input-shadow
Open

Santosh Todkar (todkarsant) wants to merge 1 commit into
crewAIInc:mainfrom
todkarsant:fix/cache-handler-input-shadow

Conversation

@todkarsant

Copy link
Copy Markdown

Summary

Fixes #9336

  • Renamed the input parameter to tool_input in CacheHandler.add() and CacheHandler.read() methods to avoid shadowing Python's builtin input() function.
  • Updated all call sites across the codebase (keyword and positional arguments) to use the new parameter name.
  • Removed the TODO notes that flagged this issue.

Files changed

  • lib/crewai/src/crewai/agents/cache/cache_handler.py — parameter rename in method signatures
  • lib/crewai/src/crewai/agents/tools_handler.py — updated keyword arg
  • lib/crewai/src/crewai/agents/agent_executor.py — updated keyword args (2 call sites)
  • lib/crewai/src/crewai/tools/tool_usage.py — updated keyword args (2 call sites)
  • lib/crewai/src/crewai/utilities/agent_utils.py — updated keyword args (2 call sites)
  • lib/crewai/src/crewai/project/utils.py — updated keyword args (4 call sites)
  • lib/crewai/tests/tools/test_tool_failure.py — updated keyword args in tests

Test plan

  • Existing cache-related tests pass with the renamed parameter
  • No remaining uses of input= as a keyword argument in CacheHandler call sites

@strix-security

strix-security Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Strix Security Review

Warning

This pull request has 71 commits after the last Strix review (d9e0a81). Strix has not reviewed these changes.
Automatic review on push is off for this repository. To review the latest changes, tag @strix-security in a comment, or turn on re-review on push.

✅ No open security findings.

PR summary: Renames the `input` parameter to `tool_input` in `CacheHandler.add()`/`read()` to stop shadowing Python's builtin, and updates the keyword arguments at every in-repo call site while removing the related TODO notes.

Review summary

This PR is a mechanical signature rename: CacheHandler.add()/read() take tool_input instead of input, and every in-repo caller was updated accordingly. I reviewed all seven changed files and traced each cache read/write path into its implementation — the produced cache key (f"{tool}-{tool_input}"), the ToolFailure suppression in add(), the RWLock usage and the read/write ordering relative to tool-call hooks are all semantically unchanged, so no new caching behaviour is introduced. The cache-collision, cross-agent cache read, fuzzy tool-name match and stale cached file-content hypotheses were each investigated and rejected: the key is injective for the values actually passed, the arbitrary-key cache tool is never registered and holds its own empty handler, and the remaining behaviours are documented opt-in cache=True semantics in code the rename does not alter. No security vulnerability found in this change. Two non-security notes for the author: the test double FailureReplayingCache in lib/crewai/tests/tools/test_tool_failure.py and the cache_calls assertion in lib/crewai/tests/test_crew.py still use the old input= spelling and will fail, and since CacheHandler is exported public API, third-party keyword callers will now get a TypeError.

Ruled out (6)
  • Can two different tool calls collide in the `f"{tool}-{input}"` cache key so one call is served another call's cached output?
    Reads always pass a `sanitize_tool_name()` result (no `-` possible) and the input half is always `json.dumps(...)` starting with `{`, so the key decomposes uniquely and the handover's `add("web", "search-{}")` / `read("web-search", "{}")` pair is not constructible through any real call site.
  • Can a model-supplied key read any cached tool result in the crew-wide cache through `CacheTools.hit_cache`?
    `hit_cache` is never registered on an agent and `CacheTools` holds its own private empty `CacheHandler`, never the crew's shared one, so it cannot reach any crew cache entry.
  • With `Crew(cache=True)`, can a reused crew be served a previous kickoff's file bytes for the same file name?
    The cache read and write happen on the same Crew object held by the same operator, `read_file_tool.py` is not in the diff, and this is the documented opt-in semantics of `cache=True`, so it is same-principal staleness under an unchanged design rather than a boundary crossing this rename introduces.
  • Does the sanitised read key versus the raw write key let a call be served a different tool's cached output?
    `sanitize_tool_name` output is a fixed point, so a read key can only equal an already-normalised write key; on any hit the writer and reader resolve to the same tool, and a non-normalised write simply produces a cache miss.
  • Do the cache read before argument validation, or the 0.85 fuzzy tool-name match, let a tool execute with unvalidated arguments or bypass a tool-level control?
    A cache hit skips `invoke()` entirely so nothing executes with unvalidated arguments, every stored entry came from a previously validated invoke, and the usage-limit check plus the pre-tool-call hook gate both still run on a hit.
  • Does an unmigrated `input=` caller or a duck-typed cache handler yield a security-relevant outcome?
    All in-repo product call sites were migrated and positional callers still bind identically, so the only fallout is a `TypeError` for an out-of-tree handler using the old signature, which the attacker does not control and which cannot replay a failure or serve another call's entry.

Review 1 on this PR · d9e0a81 · requested Nov 21 14:18 UTC when the PR was opened


Reviewed by Strix
Re-run review · Configure security review settings · Try a deeper review with @strix-security /deep

@todkarsant

Copy link
Copy Markdown
Author

Vidit Ostwal (@Vidit-Ostwal) Could you review this PR when you get a chance? Thanks!

@surlymochan Nick (surlymochan) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified the rename is complete — I checked every call site rather than just the diff.

Coverage check:

  • All keyword callers are updated: agent_executor.py (read + add), tools_handler.py, project/utils.py (sync and async wrappers), tool_usage.py (_use and _ause), agent_utils.py (read + add), plus the test_tool_failure.py tests.
  • The only other cache.add/cache.read user in the repo is tests/agents/test_native_tool_hook_contract.py, which calls positionally (cache.add("lookup", key, ...)), so it is unaffected by a keyword rename and correctly untouched by this PR.
  • The cache key format f"{tool}-{tool_input}" is unchanged, so existing cached entries stay compatible; the three duplicated TODO: Rename 'input'... notes in cache_handler.py are removed along with the rename.

Pure rename, no behavior change, and the sweep confirms nothing was missed.

@todkarsant

Copy link
Copy Markdown
Author

Vidit Ostwal (@Vidit-Ostwal) Gentle bump — this PR renames the CacheHandler 'input' parameter to avoid shadowing the builtin. CI is green. Would appreciate a review when you get a chance.

This branch has not been deployed

No deployments
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.

fix: CacheHandler 'input' parameter shadows builtin

2 participants