Skip to content

fix(gbrain): constrain imports to configured vault - #192

Open
levineam wants to merge 1 commit into
mainfrom
codex/fix-gbrain-import-path-traversal-vulnerability
Open

fix(gbrain): constrain imports to configured vault#192
levineam wants to merge 1 commit into
mainfrom
codex/fix-gbrain-import-path-traversal-vulnerability

Conversation

@levineam

Copy link
Copy Markdown
Owner

Motivation

  • The curated import was allowing absolute paths and relative traversal to escape the configured vault, letting a manifest stage arbitrary readable files into generated GBrain pages.
  • Symlinked files inside the vault could resolve to targets outside the vault, creating an additional path-traversal vector.
  • The intent is to ensure imports only include files that actually live under the configured vaultDir to prevent accidental or malicious exfiltration into the brain store.

Description

  • resolveSourcePath now resolves candidate source paths against the configured vaultDir and rejects paths that escape the vault (rejects .. traversal and absolute escapes).
  • Added resolveRealSourcePath which canonicalizes both the vault and the candidate with realpathSync to detect and reject symlink escapes, and createImportPlan uses this canonical path for subsequent operations.
  • createImportPlan now emits clearer warnings for missing/out-of-vault sources and excludes any items whose normalized or real path is outside the vault.
  • Added regression tests to modules/jarvos-gbrain/test/gbrain.test.js that assert rejection of ../ traversal, absolute outside paths, and symlink-based escapes while preserving normal import behavior.

Testing

  • Ran the module test suite with npm test (which executes node --test test/*.test.js) and all tests passed (36/36).
  • The newly added tests exercise relative traversal and symlink escape cases and succeeded under the updated validation logic.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant