T01 · Skill Instruction Hijacking
- Location
scripts/booklist_generator.py:249- Finding
Untrusted DuckDuckGo Search Content Is Inserted into Agent-Visible Booklists
- Content
View full analysis
list[dict]: """Use DuckDuckGo HTML search without an API key.""" url = f"https://duckduckgo.com/html/?q={urllib.parse.quote(query)}" try: req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"}) with urllib.request.urlopen(req, timeout=10) as resp: html = resp.read().decode("utf-8", errors="replace") # Extract snippets results = [] for match in re.finditer( r']*>(.*?)', html, re.DOTALL ): snippet = re.sub(r"<[^>]+>", "", match.group(1)).strip()[:150] if snippet: results.append({"snippet": snippet}) if len(results) >= limit: break return results except Exception: return [] ``` ```python if include_web and books: lines.append("\n---\n## 🌐 網路延伸閱讀\n") for b in books[:3]: query = f"{b['title']} {b.get('author','')} book summary" web = _web_search(query, 1) if web: snippet = web[0].get("snippet","") lines.append(f"- **{b['title']}**:{snippet}") else: lines.append(f"- **{b['title']}**:{b.get('why','')}") ``` ```python if args.web: query = f"best books about {args.topic} reading list" web_results = _web_search(query, 5) for r in web_results: data["books"].append({ "title": r.get("snippet","")[:60], "author": "搜尋結果", "why": r.get("snippet",""), "难度": 2, "required": False, }) ``` ### Technical Analysis The `--web` feature ...[truncated 2312 chars]- Remediation
View remediation
