fix(security): path traversal, SSRF, prompt injection, and 13 CVEs - #15
Merged
Conversation
Path traversal
- Replace bare require('fs') + unvalidated paths in BootstrapFewShot,
MIPROv2, and GEPA save/load with a safeResolvePath() helper that
strips null bytes and normalises '..' components via path.resolve().
- Add proper 'fs' and 'path' static imports (removes dynamic require calls).
SSRF
- Add validateEndpoint() to OpenAILM, AnthropicLM, and OpenRouterLM that
enforces HTTPS and rejects private/loopback addresses (localhost, RFC-1918,
::1, ULA). Validation runs at construction time before any network call.
Prompt injection
- Add src/utils/sanitize.ts with sanitizeUserInput() and
stripPromptInjection() helpers that: strip null bytes, cap input at 4096
chars, and remove 20+ common jailbreak patterns (role overrides, delimiter
smuggling, exfiltration probes).
- Apply sanitizeUserInput() to user-supplied string fields in ReAct
(thought-prompt and back-fed tool observations) and ChainOfThought (input
prompt construction).
Dependency CVEs (npm audit)
- Add package.json overrides for qs (>=6.15.0), protobufjs (>=7.5.8), and
tar (>=7.5.11) to address GHSA-q8mj-m7cp-5q26 (moderate DoS),
GHSA-xq3m-2v4x-88gg and 8 related protobufjs RCE/DoS CVEs, and 6
node-tar path-traversal/symlink-poisoning CVEs.
- Run `npm audit fix` to apply the qs patch; result: 0 vulnerabilities.
TypeScript: tsc --noEmit passes with 0 errors.
Tests: 177/177 passing.
Co-Authored-By: claude-flow <ruv@ruv.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
save()/load()methods: callers could supply../../etc/passwdas a path. Fixed with asafeResolvePath()helper that strips null bytes and normalises..components viapath.resolve(), and replaces dynamicrequire('fs')with static imports.OpenAILM,AnthropicLM,OpenRouterLM): theendpointconfig option was passed directly tofetch()without validation. AvalidateEndpoint()guard now enforces HTTPS and blocks private/loopback addresses (RFC-1918,::1, ULA) at construction time.ReActandChainOfThought: user-supplied string fields were embedded verbatim in LLM prompts viaJSON.stringify(input[field]). A newsrc/utils/sanitize.tsmodule providessanitizeUserInput()(null-byte strip, 4096-char cap, pattern-based jailbreak removal) andstripPromptInjection()(20+ patterns covering role overrides, delimiter smuggling, and exfiltration probes). Applied to input fields and tool observations fed back into the ReAct context.package.jsonoverrides:protobufjs <=7.5.7— CRITICAL: 9 CVEs including RCE (GHSA-xq3m-2v4x-88gg, code injection, prototype pollution, multiple DoS). Override to>=7.5.8.tar <=7.5.10— HIGH: 6 CVEs for path traversal / symlink poisoning during archive extraction. Override to>=7.5.11.qs 6.11.1–6.15.1— MODERATE: DoS viaqs.stringifycrash (GHSA-q8mj-m7cp-5q26). Override to>=6.15.0;npm audit fixapplied the patch.npm audit).Test plan
tsc --noEmitpasses with 0 errors (verified in CI and locally)npm testpasses 177/177 testsnpm auditreturns 0 vulnerabilitieshttp://localhost/evilandhttps://192.168.1.1/evilfor all three LM providerssanitizeUserInput('ignore all previous instructions')returns'[removed] all previous instructions'save('../../../tmp/evil.json')resolves to an absolute path (no traversal)Files changed
src/utils/sanitize.tssrc/utils/index.tssrc/lm/providers/openai.tsendpointsrc/lm/providers/anthropic.tsendpointsrc/lm/providers/openrouter.tsendpointsrc/modules/react.tssrc/modules/chain-of-thought.tssrc/optimize/bootstrap.tssrc/optimize/miprov2.tssrc/optimize/gepa.tspackage.jsonpackage-lock.json🤖 Generated with claude-flow