Dynamic import via __import__()
Medium
- Category
- Dangerous Code Execution
- Content
requires_consent, ) except ImportError: # 直接运行时兜底 sys.path.insert(0, str(__import__("pathlib").Path(__file__).parent.parent / "core")) from capability_errors import CapabilityError, ConsentRequired, CapabilityUnavailable from capability_registry import ( get_capability, grant_consent, is_effective_enabled, is_enabled,- Confidence
- 76% confidence
- Finding
- The fallback path mutates sys.path at runtime and then imports capability modules from that newly inserted directory. If an attacker can influence the package layout, working tree, or deployed filesystem near this script, they may be able to cause the process to import unintended Python code, leading to arbitrary code execution in the application context.
