Commit 3b09de0
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
File tree
- sites/admin-cabinet/assets/js
- pbx/Providers
- src/Providers
- src
- Common/Messages
- az
- cs
- da
- de
- el
- en
- es
- fi
- fr
- hr
- hu
- it
- ja
- ka
- nl
- pl
- pt_BR
- pt
- ro
- ru
- sv
- th
- tr
- uk
- vi
- zh_Hans
- Core
- Asterisk/Configs
- System/Configs
- Utilities
- Workers
- PBXCoreREST/Lib/Providers
- tests/Core
- Asterisk/Configs
- Utilities
Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
389 | 392 | | |
390 | 393 | | |
391 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
0 commit comments