T09 · Insecure Skill Coding Practices
- Location
scripts/gaode_map.py:545- Finding
API Keys Exposed Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/gaode_map.py:545-546,scripts/poi_search.py:278,scripts/poi_search.py:283,scripts/poi_search.py:292, and command examples inSKILL.md:56-71
Vulnerability Type: API credential exposure through process arguments and shell history
Risk Level: MediumVulnerable Code
scripts/gaode_map.py:545-546:python ip_parser = subparsers.add_parser("ip", help="IP location") ip_parser.add_argument("--key", help="Gaode API Key (or set environment variable AMAP_API_KEY)")The same command-line option is registered for the other subcommands in this file.
scripts/poi_search.py:278,scripts/poi_search.py:283, andscripts/poi_search.py:292:python ip_parser.add_argument("--key", required=True, help="Gaode API Key") poi_parser.add_argument("--key", required=True, help="Gaode API Key") geo_parser.add_argument("--key", required=True, help="Gaode API Key")The documentation instructs users to place the credential directly in the command line:
bash python3 gaode_map.py ip --key YOUR_API_KEYTechnical Analysis
Both scripts accept the Amap API key as a command-line argument. In
scripts/poi_search.py, this method is mandatory because every available subcommand declares--keyas required. Althoughscripts/gaode_map.pyalso supports theAMAP_API_KEYenvironment variable, it continues to accept command-line credentials, and the documentation demonstrates that usage.Command-line arguments are not an appropriate transport for secrets. Depending on the operating system and runtime environment, arguments may be exposed through:
- Shell history files.
- Process inspection utilities and process metadata.
- Job schedulers, automation logs, and command auditing systems.
- Terminal recording and observability agents.
- CI/CD logs when commands are echoed.
- Wrapper scripts or error reports that record the full invocation ...[truncated 1948 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove or deprecate the
--keyoption in both scripts. -
Read the credential from
AMAP_API_KEYby default without printing or logging its value. -
Add environment-variable support to
scripts/poi_search.py, where command-line credential entry is currently mandatory. -
If interactive entry is needed, use
getpass.getpass()so the key is not echoed or stored in shell history. -
Update every example in
SKILL.mdto use environment-based invocation:bash export AMAP_API_KEY="YOUR_API_KEY" python3 gaode_map.py ip -
Ensure CI/CD systems provide the key through an encrypted secret store and mask it in logs.
-
Avoid including complete request URLs in logs because the Amap key is encoded as a URL query parameter.
-
Configure server-side key restrictions where supported, including API allowlists, quota limits, and source restrictions.
-
Rotate any key that has previously been entered through a command line or exposed in logs.
-
If backward compatibility requires temporary support for
--key, display a deprecation warning, avoid documenting it, and clearly warn that process arguments and shell history may expose the credential.
-
