QWED

Type to search pages, engines and advisories.

    Looking for API details?Search the docs

    Security·Advisories·GHSA-qrp4-p44j-m484

    CodeVerifier admits shell commands reached through the module loader (__loader__.load_module('posix').system)

    highFixed in 9.0.0GHSA-qrp4-p44j-m484 · Published 6 November 2026

    Impact

    CodeVerifier.verify_code returns VERIFIED, is_valid: true and admission ADMIT for Python that runs a shell command through the module loader object every module has. POST /verify/code returns the same verdict.

    code main @ b74ac00 Correct
    __loader__.load_module('posix').system('id') VERIFIED, is_valid: true, ADMIT unsafe (runs id)
    __spec__.loader.load_module('posix').system('id') VERIFIED, is_valid: true, ADMIT unsafe
    import os; os.system('id') (control) VERIFIED, is_valid: false, BLOCKED correct

    __loader__ is the module's BuiltinImporter/SourceFileLoader. load_module('posix') returns the posix module, so the call is os.system without an import statement or a name the denylist knows.

    The false verdict is in the result: CodeGuard and the sandbox's own pattern check do block .system, so QWED does not run this code itself. A caller that gates execution on /verify/code's admission would.

    Affected

    qwed (PyPI) through 8.0.0. Reproduced on main @ b74ac00.

    Reachable from:

    • POST /verify/code;
    • the CodeVerifier.verify_code Python API.

    Reproduction

    from qwed_new.core.code_verifier import CodeVerifier
    from qwed_new.core.diagnostics import admission_decision
    
    cv = CodeVerifier()
    for code in ["__loader__.load_module('posix').system('id')",
                 "__spec__.loader.load_module('posix').system('id')",
                 "import os\nos.system('id')"]:
        dr = cv.verify_code(code, language="python")
        print(repr(code), dr.status.value, dr.developer_fields.get("is_valid"), admission_decision(dr).value)
    

    Details

    • src/qwed_new/core/code_verifier.py:313: PYTHON_DANGEROUS_ATTRS does not list __loader__, __spec__, loader or load_module.
    • The checks that catch os.system look for a module the snippet imported or a known dangerous name. __loader__ is neither: it is a module global that needs no import, and load_module takes the module name as a string.
    • The same class as GHSA-4phf-6h72-9xfg and GHSA-jrxf-9jh4-86w7 (a dangerous capability reached through an object the denylist does not model).

    Patches

    Fixed in 9.0.0 (4cd0574). Upgrade to 9.0.0 or later.

    • __loader__ and __spec__ are dangerous attributes.
    • The loader methods and import-system internals that return a module by name (load_module, create_module, module_from_spec and the importlib bootstrap functions and modules) are refused wherever they appear: called or not, as an attribute, an import or alias, or a string.
    • pkgutil.resolve_name and pydoc.locate are refused, with import aliases resolved.
    • Any read of sys.modules is refused, not only a subscript (sys.modules.get(...), from sys import modules).

    On 9.0.0 both rows of the table above are VERIFIED, is_valid: false, BLOCKED (dangerous_attribute, dangerous_function).

    All advisories