Skip to content

Add Current IP and visitor exclusion use inconsistent client IP sources #40

Open

Description

@jdevalk

Problem

The IP settings UI saves REMOTE_ADDR, while tracking prefers the entire HTTP_X_FORWARDED_FOR header. A different forwarded value, or a comma-separated proxy chain, prevents the saved address from matching. Forwarded headers are also trusted without validating the proxy.

Reproduction

  1. Behind a reverse proxy, use Add Current IP, save, then revisit the site from the same browser.
  2. Inspect whether tracking is suppressed by the IP rule.
  3. For a controlled proxy-chain case, use an exclusion of 203.0.113.10 and X-Forwarded-For: 203.0.113.10, 10.0.0.1.

Actual: the live same-browser visit was excluded by its user role rather than its saved IP; the anonymous visit still received the tracking script. The controlled chain never matches the individual address.
Expected: the UI and tracking use the same validated client-IP policy.

Evidence

Reproduced with plugin 1.109. The live request's exact forwarded header was not captured, so its precise proxy chain remains unverified.

src/TrackingRules.php:16-22 compares the entire forwarded header; src/Settings/Blocks/Fields/IpList.php:41 displays REMOTE_ADDR.

Acceptance

Share one IP resolver between the UI and tracking. Do not trust arbitrary forwarded headers; provide a documented way for trusted proxy deployments to supply a validated address. Cover direct requests, forwarded headers, malformed input, and address normalization.

Update

Decisions since this issue was opened, now in #46:

  • The forwarded address stays trusted. Existing sites exclude visitors by the address in X-Forwarded-For, so ignoring it would silently stop their exclusions. A visitor who spoofs the header can only exclude themselves. This replaces "Do not trust arbitrary forwarded headers" in the acceptance criteria. Sites that need a stricter policy can use the simpleanalytics_client_ip filter.
  • Proxy chains use the first public address. An office or local proxy reports the visitor's private address first, for example 192.168.1.20, 203.0.113.10. Private, loopback and invalid entries are skipped, so 203.0.113.10 is used. A chain with only private addresses still uses its first one, so intranet and local exclusions keep working. Koko Analytics and Burst Statistics choose the same way; WordPress core itself only uses REMOTE_ADDR.
  • REMOTE_ADDR is only used without the header. Earlier releases saved the proxy's address through Add Current IP, so matching it would exclude every visitor behind that proxy.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions