Skip to content

收紧 iCloud 会话目录和令牌文件的权限 - #1

Merged
cursor[bot] merged 2 commits into
masterfrom
cursor/sesion-permisos-privados-3ff8
Nov 13, 2026
Merged

cursor[bot] merged 2 commits into
masterfrom
cursor/sesion-permisos-privados-3ff8

Conversation

@hljghost

@hljghost hljghost commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

问题

Omarchy marketplace 维护者在 omacom/omarchy-plugin-marketplace#14569 对 icdown b1e179bfffb68b2c64bfaa6aa2ab965f7dee2f32 的审查结论:

Medium — required icdown provider icdown/src/puente.rs:76–89 and puente/puente_icloud.py:86–103, reviewed at plugin bf75d49cde05e21273c320cb8da4a55b5eb887f5 / icdown b1e179bfffb68b2c64bfaa6aa2ab965f7dee2f32: a fresh login with umask 022 creates the session directory as 0755 and writes the iCloud session/trust-token JSON as 0644. Another local account can read those authentication secrets when the parent directories are traversable; pyicloud's later makedirs(..., 0700, exist_ok=True) leaves the already-created directory unchanged, while private parents or umask 077 prevent this disclosure.

当前 HEAD 上位置仍对应:Rust 在 Puente::iniciar_con 里用 create_dir_all 建会话目录;Python 在原子写入(puente/puente_icloud.py 的 _escribir_atomico)里用默认的 open() 写会话 JSON。pyicloud v1.33.0 把 session token 和 trust token 放在同一个 .session JSON 里,并用 makedirs(cookie_directory, 0o700, exist_ok=True),不会改已经存在的目录。

修复

权限不再依赖调用方的 umask(umask 只会去掉权限位,不能把 0666/0777 收成私有):

  • 会话目录以 0700 创建。若已经存在且比 0700 更开放(例如 0755),则 chmod 为 0700。已经更严的目录保持原样。
  • 会话 JSON(session token 与 trust token)以 0600 写入。同目录里的 cookie 文件也是认证密钥,同样写成 0600。已有更开放的普通文件会收紧到 0600;已经更严的(例如 0400)不放宽。不跟随符号链接,因此不会改到目录外的目标。
  • Rust(Puente::iniciar_con,启动桥之前)和 Python(asegurar_directorio_sesion,在 main 和真正构造 PyiCloudService 之前,以及原子写入和 cookie jar 保存时)两条路径都做同样的收紧。
  • 不删除会话或照片,不改登录、校验或删除流程。

测试

  • Rust:新建目录为 0700;已有的 0755 目录和 0644 的 .session / cookie 被收紧且内容不变;符号链接指向的文件保持 0644;0400 不被放宽;iniciar_con 会收紧已有目录和 JSON。
  • Python:umask 022 与 000 下,目录为 0700,会话 JSON 与 cookie 为 0600。已有内容不被改写,更严的 0400 保持不变。Windows 上该用例跳过(无 Unix 权限位)。

CI

Windows 作业原先在 cargo clippy 处失败,因为清单路径仍是已不存在的 icopia\Cargo.toml。现改为 icdown\Cargo.toml。Python 测试在这次失败的作业里已经通过(48 passed,1 skipped)。

Open in Web Open in Cursor 

cursoragent and others added 2 commits November 13, 2026 05:58
umask 022 时会话目录会落成 0755,会话 JSON(session token 与 trust token)和 cookies 会落成 0644,本机其他账户在父目录可穿越时就能读到这些认证密钥。Rust 与 Python 都改为目录 0700、文件 0600,已有更宽的权限也会收紧,且不依赖调用方的 umask。

Co-authored-by: hljghost <hljghost@users.noreply.github.com>
Windows 作业在 clippy 之前就退出:清单路径仍是 icopia\Cargo.toml。

Co-authored-by: hljghost <hljghost@users.noreply.github.com>
@cursor
cursor Bot merged commit 17c4556 into master Nov 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants