Skip to content

security: rate limiter trusts ClientIP without configuring TrustedProxies #35

Description

@deannos

Description

gin.Engine defaults TrustedProxies to trusting all IPs. When deployed behind a reverse proxy, c.ClientIP() returns whatever X-Forwarded-For says — which is spoofable by any client. This makes the IP-based rate limiter and the logged client_ip trivially bypassable.

Location

  • router/router.go:28 (engine creation)
  • middleware/rate_limit.go:67

Fix

Call r.SetTrustedProxies([]string{"127.0.0.1"}) (or the actual proxy CIDRs) after creating the engine, or expose a TRUSTED_PROXIES config variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions