T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/enterprise_restriction.py:255
- Finding
- API Credential Exposure Through Command-Line Arguments and Insecure Plaintext Storage<![CDATA[ ## Vulnerability Details **File Location**: `scripts/enterprise_restriction.py:70-77, 255-257`; insecure usage is also documented in `SKILL.md:29-33` **Vulnerability Type**: API credential exposure **Risk Level**: Medium ### Vulnerable Code The script accepts the API key directly from command-line arguments: ```python if args[i] == "--key" and i + 1 < len(args): cli_key = args[i + 1] i += 2 ``` It also reads the credential from a plaintext `.env` file without verifying its ownership or permissions: ```python env_file = Path(__file__).parent / ".env" if env_file.exists(): for line in env_file.read_text(encoding="utf-8").splitlines(): line = line.strip() if line.startswith("JUHE_ENTERPRISE_RESTRICTION_KEY="): val = line.split("=", 1)[1].strip().strip('"').strip("'") if val: return val ``` ### Technical Analysis Passing credentials through command-line arguments is insecure because arguments may be exposed through: - Process inspection utilities while the script is running. - Shell history files. - Terminal session recording. - CI/CD job logs and command tracing. - Endpoint monitoring and process telemetry. The alternative `.env` mechanism stores the API key in plaintext beside the script. The implementation neither enforces restrictive permissions nor checks whether the file is owned by the expected user. Depending on the system umask, the file may be readable by other local users. It may also be accidentally committed or included in archives because the reviewed project does not provide a corresponding ignore rule. The key is legitimately transmitted to the documented Juhe HTTPS endpoint as part of the declared lookup operation. No evidence indicates that it is printed in query results or sent to an unrelated destination. The issue concerns local credential handling rather than hidden network exfiltration. ### Attack Path 1. A user follows the documented usage and supplies ...[truncated 1263 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the `--key` command-line option and all documentation encouraging credentials in command arguments. 2. Prefer the existing environment-variable mechanism or an operating-system credential store. 3. If `.env` support must remain: - Require file permissions equivalent to owner read/write only. - Verify file ownership before reading it. - Reject or warn about group-readable or world-readable permissions. - Add `scripts/.env` and general secret-file patterns to `.gitignore`. - Document secure creation using a restrictive umask. 4. Avoid exposing the credential in logs, exceptions, diagnostics, or serialized output. 5. Recommend immediate key rotation if a key has previously been supplied through command-line arguments or committed to source control. 6. Limit the API key at the provider level where supported, including quota limits, endpoint restrictions, monitoring, and billing alerts. ]]>
