Fix security, correctness, and performance issues#1
Open
hyunyul-XCENA wants to merge 1 commit into
Open
Conversation
…de review
Security:
- Remove CORS wildcard on POST + add Origin validation to block CSRF
- Default bind to 127.0.0.1 instead of 0.0.0.0
- Add SAFE_ID_RE regex validation on all user-supplied IDs (prevent glob injection)
- Add resolve() + prefix checks on all delete endpoints (prevent symlink traversal)
- Replace str(e) error responses with generic messages
Correctness:
- Fix hook delete index mismatch: pass handler_index/sub_hook_index instead of flat index
- Add macOS lsof fallback for process cwd detection (/proc doesn't exist on macOS)
- Normalize timestamps before sorting to prevent TypeError on mixed int/string types
- Fix falsy filter ({k:v if v} → if v is not None and v != "") to preserve timeout:0
- Increase fork dedup key from 50 to 200 chars
- Return 404 when delete-session finds nothing
Performance:
- Add TTL cache decorator on 7 expensive data-collection functions
- Move get_skills/get_agents/get_connectors calls outside per-plugin loop in get_plugins
- Replace full-file read_text with _read_last_n_lines in get_activity, get_projects_summary, get_forks
- Reduce get_session_detail from 5-6 file opens to 2 per session (single-pass)
- Replace grep subprocess with inline regex for customTitle extraction
- Stream compact counting in get_session_xray instead of loading entire file
- Increase _read_last_n_lines buffer 10x and discard partial first line
- Add @lru_cache to decode_project_path
- Optimize read_text to read only max_chars bytes when limit is set
- Wrap socket.gethostbyname in try/except for VPN/hostname edge cases
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Competitive code review (3 reviewers: Security / Performance / Correctness) identified 23 issues. This PR fixes all Critical and Warning items plus most Suggestions.
Security (Critical)
*on POST, add Origin validation, default bind to127.0.0.1SAFE_ID_REregex; replacerglob(user_input)with exact file matchingresolve()+ prefix checks on all 6 delete endpoints (consistent with_serve_staticpattern)str(e)with generic error messagesCorrectness (Critical + Warning)
handler_index/sub_hook_indexpair instead of flat indexlsof -d cwdfallback (/procdoesn't exist on macOS){k:v if v}→if v is not None and v != ""to preservetimeout: 0Performance (Critical + Warning)
@ttl_cachedecorator on 7 expensive data-collection functionsget_skills/get_agents/get_connectorscalls outside per-plugin loopread_text()with_read_last_n_lines()in 3 functionssubprocess.run(["grep", ...])with inline regex for customTitle_read_last_n_linesbuffer 10x increase + discard partial first line@lru_cacheondecode_project_path, optimizedread_text(max_chars)Test plan
Origin: http://evil.com→ 403id=*→ 400handler_index/sub_hook_indexmetadatahandler_index+sub_hook_indexparams🤖 Generated with Claude Code