Skip to content

security: harden CORS, rate limits, /health, and SQLite compat (1.0.0a5) - #27

Merged
Yurii201811 merged 1 commit into
mainfrom
codex/tasksignal-1.0.0a5
Nov 21, 2026
Merged

Yurii201811 merged 1 commit into
mainfrom
codex/tasksignal-1.0.0a5

Conversation

@Yurii201811

@Yurii201811 Yurii201811 commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Addresses the remaining hardening recommendations from security advisory GHSA-5v46-prgf-5hxf and prepares 1.0.0a5:

  • Tightens CORSMiddleware from wildcard * methods/headers to explicit HTTP methods and headers.
  • Adds configurable sliding-window rate limiting (RATE_LIMIT_REQUESTS_PER_MINUTE, defaulting to 60/min outside ENVIRONMENT=local, disabled in local dev) on POST /api/scans, POST /api/process/demo, and POST /api/search/semantic.
  • Redacts internal runtime config (llm_provider, embedding_model) from unauthenticated /health responses outside ENVIRONMENT=local.
  • Validates SQLite compatibility table/column/index identifiers against a strict regex before executing hardcoded ALTER TABLE / CREATE INDEX statements.
  • Bumps API/web package metadata, lockfiles, and changelog to 1.0.0a5 / 1.0.0-alpha.5 and passes scripts/release_check.py --version 1.0.0a5 --require-clean.

Note

Medium Risk
Changes request handling for CORS, high-load POST routes, and /health in non-local deployments; misconfiguration could block legitimate clients or hide diagnostics until operators authenticate.

Overview
Prepares 1.0.0a5 with API security hardening aligned to advisory GHSA-5v46-prgf-5hxf.

CORS no longer allows wildcard methods/headers; only explicit verbs and headers (Content-Type, X-Operator-Scan-Token, Authorization, Accept) are permitted.

Rate limiting adds an in-process sliding-window cap via RATE_LIMIT_REQUESTS_PER_MINUTE (default 60/min in non-local environments, off when ENVIRONMENT=local) for POST on /api/scans, /api/process/demo, and /api/search/semantic, returning 429 with Retry-After.

Outside local, unauthenticated /health returns only {status: ok}; full runtime fields (llm_provider, embedding_model) require a valid operator token.

SQLite compat migrations now validate table/column/index names with a strict regex before running hardcoded ALTER TABLE / CREATE INDEX statements.

Version metadata, lockfiles, changelog, and new regression tests in test_security_hardening.py are updated accordingly.

Reviewed by Cursor Bugbot for commit 2de5368. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 2de5368. Configure here.

Comment thread apps/api/app/main.py

CORS_ALLOWED_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]
CORS_ALLOWED_HEADERS = ["Content-Type", "X-Operator-Scan-Token", "Authorization", "Accept"]
RATE_LIMITED_POST_PATHS = frozenset({"/scans", "/process/demo", "/search/semantic"})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Canonical semantic search endpoint bypasses rate limiting

High Severity

RATE_LIMITED_POST_PATHS only includes "/search/semantic", which is the hidden compatibility alias for semantic_search_route in apps/api/app/api/routes.py. Requests to the canonical, OpenAPI-documented endpoint (POST /api/v1/search and POST /api/search, also used by apps/web/src/lib/api.ts) return None from _normalize_rate_limit_path and bypass rate limiting completely.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2de5368. Configure here.

@Yurii201811
Yurii201811 merged commit 66b7428 into main Nov 21, 2026
14 checks passed
@Yurii201811
Yurii201811 deleted the codex/tasksignal-1.0.0a5 branch November 21, 2026 18:33
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.

1 participant