[Security] nano-banana-pro follows output symlinks and overwrites files outside the working directory
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 skills/nano-banana-pro/scripts/generate_image.py 开始,在写入图像之前,--filename 参数在这里被转换为输出路径。将解析后的目标位置(os.path.realpath)与工作目录进行比较,当目标是符号链接或逃逸出工作目录时跳过或拒绝;该 issue 中建议的修复还提到了针对已存在目标的显式覆盖标志。按照复现步骤验证:在临时工作区中创建符号链接,运行脚本,并确认工作区外部的哨兵文件未被更改。完成的标准是:符号链接的情况会以清晰的错误被拒绝,同时正常的输出文件名仍能正常工作。
由索引模型根据 Issue 内容生成。
描述
Hi, I found a symlink-following issue in the nano-banana-pro skill that can overwrite files outside the working directory.
GitHub: https://github.com/steipete/agent-scripts/tree/main/skills/nano-banana-pro
ClawHub: https://clawhub.ai/steipete/skills/nano-banana-pro
Summary
generate_image.py saves the generated image to the path supplied with --filename without rejecting symlinks or checking that the resolved path stays inside the working directory.
If an untrusted repository contains result.png as a symlink to a file outside the repository, running the skill from that repository with --filename result.png follows the link and overwrites the target with PNG data. This can corrupt or destroy files that the OpenClaw process can write.
Steps to reproduce
-
Create an isolated test directory:
mkdir -p /tmp/nbp-test/workspace /tmp/nbp-test/outside printf 'SAFE TEST SENTINEL\n' > /tmp/nbp-test/outside/victim.txt ln -s ../outside/victim.txt /tmp/nbp-test/workspace/result.png -
From the workspace, run the skill with a valid Gemini API key available through
GEMINI_API_KEY:cd /tmp/nbp-test/workspace python3 /path/to/nano-banana-pro/scripts/generate_image.py \ --prompt "A simple blue square on a plain light background." \ --filename result.png -
Check the target:
file /tmp/nbp-test/outside/victim.txt
Expected behavior
The script should reject symlink outputs and any resolved output path outside the working directory.
Actual behavior
The script follows result.png and writes the generated PNG to /tmp/nbp-test/outside/victim.txt.
Impact
An attacker who can provide or modify repository contents can place the output symlink in the repository. If a user or agent runs image generation from that repository using the symlink name, files outside the repository may be overwritten or corrupted, subject to the OpenClaw process's file permissions.
Affected versions
Confirmed in nano-banana-pro 1.0.0 and 1.0.1.
Suggested fix
Reject symlink outputs and verify the resolved destination remains within the intended output directory before writing. Consider requiring an explicit overwrite option when the destination already exists.
- 主要语言
- Shell
- 星标
- 7.4k
- 派生
- 649
- 平均合并
- 32 分钟
- 30 天内合并 PR
- 3
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
leanprover-community/lean4game#589 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
agent-ready priority: medium status: ready work-class: scoped
难度 1/5 1 小时以内 新手友好度 75/100
melodic-software/claude-code-plugins#12762 ·
维护者通常 1 天内回复
-
examples/dnsdoctor: cleanup.sh stops at the first missing piece of a setup.sh that did not finish未关闭severity: low
难度 2/5 1-3 小时 新手友好度 70/100
luainkernel/lunatik#2263 ·
维护者通常 1 天内回复
-
Statusline crashes on Windows: Admission lock invariants hard-code '/' separator可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
danielmiessler/LifeOS#2567 ·
维护者通常 9 天内回复