Skip to content

fix(hub): contain index-sourced paths to project root (bd-rz6yb)#244

Merged
shikokuchuo merged 1 commit into
mainfrom
feature/bd-rz6yb-hub-path-traversal-containment
May 31, 2026
Merged

fix(hub): contain index-sourced paths to project root (bd-rz6yb)#244
shikokuchuo merged 1 commit into
mainfrom
feature/bd-rz6yb-hub-path-traversal-containment

Conversation

@shikokuchuo
Copy link
Copy Markdown
Member

@shikokuchuo shikokuchuo commented May 31, 2026

Summary

The Hub index is a client-writable CRDT mapping path → doc, and the sync loop wrote each doc to project_root.join(path) with no containment check (only an .exists() guard).

Any authenticated client can put any key in the index over the wire, so a malicious one could set ../../../home/svc/.bashrc and have the server write attacker content outside the project root — an overwrite-any-writable-file primitive (potential RCE via shell rc / configs / .git/hooks).

.exists() also follows symlinks, so a symlinked dir inside the root gave the same escape with no ...

Fix

  • This gates the single index-key→write site in sync_all_documents with a lexical contained_join (rejects ../absolute/rooted) plus a canonicalize + starts_with check (catches symlink escapes).
  • Rejections are logged and counted.
  • Holds even with auth disabled.

@cscheid @gordonwoodhull this closes a security vulnerability whereby changes to an index document could result in filesystem changes on the server.

A malicious wire client could poison the index CRDT with a traversal,
absolute, or symlink-escaping key and overwrite any file the server can
write. Gate the single index-key -> fs-write site in sync_all_documents
with a lexical contained_join plus a canonicalize/starts_with
symlink-escape check; rejected entries are counted and warned.
@shikokuchuo shikokuchuo force-pushed the feature/bd-rz6yb-hub-path-traversal-containment branch from af6c36f to a20a02f Compare May 31, 2026 04:09
@shikokuchuo shikokuchuo merged commit 17b589f into main May 31, 2026
4 checks passed
@shikokuchuo shikokuchuo deleted the feature/bd-rz6yb-hub-path-traversal-containment branch May 31, 2026 04:15
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