Dynamic import via __import__()
Medium
- Category
- Dangerous Code Execution
- Content
# db_logger统一日志 (R14统一入口铁律) # 路径: skills/_lazy/content-qa-guard/scripts/ → parents[4]=项目根 sys.path.insert(0, str(__import__('pathlib').Path(__file__).resolve().parents[4] / "scripts")) sys.path.insert(0, str(__import__('pathlib').Path(__file__).resolve().parents[4])) # 项目根(R45修复: parents[5]→parents[4]) from mcps.shared.db_logger import get_logger logger = get_logger("content-qa-guard", source="check_compliance.py(v25.0合并)")- Confidence
- 88% confidence
- Finding
- The code prepends a computed project-root path to sys.path before importing mcps.shared.db_logger, which changes Python's module resolution order globally. If an attacker can place or influence files in that inserted path, they may cause the process to import a malicious module and achieve arbitrary code execution during startup.
