T09 · Insecure Skill Coding Practices
- Location
scripts/starops_manager.py:676- Finding
Diagnostic Prompts Are Persisted Verbatim in Execution Traces
- Content
View full analysis
None: """Append an execution trace record to .aliyun-sre/execution-trace.jsonl.""" sre_dir = os.path.join(os.getcwd(), ".aliyun-sre") if not os.path.isdir(sre_dir): os.makedirs(sre_dir, exist_ok=True) trace_path = os.path.join(sre_dir, "execution-trace.jsonl") record = { "timestamp": datetime.now(timezone.utc).isoformat(), "script": "starops_manager.py", "command": command, "args": args_dict, "session": (extra or {}).get("session"), "thread_id": (extra or {}).get("thread_id"), "exit_code": exit_code, "success": success, } trace_flags = os.O_CREAT | os.O_WRONLY | os.O_APPEND trace_fd = os.open(str(trace_path), trace_flags, 0o600) with os.fdopen(trace_fd, "a") as f: f.write(json.dumps(record, ensure_ascii=False) + "\n") ``` ```python extra = {} if args.command == "chat" and hasattr(args, "thread_id"): extra["thread_id"] = args.thread_id _append_trace(args.command, vars(args), exit_code == 0, exit_code, extra or None) ``` The `chat` command defines the diagnostic prompt as `args.question`. Calling `vars(args)` includes that complete value in `args_dict`, which is then serialized without filtering into `.aliyun-sre/execution-trace.jsonl`. ### Technical Analysis SRE diagnostic prompts can contain sensitive operational information, including: - Cloud resource IDs and account identifiers - Internal hostnames, IP addresses, and network topology - Incident descriptions and log excerpts - Application names and infrastructure metadata - Credentials or tokens accidentally paste ...[truncated 1824 chars]- Remediation
View remediation
dict: raw = vars(args) allowed_by_command = { "chat": { "uid", "config", "endpoint", "idle_timeout", "stream", "raw", "json" }, "create-thread": { "employee_id", "uid", "profile", "workspace", "config", "endpoint" }, } safe = { key: raw.get(key) for key in allowed_by_command.get(command, set()) } if command == "chat": question = raw.get("question") or "" safe["question_supplied"] = bool(question) safe["question_length"] = len(question) return safe ``` Then invoke the trace writer with: ```python _append_trace( args.command, _safe_trace_args(args.command, args), exit_code == 0, exit_code, extra or None, ) ``` ]]>
