T08 · Insecure Dependencies
- Location
SKILL.md:27- Finding
Unpinned Third-Party SDK Executes with Access to API Credentials
- Content
View full analysis
= 3.9) ``` ```python def get_client(api_key: Optional[str] = None, timeout: Optional[float] = None): key = api_key or os.environ.get(ENV_VAR) if not key: fail( f"{ENV_VAR} is not set. Get a free key (400 credits + 100/day, no card) " "at https://magichour.ai/developer" ) try: from magic_hour import Client except ImportError: fail("magic_hour SDK not installed. Run: pip install magic_hour") kwargs: Dict[str, Any] = {"token": key} if timeout is not None: kwargs["timeout"] = timeout return Client(**kwargs) ``` ### Technical Analysis The installation instructions retrieve the latest available `magic_hour` package without pinning a reviewed version or verifying an integrity hash. Python packages can run arbitrary code during installation and import. The imported package is also explicitly given the value of `MAGIC_HOUR_API_KEY`. The project identifies the package as the official SDK, and the audit found no evidence that the currently published package is malicious. Nevertheless, the absence of version and integrity controls creates a supply-chain trust gap: a compromised maintainer account, malicious replacement release, or unexpectedly incompatible future release could change the code executed by this Skill after its source has been reviewed. ### Attack Path 1. An attacker compromises the package publication process or publishes a malicious future release through the trusted package channel. 2. A user follows the documented `pip install mag ...[truncated 1001 chars]- Remediation
View remediation
``` 2. Maintain a lock file containing cryptographic hashes and install with hash verification, such as: ```bash python3 -m pip install --require-hashes -r requirements.txt ``` 3. Record the package version tested by the project and update it only after reviewing release notes, package provenance, and dependency changes. 4. Prefer an isolated virtual environment or restricted container rather than installing into a privileged or shared Python environment. 5. Avoid running package installation as root or with `sudo`. 6. Restrict the API key to the minimum account permissions available, rotate it if dependency compromise is suspected, and avoid exposing unrelated secrets to the process. 7. Add automated dependency scanning and provenance verification to the release process. ]]>
