T09 · Insecure Skill Coding Practices
- Location
scripts/quake_batch_cli.py:85- Finding
Quake API Key Exposed Through Process Arguments and Error Messages
- Content
View full analysis
Vulnerability Details
File Location:
scripts/quake_batch_cli.py:85-93, 143-147, 270, 341-342, 431-432
Related Documentation:SKILL.md:23, 60, 63;scripts/README.md:25
Vulnerability Type: API credential exposure through command-line arguments and unredacted errors
Risk Level: MediumVulnerable Code
python def run_quake(args: List[str], quake_bin: Optional[str] = None) -> str: exe = resolve_quake_binary(quake_bin) cmd = [str(exe)] + args proc = subprocess.run( cmd, cwd=str(script_dir()), capture_output=True, text=True, encoding="utf-8", errors="ignore", ) output = (proc.stdout or "") + ("\n" + proc.stderr if proc.stderr else "") if proc.returncode != 0: raise QuakeCliError(f"命令失败: {' '.join(args)}\n{output.strip()}") return outputpython def init_key(api_key: str, quake_bin: Optional[str] = None) -> None: print("[*] 正在初始化 Quake key ...") out = run_quake(["init", api_key], quake_bin=quake_bin) print(out.strip() or "[+] init 完成")python parser.add_argument("--key", help="可选,若提供则先执行 quake init <key>")python if args.key: init_key(args.key, quake_bin=str(selected_bin))python except QuakeCliError as exc: print(f"[!] 错误: {exc}") raise SystemExit(1)The documented usage also supplies the secret as a command-line argument:
bash python3 scripts/quake_batch_cli.py --no-interactive --mode search --key "$QUAKE_API_KEY" --query 'app:"exchange 2010"' --fields "ip,port,title" --page-size 100 --max-records 1000 --output-csv search.csv --output-raw search_raw.txtTechnical Analysis
Although the documentation recommends storing the key in an environment variable, shell expansion of
--key "$QUAKE_API_KEY"places the actual secret in the Python process's argument vector. The wrapper subsequently passes the key as an argument to the Quake child process via["init", api_key].Depending o ...[truncated 2166 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the
--keycommand-line option for normal credential entry. Read the key directly fromQUAKE_API_KEYinside the Python process or obtain it interactively withgetpass.getpass()so it is not echoed. - If the official Quake CLI supports reading credentials from standard input, a protected configuration file, or an environment variable, use that facility rather than invoking
quake init <key>. - If command-line transfer to the Quake executable is unavoidable, clearly document the residual process-list exposure and avoid encouraging initialization on shared systems.
- Redact sensitive arguments before constructing error messages. For example, represent an initialization failure as
quake init [REDACTED]and never include the underlying secret. - Avoid printing child-process output during credential initialization unless it is known not to echo the credential. Apply defensive redaction to both standard output and standard error.
- Update
SKILL.mdandscripts/README.mdso examples do not use--key "$QUAKE_API_KEY". - Add automated tests that force initialization failure and verify that neither the API key nor recognizable substrings of it appear in exceptions, standard output, or standard error.
- Rotate any API key that may already have appeared in process telemetry or logs, and remove retained log entries where feasible.
- Remove the
