Skip to content

IBX-11181: Filtered client-supplied X-Forwarded-* headers in Varnish VCL - #87

Open
vidarl wants to merge 12 commits into
4.6from
IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud
Open

vidarl wants to merge 12 commits into
4.6from
IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud

Conversation

@vidarl

@vidarl vidarl commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor
🎫 Issue IBX-11181

Caution

DO-NOT-MERGE : PR contains TMP commit with dependencies.json for making CI green

Note

SonarCloud error is false positive. behat tests refers to github actions by ibexa repo/branchname instead of SHA commit hash

Related PRs:

ibexa/docker#65 must be merged before this one ( once it is merged, the [TMP] commit in this PR can be removed )

Description:

Follow-up to ibexa/core#699, which makes Ibexa DXP declare the peer a trusted proxy when a request
arrives via Fastly on Ibexa Cloud. Once trusted proxies are in play, every X-Forwarded-* header a
client sends is believed by Symfony, so Varnish has to stop them from reaching the application.

Until now the VCLs took X-Forwarded-Proto straight from the client and derived X-Forwarded-Port
from it, and never touched Forwarded, X-Forwarded-Host or X-Forwarded-Prefix. A client could
therefore spoof the scheme and host the application sees. Since X-Forwarded-* is not part of the
Varnish cache key, a spoofed value also poisons the cached object for everyone else.

vcl_recv now strips those headers for every client that is not listed in a new trusted_proxies
ACL in parameters.vcl, and overwrites X-Forwarded-For with the real client IP. X-Client-IP and
Client-Cdn are stripped too, so a client cannot fake the Ibexa Cloud detection added in
ibexa/core#699. A proxy that is in the ACL keeps passing everything through, which is what a TLS
terminator, load balancer or CDN in front of Varnish relies on.

Applies to varnish5.vcl, varnish6.vcl and varnish7.vcl. varnish9.vcl is deliberately left
out while its own PRs are open; it gets the same treatment once they land.

SonarCloud complains: Use full commit SHA hash for this dependency.. However, I refer to main branch in a ibexa repository. This is considered safe and that warning can be ignored.

BC breaks:

varnish5/6/7.vcl now reference the trusted_proxies ACL, which lives in parameters.vcl. Varnish
resolves ACLs at VCL load time, so parameters.vcl and the VCL must be updated together - an
existing parameters.vcl without the ACL makes Varnish fail to load with
Symbol not found: 'trusted_proxies'. There is no way to make an ACL reference optional in VCL.

The ACL ships with localhost only. Anyone running a TLS terminator in front of Varnish has to add
its IP, otherwise the X-Forwarded-Proto it sets is discarded and URLs are generated as http://.
Documented in docs/varnish/README.md.

For QA:

Check that https URL generation still works behind a TLS terminator once its IP is added to the
trusted_proxies ACL, and that cache invalidation and the X-Cache debug headers are unaffected.
Easiest done using a custom controller that outputs those headers if they exists, maybe

@vidarl
vidarl force-pushed the IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud branch 2 times, most recently from 434e83e to 15d27f9 Compare August 19, 2026 07:15
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@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.

The VCL and reasoning looks good enough, I like the extended testing setup. Summoning @alongosz for his opinion on the bash/CI changes and @ibexa/quality-assurance in regards to docker/Behat. 😉

Comment thread .github/workflows/backend-ci.yaml Outdated
- name: Run test suite
run: composer run-script --timeout=600 test

varnish-vcl-tests:

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.

@alongosz is this setup aligned with the current, org-wise CI adjustments?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@konradoboza @alongosz If you refere to IBX-11778 / #90, I have aligned that now:

  • the varnish-vcl-tests job runs on ubuntu-26.04 (fixup 7d80b5a, as you suggested)
  • uses actions/checkout@v7 like the rest of the workflow.

AUTOMATION_CLIENT_INSTALLATION: ${{ secrets.AUTOMATION_CLIENT_INSTALLATION }}
AUTOMATION_CLIENT_SECRET: ${{ secrets.AUTOMATION_CLIENT_SECRET }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
varnish7-trusted-proxy:

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.

Same question.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@konradoboza @alongosz : Aligned this based on existings jobs:

  • all three trusted-proxy jobs (Varnish 6, 7 and the new 9) now use secrets: inherit (fixups 074f347 and 87a3f59)
  • using ibexa/gh-workflows/.github/workflows/browser-tests.yml@main like every other job in the file

@konradoboza konradoboza added the Doc needed The changes require some documentation label Sep 11, 2026
@konradoboza
konradoboza requested a review from a team September 11, 2026 07:08
@vidarl
vidarl force-pushed the IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud branch 2 times, most recently from 1cf910d to 131cf41 Compare October 8, 2026 10:24
@micszo
micszo removed their request for review October 8, 2026 12:30
@vidarl
vidarl force-pushed the IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud branch 3 times, most recently from 19690e1 to fc5e116 Compare October 12, 2026 12:16
@vidarl
vidarl force-pushed the IBX-11181-Trusted_Proxies_is_not_set_on_Ibexa_Cloud branch 2 times, most recently from 9d4791b to 03221b4 Compare October 14, 2026 10:35
@sonarqubecloud

Copy link
Copy Markdown

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 Ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants