Skip to content

Commit 3b09de0

Browse files
committed
fix(sip): extend identify hostname resolver to additionalHosts, harden trust gate
- m_SipHosts.address now accepts hostnames in addition to IP/CIDR literals; resolution flows through the same WorkerSipDnsResolver + Redis cache as provider.host. IptablesConf::addAdditionalFirewallRules reads the same cache so identify trust and firewall trust stay consistent for hostname rows. getSipHostsBuckets returns {ips,hostnames} split; legacy getSipHosts() kept as flat shape for 3rd-party module compat. - Reject /0 wildcard CIDR (0.0.0.0/0, ::/0) at all ingress points — the previous string-equality guard was bypassable via /00, /+0, /-0, /0x0 (filter_var did NOT validate the prefix, only the IP half). Switched to IpAddressHelper::normalizeCidr which parses prefix as a strict decimal int and enforces the per-version range. - IpAddressHelper::isPublicIp now explicitly rejects CGNAT (100.64/10, RFC 6598), multicast (224.0.0.0/4), TEST-NET-{1,2,3} for IPv4; and Benchmarking (2001:2::/48), ORCHIDv1 (2001:10::/28) and ORCHIDv2 (2001:20::/28) for IPv6. PHP filter flags FILTER_FLAG_NO_PRIV_RANGE | NO_RES_RANGE do not cover these. - Symmetric structural gate (isAcceptableAdditionalHost) applied to provider.host, outbound_proxy and additionalHosts: single-label hostnames, host:port shapes, SRV-prefixed labels, bracketed-IPv6 with garbage all fail at schema validation as HTTP 422 instead of dropping silently in updateAdditionalHosts or throwing HTTP 500 deep inside executeInTransaction. - maxLength=253 on host and additionalHosts.address (RFC 1035 limit; symmetric with isValidHostname strlen gate). - OpenAPI pattern for host requires at least one '.' or ':' so single- label hosts surface as schema 422. - stripIpv6Brackets shared helper normalises copy-paste-from-SIP-URI input ([2001:db8::1] -> 2001:db8::1) consistently across all ingress paths. - Resolved-IP cache invalidated post-save when a hostname is dropped from provider.host or outbound_proxy (orphan cache prevention) — runs AFTER \$sip->save() so the orphan-check reads committed DB state. - DNS warmup runs once per save batch with a 3-second wall-clock budget shared across all hostnames (provider.host, outbound_proxy, m_SipHosts). Gated by \$touchedHostFields so PATCHes of unrelated columns skip the cost. warmupShutdownRegistered de-dupes register_shutdown_function so long-running WorkerApiCommands does not accumulate closures linearly with save count. - DnsResolver::resolveBatch short-circuits when caller passes timeoutSec=0 (shared budget already exhausted) — no proc_open/fork/exec churn. - m_SipHosts rows that fail validation (stale data from pre-validation DB writes) are logged once-per-process with SIP-IDENT-DROP prefix to surface in syslog without flooding on every regen. UI tooltip on the Additional Hosts table surfaces the DNS-trust caveat: hostnames are resolved through the configured DNS, so a compromised resolver can inject IPs into the identify whitelist — admin should pin critical providers to IP/CIDR directly. Translation key pr_AdditionalHostsTooltip_trust added in Russian and propagated to all 28 locale files. Tests: SIPConfTest gains 321 lines covering getSipHostsBuckets, flattenBucketsToLegacyShape, isValidHostname, isAcceptableAdditionalHost (including the /0 wildcard rejection), stripIpv6Brackets, and the hostname-warmup cold-cache degradation path. DnsResolverTest covers the timeoutSec=0 short-circuit.
1 parent 8dee0ab commit 3b09de0

37 files changed

Lines changed: 1526 additions & 209 deletions

sites/admin-cabinet/assets/js/pbx/Providers/provider-sip-tooltip-manager.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sites/admin-cabinet/assets/js/src/Providers/provider-sip-tooltip-manager.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,10 @@ class ProviderSipTooltipManager extends ProviderTooltipManager {
385385
globalTranslate.pr_AdditionalHostsTooltip_format_subnet,
386386
globalTranslate.pr_AdditionalHostsTooltip_format_domain
387387
],
388-
note: globalTranslate.pr_AdditionalHostsTooltip_important
388+
note: globalTranslate.pr_AdditionalHostsTooltip_important,
389+
warning: {
390+
text: globalTranslate.pr_AdditionalHostsTooltip_trust
391+
}
389392
};
390393
}
391394

src/Common/Messages/az/Providers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
'pr_AdditionalHostsTooltip_formats' => 'Formatlar',
6060
'pr_AdditionalHostsTooltip_header' => 'Provayderin əlavə ünvanları',
6161
'pr_AdditionalHostsTooltip_important' => 'Vacib: yalnız gələn zənglərin identifikasiyası üçün istifadə olunur, gedən balanslaşdırma üçün DEYİL',
62+
'pr_AdditionalHostsTooltip_trust' => 'Domen adları sizin DNS serveriniz vasitəsilə həll edilir; əgər bu DNS təcavüzkarın nəzarəti altındadırsa, onun IP-ləri whitelist-ə düşə bilər. Kritik provayderlər üçün birbaşa IP/şəbəkə göstərin.',
6263
'pr_AdditionalHostsTooltip_purpose_id' => 'Provayderdən gələn zənglərin identifikasiyası',
6364
'pr_AdditionalHostsTooltip_purpose_multi' => 'Çoxlu serveri olan provayderlərin dəstəyi',
6465
'pr_AdditionalHostsTooltip_purpose_security' => 'IP whitelist vasitəsilə təhlükəsizlik',

src/Common/Messages/cs/Providers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
'pr_AdditionalHostsTooltip_formats' => 'Formáty',
6060
'pr_AdditionalHostsTooltip_header' => 'Další adresy poskytovatele',
6161
'pr_AdditionalHostsTooltip_important' => 'Důležité: používají se pouze pro identifikaci příchozích hovorů, NE pro vyvažování odchozích',
62+
'pr_AdditionalHostsTooltip_trust' => 'Doménová jména jsou překládána přes váš DNS server; pokud je tento DNS pod kontrolou útočníka, jeho IP adresy se mohou dostat do whitelistu. U kritických poskytovatelů uvádějte IP/podsíť přímo.',
6263
'pr_AdditionalHostsTooltip_purpose_id' => 'Identifikace příchozích hovorů od poskytovatele',
6364
'pr_AdditionalHostsTooltip_purpose_multi' => 'Podpora poskytovatelů s více servery',
6465
'pr_AdditionalHostsTooltip_purpose_security' => 'Bezpečnost prostřednictvím IP whitelist',

src/Common/Messages/da/Providers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
'pr_AdditionalHostsTooltip_formats' => 'Formater',
6060
'pr_AdditionalHostsTooltip_header' => 'Yderligere udbyderadresser',
6161
'pr_AdditionalHostsTooltip_important' => 'Vigtigt: bruges kun til identifikation af indgående opkald, IKKE til lastbalancering af udgående',
62+
'pr_AdditionalHostsTooltip_trust' => 'Domænenavne opløses via din DNS-server; hvis denne DNS er under en angribers kontrol, kan deres IP\'er ende på whitelisten. For kritiske udbydere skal du angive IP/undernet direkte.',
6263
'pr_AdditionalHostsTooltip_purpose_id' => 'Identifikation af indgående opkald fra udbyder',
6364
'pr_AdditionalHostsTooltip_purpose_multi' => 'Understøttelse af udbydere med flere servere',
6465
'pr_AdditionalHostsTooltip_purpose_security' => 'Sikkerhed gennem IP whitelist',

src/Common/Messages/de/Providers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
'pr_AdditionalHostsTooltip_formats' => 'Formate',
6060
'pr_AdditionalHostsTooltip_header' => 'Zusätzliche Provider-Adressen',
6161
'pr_AdditionalHostsTooltip_important' => 'Wichtig: nur zur Identifizierung eingehender Anrufe verwendet, NICHT für Lastverteilung ausgehender',
62+
'pr_AdditionalHostsTooltip_trust' => 'Domainnamen werden über Ihren DNS-Server aufgelöst; befindet sich dieser DNS unter Kontrolle eines Angreifers, können dessen IPs in die Whitelist gelangen. Geben Sie für kritische Anbieter IP/Subnetz direkt an.',
6263
'pr_AdditionalHostsTooltip_purpose_id' => 'Identifizierung eingehender Anrufe vom Provider',
6364
'pr_AdditionalHostsTooltip_purpose_multi' => 'Unterstützung von Providern mit mehreren Servern',
6465
'pr_AdditionalHostsTooltip_purpose_security' => 'Sicherheit durch IP-Whitelist',

