Share sensitive information with cellar. End to end encryption, always free. No sign-up required.

Rate Limiting

INFO

Rate limiting is available in Cellar API v3.4.0+

Cellar includes built-in rate limiting to protect your deployment from abuse, resource exhaustion, and denial-of-service attacks. Rate limiting is enabled by default and uses a Redis-backed sliding window algorithm.

Overview

Rate limiting restricts the number of API requests a client can make within a time window. When a client exceeds their limit, Cellar returns HTTP 429 (Too Many Requests) with information about when they can retry.

Key Features:

  • Tiered approach: Different limits for different operation costs
  • Per-client tracking: Limits apply per IP address (supports X-Forwarded-For)
  • Sliding window: Smooth rate limiting without burst allowances
  • Standard headers: RFC-compliant rate limit headers on all responses
  • Fail-open: Allows requests if Redis is unavailable (logs warning)
  • Production-ready: Enabled by default

Rate Limit Tiers

Cellar applies different limits based on operation cost:

Tier 1: Expensive Operations (300 requests/minute)

Endpoints:

  • POST /api/v1/secret - Create secret (v1)
  • POST /api/v2/secret - Create secret (v2)
  • POST /api/v1/secret/:id/access - Access secret content (v1)
  • POST /api/v2/secret/:id/access - Access secret content (v2)

Rationale: These operations involve cryptography (encryption/decryption). The default limit of 300 requests/minute (5 requests/second) aligns with professional-tier REST API standards while remaining conservative relative to underlying cryptography backend capacity. This limit prevents abuse while allowing normal team usage patterns and burst activity.

Tier 2: Moderate Operations (600 requests/minute)

Endpoints:

  • GET /api/v1/secret/:id - Get secret metadata (v1)
  • GET /api/v2/secret/:id - Get secret metadata (v2)
  • DELETE /api/v1/secret/:id - Delete secret (v1)
  • DELETE /api/v2/secret/:id - Delete secret (v2)

Rationale: These operations query or modify the datastore but don’t involve cryptography. They are less expensive than Tier 1 but still require backend access. The 2x multiplier relative to Tier 1 allows common UI workflows like get metadata → decrypt → delete without hitting rate limits.

Tier 3: Lightweight Operations (1,200 requests/minute)

Endpoints:

  • GET /api/v2/config - Query configuration limits

Rationale: This endpoint returns cached configuration values with no backend operations. Higher limit allows API clients to frequently query limits before submission without concern for rate limiting.

Health Check: Monitoring (1,200 requests/minute)

Endpoints:

  • GET /health-check - Health check endpoint

Rationale: Monitoring systems need frequent health checks. Very high limit prevents false negatives in monitoring without creating abuse risk, as health checks perform minimal work.

HTTP Response Headers

Cellar includes standard rate limit headers on all responses:

On All Responses (200, 201, 400, 404, etc.):

  • X-RateLimit-Limit: 300 - Maximum requests allowed in window for this endpoint tier
  • X-RateLimit-Remaining: 287 - Requests remaining in current window
  • X-RateLimit-Reset: 1736705220 - Unix timestamp when window resets

On 429 Too Many Requests:

  • All headers above (with X-RateLimit-Remaining: 0)
  • Retry-After: 42 - Seconds until rate limit resets

Example:

HTTP/1.1 429 Too Many Requests
Content-Type: application/json
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1736705220
Retry-After: 42

{
  "error": "rate limit exceeded"
}

Configuration

Rate limiting is configured through environment variables. See the Configuration Reference - Current Version for complete rate limiting settings and defaults.

Behavior and Edge Cases

Client Identification

  • Rate limits apply per client IP address
  • Supports X-Forwarded-For header for clients behind proxies/load balancers
  • Uses leftmost IP in X-Forwarded-For chain (the original client)

Sliding Window Algorithm

  • Uses Redis-backed sliding window (not fixed window)
  • Smooth rate limiting without burst allowances
  • Example: 10 requests/minute means 10 requests in any 60-second period

Redis Unavailable

  • Fail-open behavior: Allows requests to proceed
  • Logs warning: “Rate limiter failed, allowing request”
  • Prevents cascading failures (rate limiter doesn’t take down the application)
  • Monitor logs for Redis connectivity issues

Distributed Deployments

  • Rate limits are shared across all API instances (backed by Redis)
  • Multiple Cellar API instances share the same rate limit counters
  • Consistent behavior regardless of which instance handles the request

Adjusting Limits

The default limits align with professional-tier REST API standards and are suitable for most deployments, including medium-sized organizations. Consider adjusting if:

Increase limits when:

  • Serving many legitimate users from shared IPs (corporate NAT, VPN gateways)
  • Running automated workflows that create/access many secrets
  • Supporting large enterprise usage patterns
  • Performance testing or load testing

Decrease limits when:

  • Facing sustained abuse or attack
  • Running on resource-constrained infrastructure
  • Operating a public demo or free-tier service
  • Enforcing strict usage policies

Monitoring and Troubleshooting

Logs

Rate limit violations are logged at INFO level:

Rate limit exceeded for client 192.168.1.100 on tier tier1

Metrics

Monitor these patterns:

  • Frequent 429 responses from legitimate users → increase limits
  • High rate limit violations → potential abuse or misconfigured client
  • Rate limiter warnings → Redis connectivity issues

Common Issues

“Rate limit exceeded” for legitimate users:

  • Check if users are behind shared NAT/proxy
  • Review X-Forwarded-For configuration
  • Consider increasing limits for affected tiers

Rate limiting not working:

  • Verify RATE_LIMIT_ENABLED=true
  • Check Redis connectivity
  • Ensure Redis is shared across all API instances

False positives from monitoring:

  • Increase RATE_LIMIT_HEALTH_CHECK_REQUESTS_PER_WINDOW
  • Configure monitoring to respect Retry-After header

Security Considerations

What Rate Limiting Protects

  • Brute force attacks: Limits secret ID guessing attempts
  • Resource exhaustion: Prevents CPU/memory exhaustion via crypto operations
  • Automated abuse: Slows down automated secret creation/access
  • Cost control: Limits cryptography operations (relevant for KMS usage billing)

What Rate Limiting Does Not Protect

  • Distributed attacks: Single attacker with many IPs can exceed limits
  • Compromised secrets: Rate limiting doesn’t prevent access with valid link
  • Application vulnerabilities: Not a substitute for proper security measures

Additional Resources