Skip to content

Fix peer IP tags in Jetty/Dropwizard and Play 2.3/2.4/2.5#11237

Draft
smola wants to merge 3 commits intomasterfrom
smola/dropwizard-peer-ip
Draft

Fix peer IP tags in Jetty/Dropwizard and Play 2.3/2.4/2.5#11237
smola wants to merge 3 commits intomasterfrom
smola/dropwizard-peer-ip

Conversation

@smola
Copy link
Copy Markdown
Member

@smola smola commented Apr 30, 2026

What Does This Do

Jetty's ForwardedRequestCustomizer (enabled by default in Dropwizard) and
Play's RequestHeader#remoteAddress() both return the IP resolved from
x-forwarded-for / similar proxy headers. That value is correct for
http.client_ip but must not be reported as the actual socket peer
(peer.ip, peer.port, network.client.ip).

Jetty / Dropwizard (APPSEC-62560):

  • Read the unwrapped socket address directly from the Jetty channel /
    endpoint in every JettyDecorator (jetty 7.0, 7.6, 9, 10, 11, 12).
  • Add jetty-server-9.0 as a testImplementation of dropwizard-0.8 so the
    test classpath matches production (Jetty owns the server span; Servlet3
    skips when it sees the existing context). Update DropwizardTest's
    expectedIntegrationName to jetty-server.

Play 2.3 / 2.4 / 2.5 (APPSEC-62562):

  • In PlayHttpServerDecorator, wrap the Request handed to super.onRequest
    with a play.api.mvc.WrappedRequest whose remoteAddress() returns the
    peer IP already captured on the span by the upstream akka / netty
    instrumentation. This prevents super.onRequest -> peerHostIP from
    overwriting the real socket peer with the forwarded value, and keeps
    IG callbacks consistent. Mirrors the Play 2.6+ behavior already
    provided by RemoteConnectionWithRawAddress.

HttpServerTest:

  • Tighten PEER_HOST_IPV4 / PEER_HOST_IPV6 assertions on the FORWARDED
    endpoint to strictly expect the loopback address.

Motivation

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

Dropwizard 0.8 runs on Jetty 9.2.9, where jetty-server owns the
request span in production. Add jetty-server-9.0 and jetty-server-9.0.4
as test dependencies so the test classpath matches, and update the
expected integration name on DropwizardTest accordingly.
@smola smola added type: bug Bug report and fix comp: core Tracer core inst: play framework Play Framework instrumentation inst: jetty Jetty instrumentation tag: ai generated Largely based on code generated by an AI or LLM labels Apr 30, 2026
@smola
Copy link
Copy Markdown
Member Author

smola commented Apr 30, 2026

@codex review

@smola
Copy link
Copy Markdown
Member Author

smola commented Apr 30, 2026

@cursor review

Jetty's ForwardedRequestCustomizer (enabled by default in Dropwizard) and
Play's RequestHeader#remoteAddress() both return the IP resolved from
x-forwarded-for / similar proxy headers. That value is correct for
http.client_ip but must not be reported as the actual socket peer
(peer.ip, peer.port, network.client.ip).

Jetty / Dropwizard (APPSEC-62560):
- Read the unwrapped socket address directly from the Jetty channel /
  endpoint in every JettyDecorator (jetty 7.0, 7.6, 9, 10, 11, 12).
- Add jetty-server-9.0 as a testImplementation of dropwizard-0.8 so the
  test classpath matches production (Jetty owns the server span; Servlet3
  skips when it sees the existing context). Update DropwizardTest's
  expectedIntegrationName to jetty-server.

Play 2.3 / 2.4 / 2.5 (APPSEC-62562):
- In PlayHttpServerDecorator, wrap the Request handed to super.onRequest
  with a play.api.mvc.WrappedRequest whose remoteAddress() returns the
  peer IP already captured on the span by the upstream akka / netty
  instrumentation. This prevents super.onRequest -> peerHostIP from
  overwriting the real socket peer with the forwarded value, and keeps
  IG callbacks consistent. Mirrors the Play 2.6+ behavior already
  provided by RemoteConnectionWithRawAddress.

HttpServerTest:
- Tighten PEER_HOST_IPV4 / PEER_HOST_IPV6 assertions on the FORWARDED
  endpoint to strictly expect the loopback address.
@smola smola force-pushed the smola/dropwizard-peer-ip branch from 9e0707c to 3c754f3 Compare April 30, 2026 09:26
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: core Tracer core inst: jetty Jetty instrumentation inst: play framework Play Framework instrumentation tag: ai generated Largely based on code generated by an AI or LLM type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant