T09 · Insecure Skill Coding Practices
- Location
scripts/import_trip.py:166- Finding
TripClaw API Key Exposed Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/import_trip.py:166-170, with insecure usage documented atSKILL.md:116
Vulnerability Type: Command-line credential exposure
Risk Level: MediumVulnerable Code
scripts/import_trip.py:166-170:python parser.add_argument( "--api-key", "-k", type=str, help="TripClaw API Key(未指定则从 TRIPCLAW_API_KEY 环境变量读取)" )The resulting argument is selected as the authentication credential at
scripts/import_trip.py:181-182:python # 获取 API Key api_key = args.api_key or get_api_key()SKILL.md:116explicitly recommends passing the credential through this option:bash python3 scripts/import_trip.py --api-key "$TRIPCLAW_API_KEY" --data '<trip-json-data>'Technical Analysis
Command-line arguments are commonly observable through local process-inspection interfaces, administrative monitoring systems, endpoint telemetry, audit records, diagnostic tools, and process launch logs. When the shell expands
$TRIPCLAW_API_KEY, the plaintext bearer token becomes part of the process argument vector.This exposure is unnecessary because the script already supports retrieving the credential directly from the
TRIPCLAW_API_KEYenvironment variable. Supporting and documenting--api-keytherefore increases credential exposure beyond the minimum required for the declared trip synchronization functionality.The affected credential is transmitted to the documented TripClaw endpoint as a bearer token. The network transmission itself is necessary for the declared functionality and uses HTTPS; the vulnerability concerns how the credential is supplied locally, not its intended transmission to TripClaw.
Attack Path
- A user follows the documented example and invokes the script with
--api-key "$TRIPCLAW_API_KEY". - The shell expands the environment variable and places the plaintext API key in the Python process argume ...[truncated 1265 chars]
- A user follows the documented example and invokes the script with
- Remediation
View remediation
Remediation Suggestions
-
Remove the
--api-keyand-kcommand-line options fromscripts/import_trip.py. -
Retrieve the credential exclusively from
TRIPCLAW_API_KEYor an operating-system secret manager. -
If interactive credential entry is required, use Python's
getpass.getpass()so the token is not echoed or placed in the process argument vector. -
Replace the documented command with one that does not include the credential:
bash export TRIPCLAW_API_KEY="your-api-key-here" python3 scripts/import_trip.py --data '<trip-json-data>' -
Retrieve the API key only after the
--validate-onlybranch. Offline validation does not require authentication, so reading a secret in that execution path exceeds minimum privilege. -
Avoid printing, logging, or including the credential in exceptions and diagnostic output.
-
Advise users who previously supplied the key through command-line arguments to review relevant process telemetry or shell tooling and rotate the key if exposure is suspected.
-
