T02 · Agent Memory Poisoning
- Location
scripts/sync_truth_social.py:141- Finding
Untrusted Remote Content Persisted in the Agent Workspace
- Content
View full analysis
list: """获取 JSON 数据""" print(f"正在获取: {url}") try: with urlopen(url, timeout=60) as response: data = json.loads(response.read().decode("utf-8")) print(f"获取到 {len(data)} 条记录") return data except (URLError, HTTPError) as e: print(f"错误: 无法获取数据 - {e}") sys.exit(1) ``` The remote post content is interpolated directly into an alert message. It is truncated to 300 characters but is not sanitized, isolated, or marked as untrusted data: ```python def format_alert_message(post: dict, alerts: list) -> str: """格式化预警消息""" created_at = post.get("created_at", "") content = post.get("content", "") url = post.get("url", "") # 解析时间 try: dt = datetime.fromisoformat(created_at.replace("Z", "+00:00")) time_str = dt.strftime("%Y-%m-%d %H:%M UTC") except: time_str = created_at # 关键词摘要 keywords = [a["category"] for a in alerts] keyword_str = ", ".join(set(keywords)) # 内容截取 content_preview = content[:300] if len(content) > 300 else content msg = f"""🚨 **金融市场预警 - Trump Truth Social** **时间**: {time_str} **触发关键词**: {keyword_str} **帖子内容**: {content_preview} **原文链接**: {url} """ return msg ``` The generated message is then appended to a persistent Markdown file inside the OpenClaw workspace: ```python def write_alert_to_report(alerts: list) -> None: """将预警信息追加到报告文件""" report_dir = Path.home() / ".openclaw" / "workspace" / "repo ...[truncated 4816 chars]- Remediation
View remediation
