T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/prefetch.py:142- Finding
Unrestricted Remote Shell Execution Through Tencent Cloud TAT
- Content
View full analysis
Dict: """通过 TAT 远程执行 Shell 命令,自动 base64 编码、执行、等待、解码输出""" import base64 import time b64_content = base64.b64encode(command.encode("utf-8")).decode("utf-8") data = run_tccli([ "tat", "RunCommand", "--region", region, "--InstanceIds", json.dumps([instance_id]), "--CommandType", "SHELL", "--Content", b64_content, "--Timeout", str(timeout), ]) ``` ```python parser.add_argument("--exec-tat", default=None, help="通过 TAT 远程执行只读 Shell 命令(CVM/Lighthouse 专用)。" "示例: --exec-tat 'top -bn1 | head -20'") parser.add_argument("--tat-timeout", type=int, default=60, help="TAT 命令超时秒数(默认 60)") args = parser.parse_args() # ── TAT 远程执行模式 ── if args.exec_tat: tat_result = exec_tat_command(args.region, args.instance_id, args.exec_tat, args.tat_timeout) print(json.dumps(tat_result, ensure_ascii=False, indent=2)) sys.exit(0 if tat_result.get("status") == "ok" else 1) ``` ### Technical Analysis The `--exec-tat` argument is accepted as an unrestricted string and sent to Tencent Cloud TAT with `CommandType` set to `SHELL`. Base64 encoding only satisfies the TAT transport format and provides no validation or security boundary. The product profile states that only read-only commands should be used, but this restriction exists only as natural-language guidance. The implementation does not enforce an executable allowlist, argument validation, shell-metacharacter filtering, product restrictions, or explicit user confirmation. Consequently, the input can contain destructive commands, redirection, command substitution, pipelines, cr ...[truncated 1424 chars]- Remediation
View remediation
