Dynamic import via __import__()
Medium
- Category
- Dangerous Code Execution
- Content
def _extract_root_domain(domain: str) -> str: """Extract root domain from full domain (strip subdomain prefix).""" # Use dns_common's splitting logic sys.path.insert(0, str(__import__("pathlib").Path(__file__).parent)) try: from dns_common import split_domain candidates = split_domain(domain)- Confidence
- 79% confidence
- Finding
- The code mutates sys.path at runtime and then imports dns_common from that injected path, which can create a module-hijacking surface if an attacker can influence the filesystem contents of the script directory. While this is often done for local package convenience, it weakens import trust boundaries and can cause unintended code execution from a spoofed module.
