Impact
The GitHub Action's scan-code mode reports verified=true, verdict=VERIFIED, admission=ADMIT, zero findings and a passing badge for a Python file that calls eval, os.system, subprocess and exec. The only requirements are that the file imports them with from … import, imports them dynamically, or reaches them through getattr. The job exits 0.
File scanned:
from builtins import eval as e
from os import system
import importlib
e("1+1")
system("id")
importlib.import_module("subprocess").check_output(["id"])
getattr(__builtins__, "exec")("print(1)")
| Output | main @ b74ac00 |
Correct |
|---|---|---|
verified |
true |
false |
findings_count |
0 |
4 or more |
verdict / admission |
VERIFIED / ADMIT |
not admitted |
| exit code | 0 |
non-zero (fail_on_findings defaults to true) |
A repository that uses this mode as a required check can merge code with all four calls and show a "QWED-verified" badge for it.
Affected
The QWED-AI/qwed-verification GitHub Action, scan-code mode, through 8.0.0. Reproduced on main @ b74ac00 with INPUT_ACTION=scan-code, INPUT_PATHS=<file>.
The server's /verify/code and CodeVerifier are not affected for these forms: they flag the from builtins import eval and getattr(__builtins__, …) routes.
Reproduction
INPUT_ACTION=scan-code INPUT_PATHS=evasions.py GITHUB_OUTPUT=out.txt python action_entrypoint.py; echo "exit=$?"
grep -A1 -E '^(verified|findings_count|verdict|admission)<<' out.txt
Details
action_scan_code (action_entrypoint.py:302-366) has its own denylist instead of calling CodeVerifier:
dangerous_calls = ["eval", "exec", "compile", "__import__", "subprocess", "os.system"]. A call is matched only by its bare name (ast.Name), or by<name>.<attr>where<name>is the literal text before the dot.e(...)(an alias ofeval) andsystem(...)(imported by name) are not matched.- Only
ast.Importis checked againstdangerous_imports.ast.ImportFrom(from os import system,from builtins import eval) is never inspected. importlibis not in either list.importlib.import_module("subprocess").check_output(...)matches neither: the attribute ischeck_output, and the receiver is a call, not a name.getattr(__builtins__, "exec")(...): the outer call's func is aCall, which neither branch handles.
Patches
Fixed in 9.0.0 (649f7a6). Upgrade to 9.0.0 or later. In a workflow: uses: QWED-AI/qwed-verification@v9.0.0
- Each scanned file also goes through
CodeVerifier.verify_code, and its code- and process-execution findings (dangerous_function,dangerous_attribute,process_execution,remote_code_execution) are added to the scan. A file CodeVerifier cannot verify denies the scan. - The local import check reads
from x import yas well asimport x. getattr,setattranddelattrwith a constant name are checked as that attribute, with import aliases resolved. A computed name cannot be checked: it is reported as aDYNAMIC_ATTRIBUTEwarning (newwarnings_countoutput) that does not fail the scan.- A Python file whose coding declaration is not UTF-8, or that is not valid UTF-8, denies the scan (the same gap in
CodeVerifieris GHSA-pr6c-cqg8-6w5r). - The scope of
scan-codeis unchanged: file and network access are not findings. A pass means no known dangerous pattern was found, not that the code is safe.
On 9.0.0 the file above gives verified=false, 5 findings (lines 1, 2, 6, 7 and 8), UNVERIFIABLE / DENY and exit code 1.
