Public research

SimpleEval

GHSA-r2q2-xmpm-7fvh
Restricted-expression callable denylist bypass

Low · Public source snapshot: November 12, 2026

Original portfolio report · Source reference · Source reference · Source reference · Source reference · Source reference · Source reference · Upstream commit · Public advisory

Shared credits and the scope of my investigation are documented below.

GHSA-r2q2-xmpm-7fvh · SimpleEval · Low

Public security research by Charles Vosburgh (the-vibe-dev).

Field Value
Package simpleeval (PyPI)
Advisory GHSA-r2q2-xmpm-7fvh
Severity Low
Public affected range < 1.0.8
Fixed release 1.0.8
CVE None assigned
Public credit Charles Vosburgh (the-vibe-dev) — finder

Mallory can cross an application's intended expression-evaluation boundary when the application accepts her expression and has explicitly exposed Python's os module through ModuleWrapper(os) without an allowed_attrs allowlist. In SimpleEval 1.0.7, an expression such as os.spawnl reaches the real process-launch callable even though SimpleEval's defense-in-depth list is intended to reject dangerous functions. Calling a reachable member of that family with valid arguments could launch a child process with the evaluator process's privileges. This is not a default module escape, authentication bypass, or session theft: the host application must first make the broad os wrapper available to the untrusted expression.

The public advisory declares versions earlier than 1.0.8 affected and 1.0.8 patched. I reviewed the 1.0.7 and 1.0.8 release sources and ran a non-executing lookup check against both snapshots. The check returned the real os.spawnl object in 1.0.7 and raised FeatureNotAvailable in 1.0.8; I did not invoke the function or start a process. I did not inspect every historical release covered by the advisory, so 1.0.7 is the affected release directly verified here rather than a claimed first affected release.

SimpleEval evaluates a restricted subset of Python expressions. Integrators choose the objects and functions exposed through the evaluator's names and functions mappings. Python modules are blocked by default, but ModuleWrapper is an explicit opt-in mechanism for exposing a module. Its optional allowed_attrs set narrows that exposure to named attributes.

The assessed topology is therefore specific:

  • Mallory can provide an expression to an application that evaluates it with SimpleEval.
  • The application places ModuleWrapper(os) in names without restricting allowed_attrs.
  • The host operating system provides one or more os functions whose names begin with exec, spawn, or posix_spawn.
  • The evaluator process has permission to launch the target program.

The expected boundary is that an opt-in module wrapper still blocks functions in SimpleEval's dangerous-function denylist. The preferred deployment boundary is stronger: expose only the small set of attributes the application needs, and do not expose broad operating-system modules to untrusted expressions.

In simpleeval.py from 1.0.7, DISALLOW_FUNCTIONS included os.popen and os.system, but it did not include the os.exec*, os.spawn*, or os.posix_spawn* families:

DISALLOW_FUNCTIONS = {
    type,
    isinstance,
    eval,
    getattr,
    setattr,
    repr,
    compile,
    open,
    exec,
    globals,
    locals,
    os.popen,
    os.system,
}

The same release's ModuleWrapper.__getattr__ blocks private names, globally disallowed method names, and attributes excluded by an optional allowlist. When no allowlist is supplied, it returns any other public module attribute:

def __getattr__(self, name):
    if name.startswith("_"):
        raise FeatureNotAvailable(...)

    if name in DISALLOW_METHODS:
        raise FeatureNotAvailable(...)

    if self._allowed_attrs is not None and name not in self._allowed_attrs:
        raise FeatureNotAvailable(...)

    return getattr(self._module, name)

When Mallory's expression resolves os.spawnl, the wrapper returns Python's callable. The evaluator's _eval_attribute rejects a callable only if that exact object is already present in DISALLOW_FUNCTIONS. Because os.spawnl was absent from the 1.0.7 set, the attribute survived this final check. If Mallory supplies a call expression rather than the safe lookup used below, _eval_call invokes the resolved attribute with her evaluated arguments.

SimpleEval 1.0.8 closes this gap in DISALLOW_FUNCTIONS:

*(
    getattr(os, func)
    for func in dir(os)
    if func.startswith(("exec", "spawn", "posix_spawn"))
),

This platform-derived set covers the affected function families that actually exist in the running Python environment. The focused upstream change is commit 5fe0705. Release 1.0.8 also contains other security hardening, but those adjacent changes are not needed to explain this advisory's os-function gap.

The narrow verified primitive is unintended retrieval of a process-launch callable from an explicitly wrapped os module. That crosses the integrator's expectation that SimpleEval's dangerous-function list remains effective even when ModuleWrapper is used.

Turning that primitive into process execution requires all of the following:

  • the application evaluates attacker-controlled expressions;
  • it exposes ModuleWrapper(os) without a restrictive allowed_attrs set;
  • the selected os function exists on the host platform;
  • Mallory can supply arguments that satisfy that function's calling convention; and
  • the operating system permits the evaluator process to launch the requested executable.

Under those conditions, a call can run with the evaluator process's existing identity and operating-system permissions. The finding does not grant privileges beyond that process, make os reachable in a default SimpleEval configuration, or establish a remotely reachable application by itself. I did not test a process-launch call, a network service, a sandbox escape, persistence, or privilege escalation.

The strongest immediate control is configuration-based: ModuleWrapper(os, allowed_attrs={...}) prevents access to every member not explicitly needed. Removing the broad module wrapper prevents the path entirely. Upgrading to 1.0.8 adds the library-level rejection even when an affected function is encountered through a wrapper or other object path checked against DISALLOW_FUNCTIONS.

The following non-executing check asks SimpleEval to resolve os.spawnl but deliberately omits parentheses and arguments, so it never launches a child process:

import os
import sys

from simpleeval import FeatureNotAvailable, ModuleWrapper, SimpleEval

version = sys.argv[1]
evaluator = SimpleEval(names={"os": ModuleWrapper(os)})

try:
    result = evaluator.eval("os.spawnl")
    print(
        f"{version}: returned_callable={callable(result)}, "
        f"is_os_spawnl={result is os.spawnl}"
    )
except FeatureNotAvailable as exc:
    print(f"{version}: blocked={type(exc).__name__}: {exc}")

Run it once in an environment containing 1.0.7 and once after upgrading that environment to 1.0.8:

python -m pip install 'simpleeval==1.0.7'
python check_spawn_access.py 1.0.7
python -m pip install 'simpleeval==1.0.8'
python check_spawn_access.py 1.0.8

I observed:

1.0.7: returned_callable=True, is_os_spawnl=True
1.0.8: blocked=FeatureNotAvailable: This function is forbidden

The positive result establishes callable reachability in the affected snapshot; it does not claim that a process was executed. The fixed-release result shows that the same attribute lookup reaches SimpleEval's forbidden-function check. A fuller application-level regression test should also verify an allowed, harmless os attribute when one is intentionally allowlisted, so the negative result is not confused with a broken wrapper or unavailable module.

Upgrade simpleeval to 1.0.8 or later. The shipped fix enumerates the platform's os attributes and adds every callable family beginning with exec, spawn, or posix_spawn to DISALLOW_FUNCTIONS.

Independently of the package version, avoid exposing os as a broad module wrapper. If an application has a genuine need for a narrow helper, prefer a purpose-built wrapper with validated arguments. If ModuleWrapper is necessary, supply a minimal allowed_attrs set:

from simpleeval import ModuleWrapper, SimpleEval
import os.path

evaluator = SimpleEval(
    names={
        "path": ModuleWrapper(os.path, allowed_attrs={"basename", "dirname"})
    }
)

Regression coverage should enumerate the os attributes available on each supported platform and verify that all exec*, spawn*, and posix_spawn* members are rejected when reached through ModuleWrapper. Tests should cover attribute lookup and attempted invocation, direct registration in functions, a harmless explicitly allowlisted attribute, and a configuration without module exposure.

GHSA-r2q2-xmpm-7fvh affects SimpleEval versions publicly identified as earlier than 1.0.8. In the directly reviewed 1.0.7 release, an application that exposed ModuleWrapper(os) without allowed_attrs allowed an untrusted expression to retrieve os process-launch functions that were missing from DISALLOW_FUNCTIONS. The safe validation reached the real os.spawnl callable but did not execute it. Version 1.0.8 dynamically blocks the available exec, spawn, and posix_spawn families; applications should still expose only narrowly allowlisted helpers.

References

Credit

The advisory credits me (the-vibe-dev) as finder. The 1.0.8 source also credits me for reporting and testing dangerous functions in os.

Responsible use

This report documents a publicly disclosed issue for remediation, regression testing, and authorized security assessment. Do not test expressions against systems without explicit permission.