Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Rate Limiter Laravel Package

symfony/rate-limiter

Symfony Rate Limiter provides a token bucket implementation for rate limiting input and output in PHP applications. Configure policies and storage with RateLimiterFactory, then reserve tokens to wait or consume tokens to check acceptance.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Token Bucket Algorithm: Still the right fit for Laravel's predictable, burst-tolerant limiting (auth flows, payment APIs). The reserve()/consume() pattern continues to integrate cleanly with middleware, queues, and CLI workflows.
  • Change in this release: PR #65747 ("Cap the burst size and the duration computed from it") is the same fix previously attributed to v8.1.6 in our assessment. v5.4.54 confirms it has been backported to the 5.4 LTS branch and — critically — the release is flagged [SECURITY] Security release. This reclassifies the defect from "edge-case bug" to "security-relevant defect." Burst-size/duration computation errors can produce either unintended throttling (availability impact) or an over-large allowance (limit-bypass impact); we should treat both as in-scope until the advisory text is read.
  • Policy Flexibility: Unchanged — Token Bucket, Fixed Window, and Sliding Window remain available.
  • Compound Limiting: Unchanged — CompoundRateLimiterFactory still supports multi-dimensional limits (per-IP and per-user) for SaaS tiering.
  • Laravel Synergy: Unchanged — works with Redis, database, and file storage via StorageInterface.

Integration Feasibility

  • Middleware Integration: No API changes. The fix is internal to burst/duration computation.
  • Queue Jobs: Unchanged — consume()/reserve() patterns still apply.
  • CLI Commands: Unchanged.
  • New consideration: The availability of this fix on both 5.4.x and 8.1.x means we must confirm which branch each application actually resolves via Composer before claiming remediation. A "we're on 8.1.6" assertion is only true for services pinned there.

Technical Risk

  • Security Classification (new, elevated): The release is marked a security release. Risk is no longer "cosmetic throttling anomaly" but potentially rate-limit enforcement integrity. Mitigation: prioritise patching, obtain the advisory/CVE detail, and re-validate token bucket configurations against the new cap.
  • Version Drift / Branch Confusion (new): Our prior assessment described the fix as landing in v8.1.6 with PHP 8.1+. The same PR now ships in v5.4.54 on the 5.4 LTS line. Two supported branches carry the fix; applications on the older branch are exposed if we assumed the 8.1 patch covered everything. Mitigation: run a dependency inventory (composer show symfony/rate-limiter) across all services and map resolved versions to patched minimums (≥5.4.54 or ≥8.1.6).
  • Storage Backend: Unchanged — InMemoryStorage is non-persistent; Redis (RedisStorage) or database (DoctrineStorage) remains mandatory for distributed environments.
  • Concurrency: Unchanged — high-concurrency/serverless requires Redis to avoid race conditions.
  • Unserialize Security: The Unsafe unserialize PHPStan rule (v8.1.1) remains present and may warn on unrelated unserialize() usage. Mitigation: keep PHPStan in CI; avoid custom serialization in rate-limiter storage.
  • 5.4 Branch Status (new): Receipt of a security backport on 5.4 confirms the branch is in security-fix-only mode — no new features or non-security bug fixes. Anything we build on 5.4 is frozen in capability.

Key Questions

  1. Which branch do we actually run? Per service: symfony/rate-limiter resolved version, and is it ≥5.4.54 / ≥8.1.6?
  2. What is the security impact? Is there a CVE/advisory? Is the exploitable condition over-permissive limiting (bypass) or over-restrictive (DoS)? This drives whether this is an emergency change or a normal patch.
  3. Burst Size Configuration: Do existing token bucket policies set burst sizes above the new cap? If so, effective allowances change on upgrade — confirm intended behaviour.
  4. Storage Strategy: Per-request (in-memory) vs distributed (Redis/database)?
  5. Policy Selection: Token Bucket, Fixed Window, or Sliding Window per use case?
  6. Error Handling: How are 429 Too Many Requests responses standardised?
  7. Observability: Are rate-limiting events logged for audit/SOC 2?
  8. Performance: Will Redis latency affect high-throughput API response times?
  9. Fallbacks: What happens if the rate-limiter storage fails?
  10. PHPStan Compliance: Does the codebase use unserialize() elsewhere, and will the rule require refactoring?
  11. 5.4 Exit Plan (new): If any service is on the 5.4 branch, what is the timeline to a supported feature branch? Security-only support is a standing risk, not a one-off.

Integration Approach

