T09 · Insecure Skill Coding Practices
- Location
scripts/dataworks_diagnose.py:91- Finding
Alibaba Cloud AccessKey Secret Exposed Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Locations:
scripts/dataworks_diagnose.py:66-67scripts/dataworks_diagnose.py:91-94scripts/fetch_instance_log.py:167-168scripts/fetch_instance_log_sdk.py:155-156README.md:149-152SKILL.md:223-224
Vulnerability Type: Command-line credential exposure
Risk Level: HighVulnerable Code
scripts/dataworks_diagnose.py:66-67:python parser.add_argument("--access-key", help="Access Key ID") parser.add_argument("--access-secret", help="Access Key Secret")scripts/dataworks_diagnose.py:91-94:python if args.access_key: fetch_args.extend(['--access-key', args.access_key]) if args.access_secret: fetch_args.extend(['--access-secret', args.access_secret])scripts/fetch_instance_log.py:167-168:python parser.add_argument("--access-key", help="Access Key ID") parser.add_argument("--access-secret", help="Access Key Secret")scripts/fetch_instance_log_sdk.py:155-156:python parser.add_argument("--access-key", help="Access Key ID") parser.add_argument("--access-secret", help="Access Key Secret")The documentation also explicitly recommends passing the secret in the command line:
bash python3 scripts/dataworks_diagnose.py INSTANCE_ID \ --access-key LTAI5t... \ --access-secret xxxxxxTechnical Analysis
Secrets placed in command-line arguments can be exposed through shell history, process inspection utilities, endpoint monitoring software, diagnostic reports, audit logs, and process telemetry. The all-in-one script further forwards the secret to a child Python process by including it in
subprocess.run()'s argument list.Although the subprocess is invoked with a list and is therefore not vulnerable to shell metacharacter injection, the AccessKey Secret remains visible in the parent command and child process argument vectors. This behavior is unnecessary because t ...[truncated 1406 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the
--access-secretoption from all scripts and documentation. - Prefer the official Alibaba Cloud credential-provider chain, RAM roles, workload identity, or short-lived Security Token Service credentials.
- Avoid passing credentials from the orchestration script to a child process. Let the child SDK resolve credentials directly from a secure provider.
- If manual entry is required, use
getpass.getpass()so the secret is not echoed or stored in an argument vector. - Avoid long-lived primary-account AccessKeys and require a narrowly scoped RAM identity.
- Update examples in
README.mdandSKILL.mdto prohibit command-line secrets explicitly. - Rotate any credentials that may previously have been supplied through command-line arguments or recorded in shell history.
- Remove the
