[Security] nano-banana-pro follows output symlinks and overwrites files outside the working directory

已关闭 适合新手
#46 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
security

调研方向

从 skills/nano-banana-pro/scripts/generate_image.py 开始,在写入图像之前,--filename 参数在这里被转换为输出路径。将解析后的目标位置(os.path.realpath)与工作目录进行比较,当目标是符号链接或逃逸出工作目录时跳过或拒绝;该 issue 中建议的修复还提到了针对已存在目标的显式覆盖标志。按照复现步骤验证:在临时工作区中创建符号链接,运行脚本,并确认工作区外部的哨兵文件未被更改。完成的标准是:符号链接的情况会以清晰的错误被拒绝,同时正常的输出文件名仍能正常工作。

由索引模型根据 Issue 内容生成。

描述

clawsweeper:needs-security-review clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:data-loss impact:security issue-rating: 🦞 diamond lobster P2

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

  1. 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
    
  2. 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
    
  3. 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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

相似的 Issue

更多 Shell/Bash Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。