Skip to content

IBX-11181: Fixed setting Trusted Proxies on Ibexa Cloud - #699

Merged
alongosz merged 4 commits into
4.6from
IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud
Oct 29, 2026
Merged

alongosz merged 4 commits into
4.6from
IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud

Conversation

@vidarl

@vidarl vidarl commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor

Caution

When merging up to 5.0, remove TrustedHeaderClientIpEventSubscriber from core rather than resolving the conflicts in it. On 5.x the Ibexa Cloud logic lives in ibexa/cloud (ibexa/cloud#13).

Remove:

  • src/bundle/Core/EventSubscriber/TrustedHeaderClientIpEventSubscriber.php
  • tests/bundle/Core/EventSubscriber/TrustedHeaderClientIpEventSubscriberTest.php
  • its service definition in src/bundle/Core/Resources/config/services.yml
  • the phpstan-baseline.neon entries for both files
🎫 Issue IBX-11181

Related PRs:

Description:

Trusted proxies are not set on Ibexa Cloud when using Fastly. We document (via Upsun,) that user must disable TRUSTED_PROXIES: "REMOTE_ADDR" in .platform.app.yaml (which is correct), but we don’t say or specify how to configure TRUSTED_PROXIES correctly.

And frankly, it is not easy/possible to do via static config given how the Upsun router behaves:

Upsun router behavior:

  • Will not filter X-FORWARD-FOR sent by malicious client
  • It will add client's IP to X-FORWARD-FOR, appending header if already set ( "1.1.1.1" => "1.1.1.1, 2.2.2.2")
  • It will always set a X-Client-IP header ( value is IP of client). Value is also end-user's IP if request is received via Fastly ( doc )
  • Will filter Client-Cdn if request is not originating from any supported CDN ( doc )
    • When received from Fastly, value of header will be fastly
  • $_SERVER['REMOTE_ADDR'] will be spoofed, will have same value as X-Client-IP

So there is no static IP or IP range you can set as trusted proxies when using Fastly on Upsun. For instance, setting trusted hosts to Fasty's public IP list will not do any good. Thus, Ibexa DXP should automatically detect on Ibexa Cloud if request is received via Fastly

Next, I really doesn't understand the original purpose of TrustedHeaderClientIpEventSubscriber. It basically does this:

  • If running on Upsun (formerly known as Platform.sh), the request header X_FORWARDED_FOR will be set (value will be copied from the X-Client-IP request header) and X_FORWARDED_FOR will be set as trusted_headers
  • However, this header will still be ignored unless devs somehow also sets trusted_proxies correctly.
  • Also, the subscriber can be configured to use some other header than X-Client-IP as source

My next doubt is why there was some need for this in relation to IBX-4046
FYI : Original PR : https://github.com/ibexa/core/pull/165/files

As the Upsun router anyway sets the X-Forward-For header, and devs still needed to set trusted_proxies in config ( which IMO is impossible), the old implementation in TrustedHeaderClientIpEventSubscriber is void.
But it certainly may be that I am missing something important....?

What the new implementation of TrustedHeaderClientIpEventSubscriber does:

  • If we are on Ibexa Cloud and request is coming from Fastly, then we declare that the request is received via trusted proxy

For QA:

Maybe do sanity checks with "create Applications for Customer portal" feature, as original implementation of TrustedHeaderClientIpEventSubscriber was implemented in relation to that.

Documentation:

  • We have now removed the ibexa.trusted_header_client_ip_name setting that was available but commented out by default in config/packages/ibexa.yaml. It was not referred to anywhere else AFAIK, and I don't think anyone ever used that setting. so not sure it needs mentioning anywhere
  • In general we now support using trusted headers ( X-FORWARDED-.... ) on Ibexa Cloud when using Fastly; This will now actually cause X-FORWARDED-HOST to be trusted and have an affect:
    # config/packages/framework.yaml
    framework:
       (...)
       trusted_headers: ['x-forwarded-host']

@vidarl
vidarl changed the base branch from main to 4.6 January 14, 2026 13:57
@vidarl
vidarl force-pushed the IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud branch from 38c87b6 to 17e4096 Compare January 14, 2026 14:00
@vidarl
vidarl force-pushed the IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud branch from 17e4096 to b1a199d Compare January 14, 2026 14:37
@sonarqubecloud

Copy link
Copy Markdown

@vidarl
vidarl requested a review from a team January 19, 2026 15:03
@vidarl
vidarl force-pushed the IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud branch from ec3cba0 to d53633c Compare July 30, 2026 07:31
@sonarqubecloud

Copy link
Copy Markdown

@konradoboza konradoboza left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR can be rebased as #794 got merged, it contains PHPStan issues fix.

A few questions:

PR for filtering X-Forward-For in varnish and fastly VCLs are comming

Do we have this PR already? It should most likely incorporate X-Forward-For and X-Forward-Host in our VCL, right?

Shouldn't this indeed belong to ibexa/fastly since it's covering this very case? It will also make more sense concerning merging up the changes.

In regards to:

As the Upsun router anyway sets the X-Forward-For header, and devs still needed to set trusted_proxies in config ( which IMO is impossible), the old implementation in TrustedHeaderClientIpEventSubscriber is void.
But it certainly may be that I am missing something important....?

https://github.com/ibexa/post-install/blob/4.6/resources/platformsh/ibexa-commerce/4.6/.platform.app.yaml#L65 I think this is where it can be omitted once projects are created from templates. This seems like potential security flaw where XFF remains untouched. The subscriber in question overwrites XFF (attacker-influenced?) with X-Client-IP (router-controlled) so that the processing reads a clean value.

It seems we need to do the following to summarize:

  • sunset ibexa/fastly-forwarded-host (archive),
  • make sure VCL is properly updated,
  • the combo mentioned below is verified not to fallback to the Symfony defaults.

@konradoboza

Copy link
Copy Markdown
Contributor

@vidarl just making sure we are not stuck: is this topic still in progress concerning this comment or do you wait for our input?

@vidarl

vidarl commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@vidarl just making sure we are not stuck: is this topic still in progress concerning this comment or do you wait for our input?

@konradoboza
Sorry for the lack of feedback, but I am starting to look at the vcl changes you mentioned today (filter out X-Forward headers). However, my plan there is to only do it for 4.6/varnish6 and fastly ATM. Then wait for varnish9 PRs to land in stable branches before finishing it up

@konradoboza

Copy link
Copy Markdown
Contributor

Makes sense, thank you for the heads up!

@vidarl
vidarl force-pushed the IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud branch 2 times, most recently from e026319 to 609d925 Compare October 14, 2026 10:35
@vidarl

vidarl commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

So, varnish9 has now landed upstream, and I have fixed all related PR accordingly and rebased on top of 4.6 tip. ( Most changes where in http-cache)

@vidarl
vidarl force-pushed the IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud branch 2 times, most recently from 24bfa57 to ddc864e Compare October 15, 2026 11:41
vidarl added a commit to ibexa/cloud that referenced this pull request Oct 26, 2026
@vidarl
vidarl force-pushed the IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud branch from c871a50 to 4997bc4 Compare October 28, 2026 15:05
@vidarl
vidarl force-pushed the IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud branch from 4997bc4 to 116cd9d Compare October 29, 2026 08:50
@sonarqubecloud

Copy link
Copy Markdown

@alongosz
alongosz merged commit f132faa into 4.6 Oct 29, 2026
37 checks passed
@alongosz
alongosz deleted the IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud branch October 29, 2026 10:41
vidarl added a commit to ibexa/cloud that referenced this pull request Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Doc needed The changes require some documentation QA approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants