Skip to content

fix: address default execution tier security posture - #1271

Merged
AngeloDanducci merged 4 commits into
generative-computing:mainfrom
AngeloDanducci:ad-1232
Jun 17, 2026
Merged

AngeloDanducci merged 4 commits into
generative-computing:mainfrom
AngeloDanducci:ad-1232

Conversation

@AngeloDanducci

Copy link
Copy Markdown
Contributor

Pull Request

Issue

Fixes #1232

Description

adds additional warning and handling around python tool sandboxing and default security

Testing

  • Tests added to the respective file if code was changed
  • New code has 100% coverage if code was added
  • Ensure existing tests and github automation passes (a maintainer will kick off the github automation when the rest of the PR is populated)

Attribution

  • AI coding assistants used

Adding a new component, requirement, sampling strategy, or tool?

If your PR adds or modifies one of the types below, check the matching box. A checklist of type-specific review items will be posted as a comment.

  • Component
  • Requirement
  • Sampling Strategy
  • Tool

NOTE: Please ensure you have an issue that has been acknowledged by a core contributor and routed you to open a pull request against this repository. Otherwise, please open an issue before continuing with this pull request.

@AngeloDanducci
AngeloDanducci requested a review from a team as a code owner June 15, 2026 22:03
@github-actions github-actions Bot added the bug Something isn't working label Jun 15, 2026

@markstur markstur left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI fail and I started a review which probably explains the CI fail.

Location: test/stdlib/tools/test_python_tool.py:546-564
Issue: Test test_python_tool_packages_plus_filesystem_policy_warns_once expects 1 warning during python_tool() call, but the warning is emitted during CapabilityPolicy construction (line 552), which happens before the warning capture context starts (line 553).
Fix needed: Wrap the CapabilityPolicy construction in the warning capture context:
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
policy = CapabilityPolicy(filesystem_read_roots=[Path("/tmp")])
python_tool(tier="local_unsafe", packages=["numpy"], policy=policy)

Signed-off-by: AngeloDanducci <[email protected]>
@AngeloDanducci
AngeloDanducci requested a review from markstur June 16, 2026 16:31

@psschwei psschwei left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

did we fix this part of the issue?

  1. Example and documentation framing
    The python_tool_example.py docstring describes local_unsafe as chosen "so no Docker daemon is required", framing the tier as a deployment convenience rather than a trust decision. The tools README recommends using code_interpreter for untrusted code but uses local_code_interpreter with an LLM in the quickstart example.

Signed-off-by: AngeloDanducci <[email protected]>
@AngeloDanducci

Copy link
Copy Markdown
Contributor Author

The docstring in python_tool_example.py was updated, but I did not change the tools README to use the non local version.

Should be fixed 👍

@psschwei

Copy link
Copy Markdown
Contributor

Filed #1277 to migrate the remaining docs/examples (interpreter_example.py, tools-and-agents.md, and a second pass on the README touched here) off the deprecated code_interpreter/local_code_interpreter helpers to python_tool. Keeping it out of this PR since the migration touches tool-name semantics (uses_tool needs the name string, not the MelleaTool object) and is broader than this PR's security-posture scope.

# Warn once at construction time when the caller passed a policy on a local tier
# whose boolean restriction fields are unenforced — do this before any replace()
# so the warning fires exactly once and points at the python_tool() call site.
if policy is not None and resolved_tier in _LOCAL_TIERS:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: this only warns when a policy is explicitly passed — tier="local" with no policy uses the equally-unenforced LOCAL_POLICY silently. A one-line docstring note that default local-tier policies are also unenforced might close that gap.

Comment thread mellea/stdlib/tools/interpreter.py Outdated
from mellea.stdlib.tools import python_tool

tool = python_tool(packages=["matplotlib", "numpy"])
tool = python_tool(tier="local_unsafe", packages=["matplotlib", "numpy"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: since the PR is about nudging conscious trust decisions, a short inline comment here (e.g. # explicit unsafe local execution) would keep copy-pasters from treating unsandboxed exec as the blessed default.

Signed-off-by: AngeloDanducci <[email protected]>
@AngeloDanducci
AngeloDanducci enabled auto-merge June 17, 2026 18:02
@AngeloDanducci
AngeloDanducci added this pull request to the merge queue Jun 17, 2026
Merged via the queue into generative-computing:main with commit 85c447e Jun 17, 2026
9 checks passed
@AngeloDanducci
AngeloDanducci deleted the ad-1232 branch June 17, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security posture of python_tool(): default execution tier and unenforced CapabilityPolicy fields

3 participants