Dynamic builtin resolution bypasses detection(malicious skill example that bypasses this static detection model)
Summary
The scanner detects direct use of exec(), but misses the same execution behavior when the function is resolved dynamically through getattr().
Original:
import base64
decrypted_data = base64.b64decode('just a test')
exec(decrypted_data.decode('utf-8'))
Result:
HIGH: AST1 - exec() call detected
Confidence: 85%
Variant:
import base64
import builtins
decrypted_data = base64.b64decode('just a test')
_runner = getattr(builtins, ''.join(['e','x','e','c']))
_runner(decrypted_data.decode('utf-8'))
Result:
LOW: AST7 - Dynamic attribute access via getattr()
Confidence: 50%
Expected Behavior
The variant should still trigger the high-severity exec() finding because the dynamically constructed attribute resolves to builtins.exec.
Impact
Dynamic builtin resolution downgrades the finding from HIGH arbitrary code execution to a generic LOW getattr() warning.
Suggested Fix
Add constant folding and builtin resolution for getattr() calls, including statically constructed names such as ''.join(['e','x','e','c']).
I'll work on this. Could you assign it to me?
I'll pin a regression test (or stabilize the flake) and keep the change small.
I'll work on this. Could you assign it to me?
I'll pin a regression test (or stabilize the flake) and keep the change small.
Hi, I don't have permission to assign this issue. Could you please self‑assign it if you have access? Alternatively, feel free to open a PR directly to address this problem. @modelpath-dev
Implementation is in progress in PR #544, which adds joined reflective-execution sink detection for the reported dynamic-builtin path. Keeping this issue open until the PR merges and the PoC is verified on main.
Resolution verification: PR #544 merged and automatically closed this issue. Constant construction of reflective getattr sink names, including joined strings, is now resolved for AST9 detection. The behavioral-AST regressions pass on main at 94f5cc8.
This supersedes the earlier in-progress comment. The fix covers the supported statically resolvable construction, not arbitrary runtime execution. It is merged on main but not yet in the latest published release, v2.11.2.