Skip to content

fix(http): read the client address from trusted proxies - #22

Merged
roncodes merged 1 commit into
release/v2.0.0from
fix/trust-proxies
Nov 27, 2026
Merged

roncodes merged 1 commit into
release/v2.0.0from
fix/trust-proxies

Conversation

@roncodes

Copy link
Copy Markdown
Member

Found while checking the qa deployment.

The fault

The service never told Laravel to trust the load balancer, so $request->ip() was the balancer's address for every request. Every rate limit that counts per address was shared by all clients on a balancer node:

  • auth: 10 sign-ins, registrations or password resets a minute, for everyone together
  • instance-register: 10 a minute
  • catalog: 300 a minute, across all anonymous traffic
  • packages: anonymous npm and Composer reads

On qa, X-RateLimit-Remaining on /v1/catalog counted down separately for each of the three balancer addresses and was unaffected by who called.

The change

  • config/trustedproxy.php: proxies in the private and loopback ranges are trusted by default; TRUSTED_PROXIES overrides (addresses, CIDR ranges, or *). An ECS task behind an ALB needs no configuration.
  • Only the address, scheme and port are read from the proxy. X-Forwarded-Host is not: an ALB passes a client's own value through, and the public host is REGISTRY_PUBLIC_URL.
  • The address taken is the one the proxy appended, so a client cannot pick its own by sending X-Forwarded-For.
  • tests/Feature/TrustedProxiesTest.php covers each of these.

Docs

  • README: TRUSTED_PROXIES in the configuration table and the deployment list.
  • Runbook step 2 and the README deployment list now say to seed the categories (php artisan registry:seed --force). A fresh deployment has none: qa's /v1/catalog/categories is [], and the Studio's category list is empty with it.

After merging

Push to deploy/qa. To check: the remaining count on /v1/catalog/extensions/x should continue across the balancer's addresses instead of starting again on each.

Behind the load balancer every request arrived from the balancer's
address, so all clients shared one rate-limit bucket per balancer node:
ten sign-ins a minute for everyone together. Seen on qa, where the
remaining count on /v1/catalog was separate per balancer address and
did not change with the caller.

Proxies in the private and loopback ranges are trusted by default
(TRUSTED_PROXIES overrides), for the address, scheme and port only.
X-Forwarded-Host is not read.

Also: the runbook and the README say to seed the categories, which a
fresh deployment does not have.
@roncodes
roncodes merged commit a88c2eb into release/v2.0.0 Nov 27, 2026
6 checks passed
@roncodes
roncodes deleted the fix/trust-proxies branch November 27, 2026 07:03
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