Impact
POST /verify/code returns VERIFIED, is_valid: true and admission ADMIT for code that runs commands or destroys data, in three ways:
language |
code |
main @ d4ca8dc |
|---|---|---|
javascript |
const {exec} = require('child_process'); exec('id'); |
VERIFIED, is_valid: true, ADMIT |
java |
Runtime r = Runtime.getRuntime(); r.exec("id"); |
VERIFIED, is_valid: true, ADMIT |
sql |
DROP TABLE users |
VERIFIED, is_valid: true, ADMIT |
sql |
SELECT 1; DROP TABLE users |
VERIFIED, is_valid: true, ADMIT |
python |
secret = os.environ.get('AWS_SECRET_ACCESS_KEY') (no import) |
VERIFIED, is_valid: true, ADMIT |
python |
the same with import os (control) |
VERIFIED, is_valid: false, BLOCKED |
/verify/sql blocks both SQL statements above; the language: "sql" path of /verify/code does not use it.
Affected
qwed (PyPI) through 10.0.0. Reproduced on main @ d4ca8dc.
Reachable from:
POST /verify/code(and batch code items) withlanguagejavascript,typescript,java,goorsql, and withpythonfor names the snippet does not bind;CodeVerifier.verify_code, which the executor and the stats gates also call.
Reproduction
from qwed_new.core.code_verifier import CodeVerifier
from qwed_new.core.diagnostics import admission_decision
cases = [("javascript", "const {exec} = require('child_process'); exec('id');"),
("java", 'Runtime r = Runtime.getRuntime(); r.exec("id");'),
("sql", "DROP TABLE users"),
("python", "secret = os.environ.get('AWS_SECRET_ACCESS_KEY')"),
("python", "import os\nsecret = os.environ.get('AWS_SECRET_ACCESS_KEY')")]
for lang, code in cases:
dr = CodeVerifier().verify_code(code, language=lang)
print(lang, dr.status.value, dr.developer_fields.get("is_valid"), admission_decision(dr).value)
Details
- Other languages are judged by substring lists. For JavaScript, TypeScript, Java and Go,
CodeVerifiersearches for listed substrings (JS_CRITICALand its siblings,src/qwed_new/core/code_verifier.py:405-509) and admits when no CRITICAL entry matches (:657). A call reached through destructuring, a variable or an alias matches nothing. - SQL on
/verify/codehas its own rules. Thelanguage: "sql"path parses withpostgreshard-coded (src/qwed_new/core/code_verifier.py:1893) and applies its own checks (:1908-1953), notSQLVerifier's. - Python checks only names the snippet binds. The allowlist resolves a name through the snippet's own imports (
_chain_targets,src/qwed_new/core/code_admission.py:969-978); a name with no binding is not checked. That matters wherever names are pre-bound: the sandbox bindsnpandpd, and the stats harness bindspdanddf.
Patches
Fixed in 11.0.0. Upgrade with pip install -U "qwed>=11.0.0". /verify/code admits only code it can show safe. JavaScript, TypeScript, Java and Go are UNVERIFIABLE (code_verifier.language_unverifiable) when no listed pattern shows them unsafe, never ADMIT. SQL on /verify/code is also decided by SQLVerifier, so a write is refused. Python that reads a name it does not bind is refused; a runtime that binds names passes them with CodeVerifier(bound_names=...).
Advisory page: https://qwedai.tech/security/advisories/ghsa-7xrf-75qr-2r5w
