T09 · Insecure Skill Coding Practices
- Location
scripts/express_query.py:433- Finding
API Credentials Exposed Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/express_query.py:433-436
Related Documentation:SKILL.md:38-49
Vulnerability Type: Sensitive credential exposure through process arguments
Risk Level: MediumVulnerable Code
python parser.add_argument("--numbers", required=True, help="快递单号列表,逗号分隔(格式:单号:手机尾号,如 SF123456:6553)") parser.add_argument("--platform-id", required=True, help="平台ID (PlatformID)") parser.add_argument("--member-id", required=True, help="会员ID (MemberID)") parser.add_argument("--api-key", required=True, help="API密钥 (APIKey)")The documented invocation also directs users to place these credentials directly in the command:
bash python scripts/express_query.py --numbers 123456,789012 --platform-id xxx --member-id xxx --api-key xxxTechnical Analysis
The script requires the platform ID, member ID, and API key to be supplied as command-line arguments. Command-line arguments are not an appropriate secret-delivery mechanism because they may be exposed through:
- Shell history files.
- Process inspection utilities and operating-system process metadata.
- Agent execution transcripts, command logging, telemetry, or audit logs.
- Debug output from orchestration systems.
- CI/CD job definitions and retained build logs.
Although the script does not print the API key directly, the secret is exposed before the process begins because it forms part of the invocation. The API key is subsequently used to generate the request signature. The network request does not directly transmit the raw API key, but that does not mitigate local command-line disclosure.
Attack Path
- A user or agent follows the instructions in
SKILL.mdand invokes the script with a real API key using--api-key. - The full invocation is retained in shell history, agent logs, process metadata, telemetry, or an automation record.
- An attacker with access to one of those local rec ...[truncated 1135 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove the
--api-keycommand-line option as the primary secret-delivery mechanism. -
Read the API key from a protected environment variable or a dedicated secret manager. For example:
python import os api_key = os.environ.get("XDCCY_API_KEY") if not api_key: parser.error("XDCCY_API_KEY must be configured securely") -
For interactive use, support hidden input through
getpass.getpass()so the key is not echoed or stored in shell history. -
If a configuration file is supported, require restrictive file permissions and ensure the file is excluded from source control.
-
Update
SKILL.mdexamples so that no credential is placed directly in a command. Document secure environment-variable or secret-manager setup instead. -
Redact all credentials from agent transcripts, telemetry, exception reports, and debug logs.
-
Prefer passing only the less-sensitive platform and member identifiers as arguments; keep the API key exclusively in protected secret storage.
-
Rotate credentials that may previously have appeared in command history or retained execution logs.
-
