Skip to content

fix(security): block Hermes FS traversal and revoked token reuse#329

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-8d5a
Closed

fix(security): block Hermes FS traversal and revoked token reuse#329
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-8d5a

Conversation

@cursor

@cursor cursor Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Daily critical-bug scan found two high-severity issues and applies minimal fixes.

1. Hermes file manager path traversal (security)

Impact: hermes_fs_read / hermes_fs_write / hermes_fs_list could access files outside ~/.hermes via paths like ../outside.txt.

Root cause: validate_hermes_fs_path fell back to non-canonical joined paths when canonicalize() failed. Rust Path::starts_with treats /.hermes/../outside as starting with /.hermes because it compares path components literally before .. is resolved.

Fix: Reject ParentDir (..) components, require canonical root, and validate via canonical ancestors (matching the existing hermes_logs_download pattern).

2. Revoked operator token reuse (security)

Impact: After an operator token was revoked (revokedAtMs set in paired.json), auto_pair_device / normalize_control_ui_pairing would rewrite the entry with the same token string but drop revokedAtMs, effectively un-revoking it.

Root cause: Introduced in the v0.18.1 pairing upgrade path (ensure_operator_token reused existing token whenever operator_token_is_usable returned false).

Fix: Generate a fresh token when revokedAtMs is present; continue reusing tokens only for non-revocation upgrade cases (missing scopes, etc.).

Validation

  • Added unit tests:
    • normalize_existing_pairing_rotates_revoked_operator_token
    • rejects_parent_dir_segments / allows_new_file_under_root
  • node --test tests/patch-gateway-origins.test.js passes (recent config-merge regressions still green)
  • Full cargo test not run in this environment (missing GTK/pkg-config deps)

Checklist

  • Focused, minimal diff
  • Concrete trigger scenarios identified
  • Tests added for fixed behavior
Open in Web View Automation 

- Reject ParentDir (..) in Hermes file manager paths and validate via
  canonical ancestors instead of non-canonical starts_with prefix checks
- Rotate operator tokens when revokedAtMs is set instead of silently
  re-issuing the same revoked token during auto-pair normalization

Fixes path traversal allowing reads/writes outside ~/.hermes and
revocation bypass introduced in the v0.18.1 pairing upgrade path.

Co-authored-by: 晴天 <1186258278@users.noreply.github.com>
@1186258278

Copy link
Copy Markdown
Contributor

已在 main 通过我们自己的提交吸收并发布:0a65ea7 / v0.18.5。\n\n覆盖内容:\n- Hermes 文件管理路径拒绝 .. 并通过 canonical path 校验\n- 已撤销 operator token 自动配对时不再复用,会旋转新 token\n- 增加对应 Rust 回归测试\n\nCI 与 release workflow 均已通过,发布页:https://github.com/qingchencloud/clawpanel/releases/tag/v0.18.5\n\n这个 draft PR 保留会造成重复,先关闭。

@1186258278

Copy link
Copy Markdown
Contributor

已由 main 的 0a65ea7 / v0.18.5 吸收并发布,关闭重复 draft PR。

@1186258278 1186258278 closed this Jun 15, 2026
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