chore: update Readest path authorization - #110
Conversation
| @@ -1 +1 @@ | |||
| Subproject commit dc38f0f35b92ed10f1584e4fa66188bfe6cadfdf | |||
| Subproject commit ea89a6a20f8907f44b087bd4ebf5d785e1843ab1 | |||
There was a problem hiding this comment.
审查结论:方向正确,安全性显著提升,但建议合入前确认以下几点
这个 gitlink 升级引入了 readest PR #28 的路径授权层。整体是安全加固(修复 GHSA-55vr-pvq5-6fmg 类任意路径读写),但有几个点需要确认/改进:
值得确认的点
-
错误信息回归:
path_authorization.rs::authorize_path将resolve_path的全部错误(包括对不存在文件fs::canonicalize返回的 NotFound)统一映射为"permission denied: path is outside authorized roots"。对读操作,旧代码会在文件不存在时返回"file not found",现在授权在is_file()检查之前先失败,用户打开已删除/不存在的书会看到误导性的"权限拒绝"。 -
TOCTOU 窗口:授权是 canonicalize +
starts_with前缀检查,之后实际 I/O 使用的是授权后的路径,中间存在竞态窗口。若威胁模型是"被攻陷的 webview",恶意 JS 可配合外部进程在授权后替换父目录为符号链接逃逸。同类方案固有局限,建议至少在注释里声明,或考虑基于O_NOFOLLOW/openat 风格操作。 -
cover_thumbnail.rs仅授权了顶层目录:optimize_cover_thumbnails只对books_dir/cache_dir做授权,covers列表里每个请求的路径(webview 可控)未逐条校验。需确认build_jobs内部不会用请求路径做..拼接或直接读取任意绝对路径。 -
gitlink 指向 fork 的 PR 分支 commit:
ea89a6a是 readest PR fix: HOU-15 安全高危:capabilities 收窄 + open_reader 作用域校验(H1/H2) #28(agent/moke/66f28894分支)的 head commit,未在master。若该 PR 合并时被 rebase/squash,此 gitlink 会指向悬空 commit。PR 描述已说明保留 commit 或先合并,但合并顺序风险需在合入时确认。 -
重定向策略无测试:
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 命令。
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)cargo test -p Readest --lib(112 passed)cargo clippy -p Readest --no-deps -- -D warningscargo fmt -p Readest --checkIntegration order
Merge the Readest PR first (or retain the referenced commit in the fork), then merge this gitlink bump.
Tracks Multica TB-114.