T08 · Insecure Dependencies
- Location
scripts/ccpa-check.py:9- Finding
Undeclared Parent-Directory Python Import Enables Dependency Hijacking
- Content
View full analysis
Vulnerability Details
File Location:
scripts/ccpa-check.py:9-12
Vulnerability Type: Dependency confusion through an untrusted Python import path
Risk Level: HighVulnerable Code
python import sys import os # Ensure compliance_core can be imported sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..')) from compliance_core import UnifiedCLI, CheckEngine, CheckResult, SeverityThe imported
compliance_corepackage is not included in the audited project, while the code explicitly prepends the project's grandparent directory to Python's module search path. Because the inserted directory has the highest import priority, a package namedcompliance_corelocated there will be selected before packages from ordinary trusted locations.Python executes package initialization code during import. Therefore, importing a malicious or compromised
compliance_corepackage can execute arbitrary Python code before the CCPA checker performs its intended operation.This behavior also contradicts the project's repeated claims that it has no external dependencies and uses only the Python standard library. The bundled security checker invokes
ccpa-check.py --help, so running the security check can trigger the same external import.Technical Analysis
Python resolves modules by searching directories in
sys.pathin order. Callingsys.path.insert(0, ...)gives the selected grandparent directory precedence over the standard import locations. The code does not verify:- The origin or canonical path of
compliance_core. - The integrity or expected version of the package.
- Whether the package is part of a trusted installation.
- Whether the parent directory is writable by another user, process, installer, or extracted archive.
An attacker who can place a matching package in that directory can define malicious behavior in
compliance_core/__init__.py. That behavior runs immediately w ...[truncated 1938 chars]- The origin or canonical path of
- Remediation
View remediation
Remediation Suggestions
-
Remove the parent-directory path modification
- Delete the
sys.path.insert(0, ...)statement. - Do not search directories outside the audited package with elevated import priority.
- Delete the
-
Bundle the required component
- Include
compliance_corewithin the Skill's audited source tree. - Use explicit package-relative imports so module resolution cannot escape the package boundary.
- Include
-
Declare and pin the dependency if it must remain external
- Publish it through a trusted package source.
- Pin an exact version and cryptographic hashes.
- Document it accurately in
requirements.txt,package.json,README.md, andSKILL.md. - Remove the inaccurate “zero external dependencies” and “standard library only” claims.
-
Verify dependency provenance
- Resolve the imported module's canonical path and reject modules outside an approved installation directory.
- Validate package signatures or hashes before execution.
- Review and audit the external component as part of every release.
-
Harden deployment
- Install the Skill and its dependencies in directories that are not writable by untrusted users.
- Run it under a dedicated, least-privileged account.
- Avoid running the checker with administrator or root privileges.
-
Correct the security checker
- Ensure its functional test does not execute unaudited external imports.
- Make the checker report missing or externally resolved runtime components as a security failure rather than treating successful execution as evidence of safety.
-
