Commit 6c19897
fix(be): keep loopback http gated by explicit allowlist under sso_allow_any_domain (#4048)
Addresses the review comment on #4045
(#4045 (comment)).
## Problem
Hop-1 of SSO discovery chooses its scheme via
`scheme_for_allowlisted_host`, which keyed **only** on whether the host
was loopback (`localhost` / `127.0.0.1`) — it never consulted the
allowlist. That was safe only under the prior invariant that *every*
domain reaching discovery was already explicitly allowlisted.
`sso_allow_any_domain` breaks that invariant: with the flag on,
`is_allowed_discovery_domain` accepts **any** domain, so a
non-allowlisted `localhost` / `127.0.0.1` now reaches hop-1 and gets a
plain-`http://` outcall. That is an SSRF/footgun for staging deployments
and contradicts the flag's stated "strict-`https` posture untouched"
goal.
## Fix
Gate the loopback `http` downgrade on **explicit** allowlisting (the
same gate hop-2 already uses), so the flag opens the *domain* gate but
never relaxes `https`:
```rust
if matches!(bare.as_str(), "localhost" | "127.0.0.1") && is_explicitly_allowlisted(host) {
"http"
} else {
"https"
}
```
- A loopback host reachable *only* via the flag (not on the explicit
allowlist) now gets `https` — no plain-HTTP outcall to loopback.
- The e2e provider `localhost:11107` stays on the explicit
`sso_discoverable_domains` allowlist, so its `http` path is unaffected
(no e2e regression).
- Adds regression unit test
`allow_any_domain_does_not_relax_https_for_loopback`.
> Note: this is stacked on `feat/sso-allow-any-domain`; it can also just
be cherry-picked as a single commit onto that branch.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01LDnAektYFmpUWDHPLHypkQ
---
_Generated by [Claude
Code](https://claude.ai/code/session_01LDnAektYFmpUWDHPLHypkQ)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 26bdb1d commit 6c19897
1 file changed
Lines changed: 35 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
302 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
303 | 304 | | |
304 | 305 | | |
305 | 306 | | |
| |||
480 | 481 | | |
481 | 482 | | |
482 | 483 | | |
483 | | - | |
484 | | - | |
485 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
486 | 493 | | |
487 | 494 | | |
488 | | - | |
| 495 | + | |
489 | 496 | | |
490 | 497 | | |
491 | 498 | | |
| |||
590 | 597 | | |
591 | 598 | | |
592 | 599 | | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
593 | 622 | | |
594 | 623 | | |
595 | 624 | | |
| |||
0 commit comments