Skip to content

fix: reject calls without declared tools - #547

Open
TeoSlayer wants to merge 4 commits into
mlcommons:mainfrom
TeoSlayer:fix/empty-tool-list
Open

TeoSlayer wants to merge 4 commits into
mlcommons:mainfrom
TeoSlayer:fix/empty-tool-list

Conversation

@TeoSlayer

@TeoSlayer TeoSlayer commented Oct 28, 2026 •

Copy link
Copy Markdown

Reject tool calls unless their names are present in the declared tool list. The previous truthiness check treated an empty or malformed list as unrestricted, allowing undeclared model output to reach tool evaluation. Refs #391.

Regression tests cover empty and malformed declarations and a declared tool; the two rejection cases fail before the fix. Synced with upstream dependency/watchdog fixes, with session startup synchronized in the SIGINT test. Full Linux CI passes.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

MLCommons CLA bot:
Thank you very much for your submission; we really appreciate it. Before we can accept your contribution,
we ask that you sign the MLCommons CLA (Apache 2). Please submit your GitHub ID to our onboarding form to initiate
authorization. If you are from a MLCommons member organization, we will request that you be added to the CLA.
If you are not from a member organization, we will email you a CLA to sign. For any questions, please contact
support@mlcommons.org.
1 out of 2 committers have signed the MLCommons CLA.
✅ @TeoSlayer
❌ @teovl
You can retrigger this bot by commenting recheck in this Pull Request

@github-actions github-actions Bot added the size/normal PR Review Policy: <=500 non-test lines & <=20 files label Oct 28, 2026
@TeoSlayer
TeoSlayer marked this pull request as ready for review October 28, 2026 16:12
@TeoSlayer
TeoSlayer requested a review from a team October 28, 2026 16:12
@TeoSlayer

TeoSlayer commented Nov 5, 2026 •

Copy link
Copy Markdown
Author

Verified that empty/malformed tool declarations reject undeclared calls while declared tools remain valid. All CI checks pass.

@codecov-commenter

codecov-commenter commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@745ac91). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #547   +/-   ##
=======================================
  Coverage        ?   82.63%           
=======================================
  Files           ?      170           
  Lines           ?    24331           
  Branches        ?        0           
=======================================
  Hits            ?    20106           
  Misses          ?     4225           
  Partials        ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

# Conflicts:
#	tests/integration/commands/test_sigint.py
for tc in tool_calls:
name = tc["name"]
if allowed_names and name not in allowed_names:
if name not in allowed_names:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[Claude + Cursor (Grok)] high · security

The empty-list fix is right (verified in the review summary), but this check covers only the call name. #391 stays open: the argument keys from the endpoint still reach bfcl-eval's eval(), even for a declared tool.

bfcl-eval 2026.3.23 builds the eval string in convert_to_function_call (bfcl_eval/model_handler/utils.py:217):

f"{key}({','.join([f'{k}={repr(v)}' for k,v in value.items()])})"

Values go through repr(), but keys k are pasted in raw. execute_multi_turn_func_call then checks its denylist against only the text before the first ( and calls eval(func_call) (eval_checker/multi_turn_eval/multi_turn_utils.py).

Scenario: an untrusted or compromised endpoint returns a call to a tool the entry did declare, with a crafted argument key:

{"name": "ls", "arguments": "{\"a=__import__('os').system('id'),b\": 1}"}

ls passes this check. The executor receives ls(a=__import__('os').system('id'),b=1), the denylist sees ls, and eval runs os.system while evaluating the arguments. A key that never calls the tool works as well: ") if False else __import__('os').system('id') or dict(x" yields inst.ls() if False else __import__('os').system('id') or dict(x=1).

Reproducer (the real process_response, upstream's string builder copied verbatim, the executor replaced by a recorder; nothing is evaluated):

reached executor:          ls(a=__import__('os').getcwd(),b=1)
denylist sees:             ls
stored for scorer re-eval: ls(a=__import__('os').getcwd(),b=1)

The same string is stored in current_turn_results (line 267), so multi_turn_checker evaluates it a second time during scoring.

Fix (same loop, before model_responses_bfcl.append): require args to be a dict whose keys are all str.isidentifier() and not keyword.iskeyword(), and ideally also present in that tool's declared function.parameters.properties (already in state.tools); drop the call otherwise. With identifier-only keys and repr'd JSON values, the string is a literal-argument call to a declared method. Please add a test with a malicious key on a declared name, and keep "Refs #391" rather than "Fixes" until this lands.

@mlcommons-cla-bot

Copy link
Copy Markdown

MLCommons CLA bot: Thank you very much for your submission; we really appreciate it. Before we can accept your contribution, each committer needs to be covered by the MLCommons CLA (Apache 2):

  1. Sign in to MLCommons profile management.
  2. Link your GitHub account.
  3. Follow the CLA steps there. They show whether you need to sign it yourself or are covered by your organization.

1 out of 2 committers are covered by the MLCommons CLA.

Once you're covered, comment recheck in this pull request or click Re-run on the check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/normal PR Review Policy: <=500 non-test lines & <=20 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants