Skip to content

chore: update Readest path authorization - #110

Open
hehetoshang wants to merge 1 commit into
mainfrom
agent/moke/66f28894
Open

chore: update Readest path authorization#110
hehetoshang wants to merge 1 commit into
mainfrom
agent/moke/66f28894

Conversation

@hehetoshang

Copy link
Copy Markdown
Collaborator

Summary

Update the embedded Readest gitlink to ea89a6a20f8907f44b087bd4ebf5d785e1843ab1, which adds canonical path authorization to EPUB/MOBI parsers, directory scans, uploads, and downloads.

Readest review: hehetoshang/readest#28

Validation

  • cargo check --manifest-path src-tauri/Cargo.toml (passed; existing vendored/readest dead-code and WebKit deprecation warnings remain)
  • Readest: cargo test -p Readest --lib (112 passed)
  • Readest: cargo clippy -p Readest --no-deps -- -D warnings
  • Readest: cargo fmt -p Readest --check

Integration order

Merge the Readest PR first (or retain the referenced commit in the fork), then merge this gitlink bump.

Tracks Multica TB-114.

Comment thread readest
@@ -1 +1 @@
Subproject commit dc38f0f35b92ed10f1584e4fa66188bfe6cadfdf
Subproject commit ea89a6a20f8907f44b087bd4ebf5d785e1843ab1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查结论:方向正确,安全性显著提升,但建议合入前确认以下几点

这个 gitlink 升级引入了 readest PR #28 的路径授权层。整体是安全加固(修复 GHSA-55vr-pvq5-6fmg 类任意路径读写),但有几个点需要确认/改进:

值得确认的点

  1. 错误信息回归path_authorization.rs::authorize_pathresolve_path 的全部错误(包括对不存在文件 fs::canonicalize 返回的 NotFound)统一映射为 "permission denied: path is outside authorized roots"。对读操作,旧代码会在文件不存在时返回 "file not found",现在授权在 is_file() 检查之前先失败,用户打开已删除/不存在的书会看到误导性的"权限拒绝"。

  2. TOCTOU 窗口:授权是 canonicalize + starts_with 前缀检查,之后实际 I/O 使用的是授权后的路径,中间存在竞态窗口。若威胁模型是"被攻陷的 webview",恶意 JS 可配合外部进程在授权后替换父目录为符号链接逃逸。同类方案固有局限,建议至少在注释里声明,或考虑基于 O_NOFOLLOW/openat 风格操作。

  3. cover_thumbnail.rs 仅授权了顶层目录optimize_cover_thumbnails 只对 books_dir/cache_dir 做授权,covers 列表里每个请求的路径(webview 可控)未逐条校验。需确认 build_jobs 内部不会用请求路径做 .. 拼接或直接读取任意绝对路径。

  4. gitlink 指向 fork 的 PR 分支 commitea89a6a 是 readest PR fix: HOU-15 安全高危:capabilities 收窄 + open_reader 作用域校验(H1/H2) #28agent/moke/66f28894 分支)的 head commit,未在 master。若该 PR 合并时被 rebase/squash,此 gitlink 会指向悬空 commit。PR 描述已说明保留 commit 或先合并,但合并顺序风险需在合入时确认。

  5. 重定向策略无测试transfer_redirect_policy 的 HTTP(S) 校验与 10 次上限没有单测,只有 parse_transfer_url 有覆盖。建议补测。

确认无回归的点(已核对)

  • Moke 的书籍在 <app_data>/books,属于 AuthorizedRoots::Books 的锚定根,阅读器解析路径可正常授权。
  • 命令签名新增 AppHandle 参数对前端透明,Moke 通过 reader_invoke_handler() 注册,无需改动。
  • Moke 前端只调用 open_reader/moke_*,不直接调用 readest 的 parse/transfer 命令。

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.

1 participant