Skip to content

Security: Auto-detect Redis for rate limiting storage (#446)#498

Merged
filthyrake merged 2 commits intodevfrom
feature/446-rate-limit-redis-default
Jan 4, 2026
Merged

Security: Auto-detect Redis for rate limiting storage (#446)#498
filthyrake merged 2 commits intodevfrom
feature/446-rate-limit-redis-default

Conversation

@filthyrake
Copy link
Copy Markdown
Owner

Summary

Addresses issue #446: Rate limiting defaults to in-memory storage, which is a security vulnerability in multi-instance deployments.

  • Auto-detect Redis: If VLOG_REDIS_URL is configured, rate limiting now automatically uses Redis storage
  • Enhanced warnings: Startup warnings explicitly mention "SECURITY" and explain the attack vector
  • Updated documentation: Clear security warnings in CONFIGURATION.md
  • Non-breaking: Explicit VLOG_RATE_LIMIT_STORAGE_URL still takes precedence

Test plan

  • Verify auto-detection when VLOG_REDIS_URL is set (uses Redis)
  • Verify fallback when no Redis URL (uses memory:// with warning)
  • Verify explicit VLOG_RATE_LIMIT_STORAGE_URL takes precedence
  • Run linting (ruff check)
  • Run existing tests

Breaking changes

None. This is backwards compatible:

  • Single instance deployments: Continue using memory:// (with security warning)
  • Multi-instance with Redis: Automatically benefits from Redis rate limiting
  • Explicit configuration: Honored as before

🤖 Generated with Claude Code

filthyrake and others added 2 commits January 4, 2026 05:17
Addresses the security issue where in-memory rate limiting allows
attackers to bypass rate limits in multi-instance deployments by
distributing requests across instances.

Changes:
- Auto-detect Redis: If VLOG_REDIS_URL is configured, rate limiting
  now automatically uses Redis storage instead of in-memory
- Explicit override: VLOG_RATE_LIMIT_STORAGE_URL still takes precedence
  if explicitly set
- Enhanced warnings: Startup warnings now explicitly mention "SECURITY"
  and explain the attack vector
- Updated documentation: CONFIGURATION.md now has security warnings
  and explains auto-detection
- Updated .env.example: Better comments explaining the security issue
  and auto-detection feature

This is a non-breaking change. Existing deployments continue to work:
- Single instance: Defaults to memory:// (with warning)
- Multi-instance with Redis: Automatically uses Redis
- Explicit config: Honors VLOG_RATE_LIMIT_STORAGE_URL

Fixes #446

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changes based on specialist code review:

1. Add security warning to worker_api.py (was missing)
   - Matches admin.py and public.py warnings

2. Improve config.py clarity:
   - Better variable names: _explicit_rate_limit_storage, _redis_url_for_rate_limit
   - Avoid redundant os.getenv() calls
   - Add info log when Redis is auto-detected (aids debugging)

3. Add unit tests for auto-detection logic (tests/test_config.py):
   - test_defaults_to_memory_when_no_redis
   - test_auto_detects_redis_from_redis_url
   - test_explicit_storage_takes_precedence_over_redis_url
   - test_explicit_memory_overrides_redis_url
   - test_empty_redis_url_falls_back_to_memory

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@filthyrake filthyrake merged commit ea149e3 into dev Jan 4, 2026
3 checks passed
@filthyrake filthyrake deleted the feature/446-rate-limit-redis-default branch January 4, 2026 13:38
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