Skip to content

chore(deps): bump github.com/go-chi/chi/v5 from 5.2.5 to 5.3.0#4472

Merged
chrisgacsal merged 4 commits into
mainfrom
dependabot/go_modules/github.com/go-chi/chi/v5-5.3.0
Jun 17, 2026
Merged

chore(deps): bump github.com/go-chi/chi/v5 from 5.2.5 to 5.3.0#4472
chrisgacsal merged 4 commits into
mainfrom
dependabot/go_modules/github.com/go-chi/chi/v5-5.3.0

Conversation

@dependabot

@dependabot dependabot Bot commented on behalf of github Jun 2, 2026

Copy link
Copy Markdown
Contributor

Bumps github.com/go-chi/chi/v5 from 5.2.5 to 5.3.0.

Release notes

Sourced from github.com/go-chi/chi/v5's releases.

v5.3.0

What's Changed

New Contributors

SECURITY: middleware.ClientIP, a replacement for middleware.RealIP

@​VojtechVitek submitted PR #967, which introduces middleware.ClientIP — a replacement for middleware.RealIP that closes the three open spoofing advisories:

It also addresses issues outlined at:

middleware.RealIP is deprecated in this PR with pointers to the new API.

The deprecation only adds a // Deprecated: doc comment; the function keeps working for backward compatibility.

Why a new middleware (not "fix RealIP in place")

RealIP has two unfixable design choices: it mutates r.RemoteAddr, and it tries to be a one-size-fits-all default by walking a hard-coded list of headers any client can supply. Per adam-p's "The perils of the 'real' client IP" (which calls chi out by name on this), there is no safe default — the user must pick their trust source explicitly.

The new API

Four middlewares, two accessors. Pick exactly one middleware based on your infrastructure, read the result with one of the two accessors:

// One of the four. There is no safe default — pick exactly one.
func ClientIPFromHeader(trustedHeader string) func(http.Handler) http.Handler
func ClientIPFromXFF(trustedIPPrefixes ...string) func(http.Handler) http.Handler
func ClientIPFromXFFTrustedProxies(numTrustedProxies int) func(http.Handler) http.Handler
</tr></table> 

... (truncated)

Commits

@dependabot dependabot Bot added area/dependencies Pull requests that update a dependency file dependency/go Pull requests that update Go code release-note/dependency-update Release note: Dependency Updates labels Jun 2, 2026
@dependabot dependabot Bot requested a review from a team as a code owner June 2, 2026 10:41
@dependabot dependabot Bot added area/dependencies Pull requests that update a dependency file dependency/go Pull requests that update Go code release-note/dependency-update Release note: Dependency Updates labels Jun 2, 2026
@dependabot dependabot Bot force-pushed the dependabot/go_modules/github.com/go-chi/chi/v5-5.3.0 branch from ed56627 to 631c9f0 Compare June 11, 2026 08:44
@dependabot dependabot Bot force-pushed the dependabot/go_modules/github.com/go-chi/chi/v5-5.3.0 branch from 631c9f0 to 1c83d21 Compare June 11, 2026 09:07
Bumps [github.com/go-chi/chi/v5](https://github.com/go-chi/chi) from 5.2.5 to 5.3.0.
- [Release notes](https://github.com/go-chi/chi/releases)
- [Changelog](https://github.com/go-chi/chi/blob/master/CHANGELOG.md)
- [Commits](go-chi/chi@v5.2.5...v5.3.0)

---
updated-dependencies:
- dependency-name: github.com/go-chi/chi/v5
  dependency-version: 5.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@chrisgacsal chrisgacsal force-pushed the dependabot/go_modules/github.com/go-chi/chi/v5-5.3.0 branch from 1c83d21 to 92d7ac1 Compare June 11, 2026 11:38
@chrisgacsal chrisgacsal force-pushed the dependabot/go_modules/github.com/go-chi/chi/v5-5.3.0 branch from 92d7ac1 to 2c1fa13 Compare June 11, 2026 11:49
@chrisgacsal chrisgacsal force-pushed the dependabot/go_modules/github.com/go-chi/chi/v5-5.3.0 branch from 2c1fa13 to deb10c8 Compare June 11, 2026 11:51
@chrisgacsal chrisgacsal force-pushed the dependabot/go_modules/github.com/go-chi/chi/v5-5.3.0 branch from deb10c8 to 99b1a3f Compare June 11, 2026 12:40
@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR bumps github.com/go-chi/chi/v5 from 5.2.5 to 5.3.0 and takes advantage of the new middleware.ClientIP family to replace the deprecated (and security-advisory-carrying) middleware.RealIP. A new ClientIPMiddlewareConfig lets operators choose their trust source at startup, and pkg/server/attributes.go now reads the IP from context via middleware.GetClientIPAddr rather than from the raw r.RemoteAddr string.

  • middleware.RealIP removed — both v1 and v3 router groups now receive the configured ClientIPMiddleware, which defaults to middleware.ClientIPFromRemoteAddr (safe, no header trust). The new Config.Validate() gate ensures the field is never nil.
  • New ClientIPMiddlewareConfig in app/config/server.go supports three sources (remote-address, header, x-forwarded-for) with full startup-time validation that guards against known chi panic conditions (zero proxy count, bad CIDR notation).
  • Telemetry fix in pkg/server/attributes.goNetworkPeerAddressKey is now set from the context IP (port-free) with a correct net.SplitHostPort fallback for the no-middleware path.

Confidence Score: 5/5

Safe to merge — the default configuration uses the socket peer address only, preserving existing behaviour for deployments that do not configure clientIPMiddleware, while the new machinery closes three open chi IP-spoofing advisories for deployments that opt in.

All changed paths have startup-time validation that prevents the known chi panic conditions; the dependency bump is a straightforward minor version update with no breaking API changes; tests cover each middleware source and the critical edge cases.

No files require special attention.

Important Files Changed

Filename Overview
app/config/server.go Adds ClientIPMiddlewareConfig with thorough startup-time validation guarding chi panic conditions; default source is safe remote-address.
app/common/server.go Factory NewClientIPMiddleware correctly maps config to chi ClientIP variants; validate-before-construct pattern prevents panics.
openmeter/server/server.go Replaces deprecated middleware.RealIP in both router groups with injected ClientIPMiddleware; adds Config.Validate() nil guard.
pkg/server/attributes.go Switches NetworkPeerAddressKey to context-based IP; fallback correctly splits host/port from r.RemoteAddr.
app/common/server_test.go New tests cover all three ClientIP source modes and the silent TrustedIPPrefixes-over-TrustedProxies precedence.
app/config/server_test.go Comprehensive table-driven tests for ClientIPMiddlewareConfig.Validate(), including edge cases that would panic chi at runtime.
cmd/server/wire_gen.go Generated wire code correctly initialises ClientIPMiddleware with proper cleanup chain on error.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[HTTP Request] --> B[ClientIPMiddleware\nconfigured at startup]
    B --> C{Source}
    C -->|remote-address default| D[middleware.ClientIPFromRemoteAddr\nsocket peer only]
    C -->|header| E[middleware.ClientIPFromHeader\ntrusted overwrite header]
    C -->|x-forwarded-for| F{TrustedIPPrefixes set?}
    F -->|yes| G[middleware.ClientIPFromXFF\nCIDR-based trust]
    F -->|no| H[middleware.ClientIPFromXFFTrustedProxies\ncount-based trust]
    D --> I[ctx: clientIP stored]
    E --> I
    G --> I
    H --> I
    I --> J[RequestID / OTEL / auth middlewares]
    J --> K[GetRequestAttributes\npkg/server/attributes.go]
    K --> L{middleware.GetClientIPAddr valid?}
    L -->|yes| M[NetworkPeerAddressKey = IP]
    L -->|no| N[net.SplitHostPort r.RemoteAddr]
    N --> O[NetworkPeerAddressKey = IP\nNetworkPeerPortKey = port]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[HTTP Request] --> B[ClientIPMiddleware\nconfigured at startup]
    B --> C{Source}
    C -->|remote-address default| D[middleware.ClientIPFromRemoteAddr\nsocket peer only]
    C -->|header| E[middleware.ClientIPFromHeader\ntrusted overwrite header]
    C -->|x-forwarded-for| F{TrustedIPPrefixes set?}
    F -->|yes| G[middleware.ClientIPFromXFF\nCIDR-based trust]
    F -->|no| H[middleware.ClientIPFromXFFTrustedProxies\ncount-based trust]
    D --> I[ctx: clientIP stored]
    E --> I
    G --> I
    H --> I
    I --> J[RequestID / OTEL / auth middlewares]
    J --> K[GetRequestAttributes\npkg/server/attributes.go]
    K --> L{middleware.GetClientIPAddr valid?}
    L -->|yes| M[NetworkPeerAddressKey = IP]
    L -->|no| N[net.SplitHostPort r.RemoteAddr]
    N --> O[NetworkPeerAddressKey = IP\nNetworkPeerPortKey = port]
Loading

Reviews (2): Last reviewed commit: "fix: adding client IP to OTel attributes" | Re-trigger Greptile

Comment thread pkg/server/attributes.go Outdated
@chrisgacsal chrisgacsal assigned turip and chrisgacsal and unassigned tothandras and turip Jun 17, 2026
@chrisgacsal chrisgacsal requested review from tothandras and turip June 17, 2026 15:41
@chrisgacsal chrisgacsal merged commit 4355590 into main Jun 17, 2026
23 of 24 checks passed
@chrisgacsal chrisgacsal deleted the dependabot/go_modules/github.com/go-chi/chi/v5-5.3.0 branch June 17, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dependencies Pull requests that update a dependency file dependency/go Pull requests that update Go code release-note/dependency-update Release note: Dependency Updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants