π‘οΈ Sentinel: [CRITICAL] Fix path traversal in LocalJsonStore#224
π‘οΈ Sentinel: [CRITICAL] Fix path traversal in LocalJsonStore#224hackerxj2010 wants to merge 1 commit into
Conversation
Resolved a path traversal vulnerability in the LocalJsonStore class by implementing robust path validation and normalization. - Resolve baseDirectory to an absolute path in the constructor. - Disallow absolute paths as keys in toPath. - Filter out '.' and '..' segments from the key. - Verify the final resolved path starts with the base directory (ensuring trailing separator to prevent prefix bypass). - Add security tests to verify the fix. - Add security journal entry in .jules/sentinel.md. Co-authored-by: hackerxj2010 <198651211+hackerxj2010@users.noreply.github.com>
|
π Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a π emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
π¨ Severity: CRITICAL
π‘ Vulnerability:
Path traversal in
LocalJsonStorewithinpackages/documents/src/index.ts. The original implementation allowed keys to contain..segments or be absolute paths, which could lead to unauthorized file access or modification outside the intended base directory.π― Impact:
A malicious user or a misbehaving agent could potentially read or overwrite any JSON file on the system that the Node.js process has access to. Given that this store is used for session data, audit logs, and tool results across various services, this posed a significant security risk.
π§ Fix:
baseDirectoryis now resolved to an absolute path in the constructor.path.isAbsolute()and rejected if they are absolute..,.., or empty segments are filtered out.baseDirectoryprefix, including a trailing separator check to prevent "prefix bypass" attacks (e.g.,/data/storevs/data/store-leaked).β Verification:
packages/documents/src/security.test.tsto specifically exercise path traversal attempts and absolute path keys. All 3 tests pass.pnpm testacross the workspace. All 48 tests (including service-level tests that useLocalJsonStore) passed.pnpm lint..jules/sentinel.md.PR created automatically by Jules for task 14845244175862129537 started by @hackerxj2010