Repository navigation
Conversation
A string entry such as https://app.example.com was compared with a bare prefix match, so it also accepted proxy callback URLs like https://app.example.com.evil.org/ or https://app.example.com@evil.org/. Require that a string entry without a path ends at a URL boundary.
handleLogoutRequests() compared the PTR name of REMOTE_ADDR with the allowed client list. The PTR record is controlled by the owner of the source address, so fall back to the plain IP unless the name resolves back to it.
|
This pull request is closed, so it cannot be queued. Reopen it to get the box back. |
|
|
Hi,
|
gethostbynamel() only returns IPv4 (A) records, so an IPv6 SingleLogout client would never forward-confirm and would be rejected. Also resolve AAAA records and compare the client address in packed form (inet_pton), so equivalent IPv6 spellings match.
Covers that a plain string entry https://app.example.com does not match https://app.example.com.evil.org/ or https://app.example.com@evil.org/, while still matching the exact host and a path boundary.
|
Thanks, both addressed:
|
|
It seems dns_get_record does not use system resolver. I suggest the following function (which handles both ipv4/ipv6): |
dns_get_record() does not use the system resolver (it ignores /etc/hosts and the configured resolver), so the AAAA lookup added for IPv6 could disagree with how the host actually resolves the client name. Replace the gethostbynamel() + dns_get_record(AAAA) pair with a _gethostbynamel46() helper built on socket_addrinfo_lookup()/getaddrinfo (per maintainer suggestion), which returns both IPv4 and IPv6 via the system resolver, and fall back to gethostbynamel() when the sockets extension is unavailable.
|
Good catch, thanks. You're right that |
A string entry such as https://app.example.com was compared with a bare prefix match, so it also accepted proxy callback URLs like https://app.example.com.evil.org/ or https://app.example.com@evil.org/. Require that a string entry without a path ends at a URL boundary. Fixes part of #455
handleLogoutRequests() compared the PTR name of REMOTE_ADDR with the allowed client list. The PTR record is controlled by the owner of the source address, so fall back to the plain IP unless the name resolves back to it. Fixes part of #455 Co-authored-by: Peter Wilfahrt <pw@pw.is>
|
I committed squashed commits for "Do not let plain proxy chain entries match across the URL authority" I committed a reworked commit for "Forward-confirm reverse DNS before trusting logout request client name". |
Two small, config-dependent defense-in-depth hardenings. Neither is high severity, so a PR felt more appropriate than a private advisory.
1. Plain-string proxy-chain entries match beyond the URL authority (
CAS_ProxyChain::matches)String entries are compared with a bare case-insensitive prefix (
strncasecmp). An entry without a path, e.g.https://proxy.example.com, which the docblock describes as a valid way to allow "a full domain" also acceptshttps://proxy.example.com.evil.net/cbandhttps://proxy.example.com@evil.net/cb(userinfo form; real host isevil.net).Confirmed dynamically against a mock CAS returning
<cas:proxy>: with chain entryhttps://proxy.example.com, a proxy URL of the….evil.net/cband…@evil.net/cbforms both authenticated as the victim before the change and are rejected after it.Preconditions (hence Low–Moderate, config-dependent): the app uses
allowProxyChain()with a string entry that has no path/trailing slash; the attacker runs a proxying service registered at the CAS server whose pgtUrl passes the CAS proxy policy; a victim authenticates to it.Fix: a string entry without a path must end at a URL boundary (
/,?,#, or end of string). Entries that include a path keep prefix-matching as before. (Behaviour change:https://p.example.comno longer matcheshttps://p.example.com:8443/….) 9 regression cases covered.2. Single-logout sender check trusts an unverified PTR record (
Client::handleLogoutRequests)gethostbyaddr($_SERVER['REMOTE_ADDR'])is compared against the allowlist (default: the CAS hostname) without forward confirmation. On many providers the PTR record of a source IP is freely settable, so an attacker can set PTR = CAS hostname and pass the check, allowing forged SLO requests. Impact is limited (ending a specific session also needs the victim's service ticket), so Low / defense-in-depth (CWE-350).Fix: forward-confirm with
gethostbynamel($client)the resolved name must map back toREMOTE_ADDR, otherwise only the IP is compared.The proxy-chain check was confirmed against a mock CAS; it has not been tested against a real Apereo CAS server with a proxy policy.