LightAgent icon indicating copy to clipboard operation
LightAgent copied to clipboard

Responsible Disclosure: Sandbox Escape in the Built-in Python Executor

Open rdoromaljr opened this issue 3 months ago • 6 comments

Dear LightAgent maintainers,

We are a security research team and we are writing to responsibly disclose a potential high-severity vulnerability we identified in Python Executor. Affected versions from v0.9.7, v0.10.0 (and likely all prior versions).

LightAgent includes a built-in tool that lets the agent execute Python code expressions which is intended for safe math and logic operations. The tool applies two sandbox layers: an AST node blocklist and a string-based import deny-list.

Both layers are independently bypassable. The AST blocklist does not cover all node types that can reach dangerous builtins, and the string-based deny-list can be evaded through runtime string construction (e.g. character concatenation). As a result, an attacker who can influence the agent's tool-call arguments can escape the sandbox and execute arbitrary operating system commands as the server user.

No authentication is required to invoke the tool.

How it works

The executor is designed to allow safe expressions such as arithmetic calculations while preventing access to dangerous modules like os, subprocess, and system. In practice:

  • The AST checker blocks explicit Import and Attribute nodes for a hard-coded set of module names.
  • A secondary string checker rejects literal module names before the code reaches the evaluator.

The problem is that these are deny-list approaches. Python's object introspection model makes it possible to reach the same dangerous built-ins through paths the block list does not recognize:

  • Not every dangerous module is on the deny-list (e.g., posix).
  • The string checker inspects only literal source tokens and it does not evaluate runtime-built strings.
  • The AST checker covers Import and Attribute nodes but does not cover Subscript dispatch (module.__dict__[key]), which provides an alternative route to the same built-ins.

Because the sandbox relies on rejecting known-bad patterns rather than allowing only known-good ones, a single unlisted path is sufficient to bypass it completely.

Impact

  • Full remote code execution as the LightAgent server user.
  • No authentication required - the tool is callable by any agent session.
  • Any deployment where user input can reach the agent's tool-call arguments is exploitable.

Suggested Direction for a Fix

The most robust fix is to move from a deny-list to an AST allowlist. Instead of rejecting known-dangerous node types, compile only expressions whose nodes are exclusively from a safe set (e.g., BinOp, UnaryOp, Constant, Name, arithmetic operators). Any expression containing a node outside that set should be rejected before evaluation.

Alternative approaches include ast.literal_eval for literal-safe contexts or delegating math expressions to a purpose-built library such as simpleeval.

I have already sent the full disclosure, PoC, and suggested fix to your team at [email protected]. I am opening this issue to document the report publicly and provide a reference point for coordinated disclosure.

Best regards

rdoromaljr avatar Sep 02 '26 13:09 rdoromaljr

Thank you for the responsible disclosure. We have triaged this report as a P0 security issue and are reviewing the built-in Python Executor boundary and the claimed impact.

Because the report is public, please do not add further proof-of-concept payloads, bypass details, credentials, or deployment-specific information to this issue. Our security policy requests private vulnerability reports through GitHub Security Advisories: https://github.com/wanxingai/LightAgent/security/advisories/new

We will reproduce the report in an isolated environment, determine the affected configurations and version range, and assess whether the issue is in LightAgent, a deployment configuration, or an upstream/runtime boundary before making a patched-version statement. The existing memory-security work tracked in #39 is a separate issue; this report will be handled as the Python Executor security track.

wxai-space avatar Sep 04 '26 08:09 wxai-space

Post-release security status update:

LightAgent v0.10.1 shipped the framework-level remediation in #101. Arbitrary Python execution tools are no longer registered on LightAgent by default. Basic arithmetic and data-only expressions now use a bounded AST allowlist through safe_expression. Model-triggered use of the legacy arbitrary Python tools requires explicit enable_unsafe_python=True opt-in and an explicitly mounted SandboxProvider; otherwise the runtime fails closed with LA-SANDBOX. The documentation also states that the legacy executor is a controlled subprocess, not a security sandbox.

These changes remove the reported unsafe default tool-registration path. We are keeping this public issue open while the private security-advisory workflow confirms the affected configuration and version range, reporter attribution, and whether any additional deployment guidance is required. We will not publish exploit details here.

The issue has completed initial triage, so the needs-triage label is being removed.

wxai-space avatar Sep 14 '26 02:09 wxai-space

Hi @wxai-space, two follow-ups on this report:

Residual sandbox weakness in v0.10.1 / v0.10.2

I verified the v0.10.1 remediation (PR #101) and confirm the unsafe default tool-registration path is removed, the fail-closed LA-SANDBOX gating works as described, and safe_expression is the only executor registered by default. That resolves the reported issue for default deployments.

However, during verification I found that the legacy executor's own input validation has not changed: when enable_unsafe_python=True is set with a SandboxProvider mounted, the same bypass I disclosed (verified in v0.9.7–v0.10.0) still achieves arbitrary command execution in both v0.10.1 and v0.10.2. The deny-list gaps remain (unlisted modules and dynamic dispatch paths the AST checker does not cover).

I'd suggest either shipping an AST allowlist in the legacy executor or explicitly documenting it as a non-security boundary in the enable_unsafe_python docs, happy to re-verify whatever direction you choose.

Private advisory channel still unavailable

I still cannot access https://github.com/wanxingai/LightAgent/security/advisories/new, it returns 404 while logged in, though the new SECURITY.md links to it. Could you confirm Private Vulnerability Reporting is enabled? I have the full PoC, affected version range, and patch-verification results ready to submit as soon as the channel is reachable. Alternatively, if you'd prefer, I can send the details by reply to the email thread already opened with [email protected].

Thanks again for the fast triage and the v0.10.1 fix.

rdoromaljr avatar Sep 17 '26 13:09 rdoromaljr

Private Vulnerability Reporting is now enabled. Please retry the repository's Security Advisories submission page and keep reproduction details private. We are keeping this issue open pending coordinated disclosure.

wxai-space avatar Sep 30 '26 17:09 wxai-space

Private advisory submitted, thank you for enabling PVR.

rdoromaljr avatar Oct 05 '26 13:10 rdoromaljr

Thank you. We have located the private advisory submission and started the maintainer review. Further technical verification and version/configuration scoping will stay in the private disclosure workflow. This public tracker remains open pending coordinated validation; no additional reproduction details are needed here.

wxai-space avatar Oct 28 '26 01:10 wxai-space