Skip to content

security: harden server routes, PTY, webfetch, and auth#231

Merged
duguwanglong merged 4 commits into
devfrom
security/server-hardening
May 8, 2026
Merged

security: harden server routes, PTY, webfetch, and auth#231
duguwanglong merged 4 commits into
devfrom
security/server-hardening

Conversation

@xiami762
Copy link
Copy Markdown
Contributor

@xiami762 xiami762 commented May 8, 2026

  • Add URL guard and tighten webfetch/tool loading
  • Restrict PTY to approved shells; authenticate PTY WebSocket before probe
  • Resolve find paths via workspace guard; safer rg/grep/fd/find invocation
  • Require admin for YAML plugin tool CRUD
  • Gate tokenless loopback API auth behind FLOCKS_ALLOW_INSECURE_LOCAL
  • Optional localhost CORS regex via FLOCKS_ALLOW_ANY_LOCALHOST_CORS
  • Avoid leaking traceback in generic 500 responses
  • Add regression tests

- Add URL guard and tighten webfetch/tool loading
- Restrict PTY to approved shells; authenticate PTY WebSocket before probe
- Resolve find paths via workspace guard; safer rg/grep/fd/find invocation
- Require admin for YAML plugin tool CRUD
- Gate tokenless loopback API auth behind FLOCKS_ALLOW_INSECURE_LOCAL
- Optional localhost CORS regex via FLOCKS_ALLOW_ANY_LOCALHOST_CORS
- Avoid leaking traceback in generic 500 responses
- Add regression tests

Co-authored-by: Cursor <cursoragent@cursor.com>
@xiami762 xiami762 requested a review from duguwanglong May 8, 2026 03:41
xiami762 and others added 3 commits May 8, 2026 13:15
- When runtime host is loopback, allow 127.0.0.1, ::1, and localhost
  origins for the frontend port in CORS config
- Export _FLOCKS_WEBUI_HOST/PORT in dev.sh for uvicorn so CORS matches
  the configured frontend host
- Update CORS unit test expectations

Co-authored-by: Cursor <cursoragent@cursor.com>
…guard

- Initialize server_api_token in secrets before TUI spawns hidden serve
- Add getFlocksAuthHeaders and sdk.fetch for skill install/status requests
- Remove url_guard from YAML HTTP tools and webfetch; scheme-only URL check
- Fallback to urllib in webfetch when aiohttp is unavailable
- Remove url_guard module and obsolete security tests; adjust CLI TUI test

Co-authored-by: Cursor <cursoragent@cursor.com>
…routes

- Drop loopback local-service trust and insecure/PYTEST auth bypasses; use
  HTTPConnection helpers; update README auth docs
- Remove FLOCKS_ALLOW_ANY_LOCALHOST_CORS CORS regex fallback
- PTY: expand allowed shells, filter blocked startup/linker env, add -l only
  for shells that support login mode
- Require admin for tool update/reset/refresh/reload; disable inline YAML
  execution unconditionally (use script handlers)

Co-authored-by: Cursor <cursoragent@cursor.com>
@duguwanglong duguwanglong merged commit 6bfc6bd into dev May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants