Commit Graph

194 Commits

Author SHA1 Message Date
Abhimanyu Saharan
793c8983cb fix(ci): sort rate limit test imports 2026-03-08 00:06:45 +05:30
Abhimanyu Saharan
cc3024acc3 fix(security): Address PR review feedback 2026-03-08 00:01:23 +05:30
Abhimanyu Saharan
6d2ff60a82 fix(security): Stop logging raw trusted proxy entries 2026-03-07 23:47:00 +05:30
Abhimanyu Saharan
46bc9a02c6 fix(security): Keep short agent token prefixes in logs
Restore the existing short token-prefix logging behavior for agent auth failures while keeping the optional bearer-path rate-limit fix. Update tests and docs so the replacement branch reflects the intended logging policy.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-07 23:43:32 +05:30
Abhimanyu Saharan
fb8a932923 fix(security): Close review follow-up gaps
Rate-limit the optional agent bearer path after user auth resolution so mixed user/agent routes no longer leave an unthrottled PBKDF2 path. Stop logging token prefixes on agent auth failures and require a locally supplied token for backend/.env.test instead of committing one.

Update tests and docs to cover agent bearer fallback, configurable webhook signature headers, and the operator-facing security settings added by the hardening work.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-07 23:40:50 +05:30
Hugh Brown
e053fd4a46 fix: share a single async Redis client per URL to avoid duplicate connection pools
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
5989adedea Apply ruff reformatting 2026-03-07 23:35:10 +05:30
Hugh Brown
bafc736e03 test: make Settings construction hermetic in security header tests
Use _env_file=None and explicit base_url so tests don't depend on
global env vars or .env file loading.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
6b55b52a68 refactor: switch RedisRateLimiter to async redis.asyncio client
Replace sync redis.Redis with redis.asyncio to avoid blocking the
event loop during rate-limit checks. Make RateLimiter.is_allowed async
across both backends and update all call sites to await.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
0a749db2c4 Remove unused imports 2026-03-07 23:35:10 +05:30
Hugh Brown
3f333e1592 Add isort fix 2026-03-07 23:35:10 +05:30
Hugh Brown
f1bcf72810 feat: add trusted client-IP extraction from proxy headers
Add get_client_ip() helper that inspects Forwarded and X-Forwarded-For
headers only when the direct peer is in TRUSTED_PROXIES (comma-separated
IPs/CIDRs). Replaces raw request.client.host in rate-limit and webhook
source_ip to prevent all traffic collapsing behind a reverse proxy IP.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
fe310b50dc Apply black fixes 2026-03-07 23:35:10 +05:30
Hugh Brown
fc9fc1661c feat: add Redis-backed rate limiter with configurable backend
Add RedisRateLimiter using sorted-set sliding window alongside the
existing InMemoryRateLimiter. Users choose via RATE_LIMIT_BACKEND
(memory|redis) with RATE_LIMIT_REDIS_URL falling back to RQ_REDIS_URL.
Redis backend validates connectivity at startup and fails open on
transient errors during requests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
a66765a514 Apply ruff fixes 2026-03-07 23:35:10 +05:30
Hugh Brown
91e8270364 revert: restore GatewayRead.token field to avoid frontend breaking change
The has_token boolean redaction requires coordinated frontend changes
(detail page, edit page, orval types). Revert to returning the raw
token for now; token redaction will be handled in a dedicated PR.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
54279bf413 revert: restore truncated token_prefix in agent auth log messages
A 6-character prefix of the token is standard practice for debugging
failed auth attempts and is not a security risk. Restored in both
required and optional auth paths, and removed the now-incorrect test
that asserted its absence.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
fcbde9b0e1 test: remove duplicate rate limiter tests from test_security_fixes
These two tests were exact subsets of the dedicated test_rate_limit.py
suite. Consolidating to a single file avoids maintenance drift.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
86229038eb Update backend/tests/test_security_fixes.py
Seems like a simpler fix.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
916dace3c8 Address ruff / formatting errors 2026-03-07 23:35:10 +05:30
Hugh Brown
4960d8561b security: fix fail-open auth, streaming payload limit, and rate limiter memory leak
- agent.py: Fail closed when gateway lookup returns None instead of
  silently dropping the organization filter (cross-tenant board leak)
- board_webhooks.py: Read request body via streaming chunks so an
  oversized payload is rejected before it is fully loaded into memory
- rate_limit.py: Add periodic sweep of expired keys to prevent
  unbounded memory growth from inactive clients
- test_rate_limit.py: Add test for the new sweep behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
858575cf6c test: add comprehensive tests for all security fixes
Add 20 tests covering:
- require_user_actor: rejects agents and null users, passes valid users
- Webhook HMAC: rejects missing/invalid signatures, accepts valid ones,
  allows unsigned when no secret configured
- Prompt injection: sanitized skill name/URL, fenced external data in
  dispatch messages, system instructions precede data
- Security headers: verify nosniff, DENY, referrer-policy defaults
- Payload size: rejects oversized body and content-length
- Rate limiting: blocks after threshold, independent per-key
- Gateway token: has_token field present, token field absent
- Agent auth logs: no token_prefix in source

Also fix deprecated HTTP_413_REQUEST_ENTITY_TOO_LARGE status code.

All 407 tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Hugh Brown
94988deef2 security: add rate limiting to agent auth and webhook ingest
Agent token auth performed O(n) PBKDF2 operations per request with no
rate limiting, enabling CPU exhaustion attacks. Webhook ingest had no
rate limits either. Add an in-memory token-bucket rate limiter:
- Agent auth: 20 requests/minute per IP
- Webhook ingest: 60 requests/minute per IP

Includes unit tests for the rate limiter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 23:35:10 +05:30
Abhimanyu Saharan
532fbf1dc5 feat(config): make BASE_URL a required field and update related documentation 2026-03-05 01:36:07 +05:30
Abhimanyu Saharan
3acc276d8d fix(agent): address webhook payload read review feedback 2026-03-04 23:26:31 +05:30
Abhimanyu Saharan
3fc96baa10 feat(agent): add read-only webhook payload fetch endpoint for backfill 2026-03-04 23:22:27 +05:30
Abhimanyu Saharan
f5e3b8923a test: assert blocked precondition in dependency-only update test 2026-03-04 23:09:56 +05:30
Abhimanyu Saharan
636c130a3b test: harden blocked-task regression tests per review 2026-03-04 23:01:24 +05:30
Abhimanyu Saharan
130947dcea test: format blocked-task schema regression assertions 2026-03-04 22:52:43 +05:30
Abhimanyu Saharan
6f7867872b test: fix import order for blocked dependency regression test 2026-03-04 22:50:47 +05:30
Abhimanyu Saharan
e9ce004e70 test: address PR review feedback for blocked-task schema 2026-03-04 22:46:44 +05:30
Abhimanyu Saharan
8b77eae0f2 Document blocked-task 409 error code in OpenAPI + add regression tests 2026-03-04 22:46:44 +05:30
Abhimanyu Saharan
4378d354f4 fix(ci): resolve backend check failures in dashboard metrics 2026-03-04 16:11:14 +05:30
Abhimanyu Saharan
bdc9fc3f01 redesigned dashboard page 2026-03-04 16:01:56 +05:30
Abhimanyu Saharan
d4f9831ecb fix(agent): refine agent update retry logic to handle creation race conditions #193 2026-03-03 03:19:11 +05:30
Abhimanyu Saharan
94ae59d6aa refactor(gateway): update gateway parameters to use None as default #169 2026-03-03 01:51:52 +05:30
Abhimanyu Saharan
348b0515ac feat(boards): implement lead notification on board updates with detailed change messages 2026-02-26 01:58:55 +05:30
Abhimanyu Saharan
bc71d5ba38 refactor(page): improve code formatting for better readability in event handlers 2026-02-26 00:36:33 +05:30
Abhimanyu Saharan
6b21ea6f99 feat(boards): add 'comment_required_for_review' rule and update related logic 2026-02-26 00:31:47 +05:30
Abhimanyu Saharan
adad72373c feat(tasks): add notification messages for task assignment and rework 2026-02-25 18:29:59 +05:30
Abhimanyu Saharan
5b0ddcc7cd refactor(tests): format code for better readability in test files 2026-02-25 03:41:03 +05:30
Abhimanyu Saharan
58db8be117 fix(security): update security header names to lowercase and add tests 2026-02-25 03:39:49 +05:30
Abhimanyu Saharan
d9af5d3bc7 Merge branch 'master' into master 2026-02-25 00:42:48 +05:30
Abhimanyu Saharan
0795f78eff feat: implement unified agent lifecycle orchestration and metadata tracking 2026-02-25 00:34:04 +05:30
Simone
3fd5fe5f8c fix: make security headers configurable and add tests 2026-02-24 17:36:44 +01:00
copilot-swe-agent[bot]
1967e9583d feat: upgrade FastAPI to 0.130.0 and implement ORJSONResponse for performance
Co-authored-by: abhi1693 <5083532+abhi1693@users.noreply.github.com>
2026-02-22 22:13:52 +00:00
Abhimanyu Saharan
2d3c3ee3e4 feat: add config fallback for gateway version compatibility check 2026-02-23 01:23:09 +05:30
Abhimanyu Saharan
6b09f124e6 refactor: rename compatibility check function and update version extraction logic #159 2026-02-22 22:05:39 +05:30
Abhimanyu Saharan
62e3c267b5 feat: add allow_insecure_tls parameter to agent configuration 2026-02-22 20:24:41 +05:30
Abhimanyu Saharan
56f4964332 feat: add support for allowing self-signed TLS certificates in gateway configuration 2026-02-22 20:20:19 +05:30