将原始主题文本替换进示例 shell 命令可能造成命令注入
原文依据:3 处工具说明让代理把 QUERY 或 SUBREDDIT 直接替换到 shell 示例中,却没有规定 URL 编码、参数校验或安全的参数传递方式。如果替换过程是文本拼接,包含引号或 shell 运算符的输入可改变原命令。
恶意或意外构造的主题可能在代理权限范围内执行额外 shell 命令,读取可访问文件、修改工作区或发起非预期网络请求。
这些是文档中的示例命令,不是可见的自动执行脚本。Google News 示例还要求用 `+` 和 `%22` 编码部分字符;若代理正确做完整 URL 编码,主题文本不会改变 shell 结构。但文档没有说明完整编码或安全参数传递,Reddit 的 SUBREDDIT 也无校验,所以把不可信文本直接替换进命令时存在注入可能。用户可禁止拼接 shell,要求使用 URL 编码库、固定允许字符,并在执行前展示最终命令。
这项判断针对展示的代码和适用条件,不表示风险已经实际发生。```bash# Replace QUERY with topic (use + for spaces, %22 for quotes)curl -s "https://news.google.com/rss/search?q=QUERY&hl=en-US&gl=US&ceid=US:en" \ | xmllint --xpath "//item[position()<11]" - 2>/dev/null```查看另外 2 个位置
```bashSINCE=$(($(date +%s) - 86400))curl -s "https://hn.algolia.com/api/v1/search_by_date?query=QUERY&tags=story&numericFilters=created_at_i>${SINCE}" \ | jq '.hits[] | {title, url, points, num_comments, created_at, hn_url: ("https://news.ycombinator.com/item?id="+.objectID)}'``````bashcurl -s -A "newsjack/1.0" \ "https://www.reddit.com/r/SUBREDDIT/top.json?t=day&limit=15" \ | jq '.data.children[].data | {title, url, score, num_comments, created_utc}'```