src/Common/Messages/el/Providers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
'pr_AdditionalHostsTooltip_formats' => 'Μορφές',
6060
'pr_AdditionalHostsTooltip_header' => 'Πρόσθετες διευθύνσεις παρόχου',
6161
'pr_AdditionalHostsTooltip_important' => 'Σημαντικό: χρησιμοποιούνται μόνο για αναγνώριση εισερχόμενων κλήσεων, ΟΧΙ για εξισορρόπηση εξερχόμενων',
62+
'pr_AdditionalHostsTooltip_trust' => 'Τα ονόματα τομέα επιλύονται μέσω του DNS διακομιστή σας· αν αυτός ο DNS είναι υπό έλεγχο επιτιθέμενου, οι IP του μπορεί να καταλήξουν στη whitelist. Για κρίσιμους παρόχους ορίστε απευθείας IP/υποδίκτυο.',
6263
'pr_AdditionalHostsTooltip_purpose_id' => 'Αναγνώριση εισερχόμενων κλήσεων από πάροχο',
6364
'pr_AdditionalHostsTooltip_purpose_multi' => 'Υποστήριξη παρόχων με πολλαπλούς διακομιστές',
6465
'pr_AdditionalHostsTooltip_purpose_security' => 'Ασφάλεια μέσω IP whitelist',

src/Common/Messages/en/Providers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
'pr_AdditionalHostsTooltip_formats' => 'Formats',
7777
'pr_AdditionalHostsTooltip_header' => 'Additional provider addresses',
7878
'pr_AdditionalHostsTooltip_important' => 'Important: used only for identifying incoming calls, NOT for outbound load balancing',
79+
'pr_AdditionalHostsTooltip_trust' => 'Domain names are resolved via your DNS server; if this DNS is under attacker control, their IPs may end up in the whitelist. For critical providers specify IP/subnet directly.',
7980
'pr_AdditionalHostsTooltip_purpose_id' => 'Identification of incoming calls from provider',
8081
'pr_AdditionalHostsTooltip_purpose_multi' => 'Support for providers with multiple servers',
8182
'pr_AdditionalHostsTooltip_purpose_security' => 'Security through IP whitelist',

src/Common/Messages/es/Providers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
'pr_AdditionalHostsTooltip_formats' => 'Formatos',
6060
'pr_AdditionalHostsTooltip_header' => 'Direcciones adicionales del proveedor',
6161
'pr_AdditionalHostsTooltip_important' => 'Importante: se usan solo para identificación de llamadas entrantes, NO para balanceo de llamadas salientes',
62+
'pr_AdditionalHostsTooltip_trust' => 'Los nombres de dominio se resuelven mediante su servidor DNS; si dicho DNS está bajo el control de un atacante, sus IPs pueden acabar en la whitelist. Para proveedores críticos indique IP/subred directamente.',
6263
'pr_AdditionalHostsTooltip_purpose_id' => 'Identificación de llamadas entrantes del proveedor',
6364
'pr_AdditionalHostsTooltip_purpose_multi' => 'Soporte de proveedores con múltiples servidores',
6465
'pr_AdditionalHostsTooltip_purpose_security' => 'Seguridad a través de lista blanca de IP',

src/Common/Messages/fi/Providers.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
'pr_AdditionalHostsTooltip_formats' => 'Muodot',
6060
'pr_AdditionalHostsTooltip_header' => 'Palveluntarjoajan lisäosoitteet',
6161
'pr_AdditionalHostsTooltip_important' => 'Tärkeää: käytetään vain saapuvien puhelujen tunnistamiseen, EI lähtevien kuormantasaukseen',
62+
'pr_AdditionalHostsTooltip_trust' => 'Verkkotunnukset resolvoidaan DNS-palvelimesi kautta; jos kyseinen DNS on hyökkääjän hallinnassa, hänen IP-osoitteensa voivat päätyä sallittujen luetteloon. Kriittisille palveluntarjoajille määritä IP/aliverkko suoraan.',
6263
'pr_AdditionalHostsTooltip_purpose_id' => 'Saapuvien puhelujen tunnistus palveluntarjoajalta',
6364
'pr_AdditionalHostsTooltip_purpose_multi' => 'Useita palvelimia omaavien palveluntarjoajien tuki',
6465
'pr_AdditionalHostsTooltip_purpose_security' => 'Turvallisuus IP-valkolistan kautta',

0 commit comments

Comments
 (0)