Stack Fit

  • Laravel Ecosystem: Unchanged — middleware, service container, caching.
  • Symfony Integration: Unchanged — HTTP Client, Messenger, Cache.
  • Third-Party: Unchanged — Redis, database, filesystem storage.
  • New: The package now demonstrably spans the 5.4 LTS and 8.1+ lines. Stack fit must be evaluated per resolved branch, not per package name.

Migration Path

  1. Inventory (new, do first): Enumerate every service's resolved symfony/rate-limiter version and target patched minimum (≥5.4.54 or ≥8.1.6).
  2. Assessment Phase: Audit current rate-limiting mechanisms and any token bucket burst sizes near/over the new cap.
  3. Pilot Implementation: Non-critical endpoints first; observe whether capping changes observed throttling rates.
  4. Core Integration: Replace throttle middleware; integrate with queues/CLI.
  5. Rollout: Feature flags plus error/latency monitoring.

Compatibility

  • Laravel Versions: Unchanged — Laravel 9+ (PHP 8.0+) and Laravel 8 (PHP 7.4+ with ^7.4); the package itself requires PHP 8.1+ on the 8.1 line, while the 5.4 line serves older runtimes.
  • Symfony Components: Unchanged — HTTP Client, Messenger, Cache.
  • Storage Backends: Unchanged — Redis, database, filesystem.
  • PHPStan: Ensure the Unsafe unserialize rule doesn't flag false positives in unrelated code.
  • Version Note (updated): Two patch releases carry PR #65747 — v8.1.6 and v5.4.54. Neither introduces breaking API changes. Both are safe to adopt within their respective lines. The 5.4.54 release is additionally labelled a security release, which raises its deployment priority above a routine patch.

Sequencing

  1. Phase 0a: Dependency inventory and branch mapping across all services.
  2. Phase 0b: Patch to ≥5.4.54 / ≥8.1.6, prioritising internet-facing services with auth or payment-adjacent limits.
  3. Phase 1: Core HTTP rate limiting.
  4. Phase 2: Queue and CLI integration.
  5. Phase 3: Advanced policies, with burst sizes re-tuned to the new cap.
  6. Phase 4: Observability.
  • Run PHPStan in CI before proceeding to catch unserialize warnings.

Operational Impact

Maintenance

  • Dependency Management: Update symfony/rate-limiter to ≥5.4.54 or ≥8.1.6, aligned with Symfony/Laravel constraints. Add a recurring check that no service sits below the patched minimum.
  • Configuration: Unchanged centralised config/rate_limiter.php, but review burst-size settings against the new cap — this is now a security-relevant configuration review, not just tuning.
  • Storage Maintenance: Unchanged — monitor Redis memory / database indexing.
  • Security Scanning: Keep PHPStan in CI; add advisory/CVE monitoring for symfony/* so security-labelled releases are routed to the on-call patch process rather than the normal backlog.

Support

  • Troubleshooting: Largely unchanged (Retry-After, Redis drops). The cap fix reduces burst-related anomalies and eliminates a class of "limits behaved unexpectedly" tickets.
  • Documentation: Unchanged for policies/storage/error responses; add a note recording which branch each service uses and the patched minimum.
  • Security Runbook (new): Define how a [SECURITY]-tagged dependency release is triaged, who approves an out-of-cycle deploy, and the SLA for applying it.

Scaling

  • Horizontal Scaling: Unchanged — Redis Cluster or database sharding.
  • Branch Lifecycle (new): Any service still on the 5.4 line will not receive new capability, only security patches. Capacity/feature planning must assume that branch is static.
  • CI Cost: PHPStan additions may slow pipelines; measure before mandating repo-wide.

Failure Modes

  • Limit-Bypass / Over-Restriction via Burst Computation (now security-classified): Pre-patch versions may compute allowances incorrectly for large burst sizes or durations. Mitigation: upgrade to ≥5.4.54 / ≥8.1.6 and validate existing token bucket configs against the cap.
  • Unpatched Legacy Branch (new): A service pinned to an older 5.4.x patch level remains exposed even though the fix exists. Mitigation: inventory plus enforced minimum version in CI.
  • Unserialize Risks: Audit unserialize() usage; restrict to trusted internal data.
  • Storage Failures: Redis/database outages disrupt limiting. Mitigation: fallback to in-memory with degraded, stricter limits, and alert.

Ramp-Up

  • Developer Onboarding: Unchanged — document the rate-limiter setup. Add the branch/version matrix so engineers know which line they're on.
  • Security Process Training (new): Ensure the team recognises [SECURITY] release tags and knows the escalation path.
  • PHPStan Training: If adopted, ensure developers understand the new rule's implications.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel