[PR #11720] fix: security vulnerabilities and reliability improvements #13907

Closed
opened 2026-02-16 18:18:44 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11720

State: closed
Merged: No


Summary

This PR addresses several security vulnerabilities and reliability issues discovered through deep codebase analysis.

Security Fixes

  • CRITICAL: Code Injection - Removed new Function() in debug/agent.ts that allowed arbitrary code execution via --params flag
  • HIGH: SSRF Protection - Added private IP filtering in webfetch.ts to block requests to internal networks (127.0.0.1, 10.x.x.x, 192.168.x.x, 169.254.x.x)
  • HIGH: Path Traversal via Symlinks - Added realpath resolution in file/index.ts to prevent symlink-based sandbox escapes
  • HIGH: Patch Path Traversal - Added path validation in patch/index.ts to prevent patches from writing files outside project directory

Reliability Fixes

  • OAuth Callback Bug - Fixed cancelPending() in oauth-callback.ts which was using wrong key to lookup pending authentications
  • Retry Loop Bug - Fixed silent error swallowing in processor.ts that caused retry loop to continue when aborted
  • Memory Leak - Added close() method to AsyncQueue in queue.ts to properly cleanup pending resolvers

Test plan

  • TypeScript typecheck passes (12/12 packages)
  • All tests pass (841/841)
  • Manual verification of each fix

Files Changed

File Change
src/cli/cmd/debug/agent.ts Remove new Function(), JSON-only parsing
src/file/index.ts Add resolveRealPath() for symlink protection
src/mcp/oauth-callback.ts Fix cancelPending() to iterate Map correctly
src/mcp/index.ts Pass mcpName to waitForCallback()
src/patch/index.ts Add validatePatchPath() for path containment
src/session/processor.ts Check abort signal after retry sleep
src/tool/webfetch.ts Add isPrivateIP() SSRF filter
src/util/queue.ts Add close() method for cleanup

🤖 Generated with Claude Code

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11720 **State:** closed **Merged:** No --- ## Summary This PR addresses several security vulnerabilities and reliability issues discovered through deep codebase analysis. ### Security Fixes - **CRITICAL: Code Injection** - Removed `new Function()` in `debug/agent.ts` that allowed arbitrary code execution via `--params` flag - **HIGH: SSRF Protection** - Added private IP filtering in `webfetch.ts` to block requests to internal networks (127.0.0.1, 10.x.x.x, 192.168.x.x, 169.254.x.x) - **HIGH: Path Traversal via Symlinks** - Added `realpath` resolution in `file/index.ts` to prevent symlink-based sandbox escapes - **HIGH: Patch Path Traversal** - Added path validation in `patch/index.ts` to prevent patches from writing files outside project directory ### Reliability Fixes - **OAuth Callback Bug** - Fixed `cancelPending()` in `oauth-callback.ts` which was using wrong key to lookup pending authentications - **Retry Loop Bug** - Fixed silent error swallowing in `processor.ts` that caused retry loop to continue when aborted - **Memory Leak** - Added `close()` method to `AsyncQueue` in `queue.ts` to properly cleanup pending resolvers ## Test plan - [x] TypeScript typecheck passes (12/12 packages) - [x] All tests pass (841/841) - [x] Manual verification of each fix ## Files Changed | File | Change | |------|--------| | `src/cli/cmd/debug/agent.ts` | Remove `new Function()`, JSON-only parsing | | `src/file/index.ts` | Add `resolveRealPath()` for symlink protection | | `src/mcp/oauth-callback.ts` | Fix `cancelPending()` to iterate Map correctly | | `src/mcp/index.ts` | Pass `mcpName` to `waitForCallback()` | | `src/patch/index.ts` | Add `validatePatchPath()` for path containment | | `src/session/processor.ts` | Check abort signal after retry sleep | | `src/tool/webfetch.ts` | Add `isPrivateIP()` SSRF filter | | `src/util/queue.ts` | Add `close()` method for cleanup | 🤖 Generated with [Claude Code](https://claude.com/claude-code)
yindo added the pull-request label 2026-02-16 18:18:44 -05:00
yindo closed this issue 2026-02-16 18:18:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13907