Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions kernelguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2785,6 +2785,33 @@ def detect_dynamic_execution(code: str | SubmissionFacts) -> list[dict]:
"severity": "high",
"evidence": "importlib.reload() (module state reset/manipulation)",
})
elif func_name == "operator.call" and func_name not in seen:
if node.args and isinstance(node.args[0], ast.Name):
called_name = node.args[0].id
if called_name in ("exec", "eval", "compile"):
seen.add(func_name)
matches.append({
"pattern": "DYNAMIC_EXECUTION",
"severity": "high",
"evidence": f"operator.call({called_name}, ...) — dynamic execution via operator module",
})
elif func_name == "functools.partial" and func_name not in seen:
if node.args and isinstance(node.args[0], ast.Name):
called_name = node.args[0].id
if called_name in ("exec", "eval", "compile", "__import__"):
seen.add(func_name)
matches.append({
"pattern": "DYNAMIC_EXECUTION",
"severity": "high",
"evidence": f"functools.partial({called_name}, ...) — deferred dynamic execution",
})
elif func_name in ("builtins.exec", "builtins.eval", "builtins.compile") and func_name not in seen:
seen.add(func_name)
matches.append({
"pattern": "DYNAMIC_EXECUTION",
"severity": "high",
"evidence": f"{func_name}() — dynamic execution via builtins module",
})

return matches

Expand Down