Skip to content

fix: keep Octane TrustHosts from narrowing to the last tenant - #9178

Merged
nolanpro merged 3 commits into
developfrom
fix/octane-mt-trust-hosts
Nov 19, 2026
Merged

nolanpro merged 3 commits into
developfrom
fix/octane-mt-trust-hosts

Conversation

@nolanpro

Copy link
Copy Markdown
Contributor

ci:deploy
ci:run-testbench

Issue & Reproduction Steps

On Octane + multitenancy, parallel requests across tenant hosts (for example nightly octane-mt testbench) intermittently return Internal server error. Login/get-token then times out.

Root cause: SwitchTenant rewrites app.url to the current tenant. TrustHosts derived trusted hosts from that value and called Request::setTrustedHosts(), which persists on FrankenPHP workers. The next request for a different tenant host then fails in Spatie tenant finding with:

SuspiciousOperationException: Untrusted Host "tenant-N....".

Reproduced on ci-nt-octane-mt: sequential logins succeed; parallel cross-tenant logins mostly 500.

Solution

  • Prefer landlord APP_URL when building TrustHosts patterns under multitenancy.
  • Also trust cached tenant domains (TenantDomainCache) so non-subdomain tenant hosts stay valid after an app.url switch.
  • Add a landlord cache store with a fixed prefix so tenant cache prefixes cannot hide the domain list.
  • Invalidate the domain cache when tenants are saved/deleted.
  • Cover with TrustHosts and TenantDomainCache tests.

How to Test

  • Deploy Octane + multitenancy (default CI arch with the tags above).
  • Hit /login in parallel across tenant-1, tenant-2, tenant-3 and confirm stable 200s (no intermittent Untrusted Host 500s).
  • Confirm single-tenant / non-Octane behavior is unchanged.
  • Unit/feature: TrustHosts + TenantDomainCache tests.

Related Tickets & Packages

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

Made with Cursor

Under multitenancy, SwitchTenant rewrites app.url per request. TrustHosts
was deriving trusted hosts from that value, so FrankenPHP workers rejected
later tenant Host headers with SuspiciousOperationException.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cursor

cursor Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes request host validation on every request under multitenancy and introduce landlord-scoped caching; incorrect domain lists could reject or overly broaden trusted hosts.

Reviewed by Cursor Bugbot for commit 76fe361. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f9799ab. Configure here.

@cursor
cursor Bot requested review from agustinbusso and rodriquelca November 18, 2026 17:55
@nolanpro

Copy link
Copy Markdown
Contributor Author

QA server K8S was successfully deployed https://tenant-1.ci-c80718d30c.engk8s.processmaker.net

@nolanpro

Copy link
Copy Markdown
Contributor Author

QA server K8S was successfully deployed https://tenant-1.ci-c80718d30c.engk8s.processmaker.net

Co-authored-by: Cursor <cursoragent@cursor.com>
@nolanpro

Copy link
Copy Markdown
Contributor Author

QA server K8S was successfully deployed https://tenant-1.ci-c80718d30c.engk8s.processmaker.net

@decisions-sonarqube

Copy link
Copy Markdown

@nolanpro
nolanpro merged commit 03fb94c into develop Nov 19, 2026
11 checks passed
@nolanpro
nolanpro deleted the fix/octane-mt-trust-hosts branch November 19, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant