git: 0ab05345fb40 - releng/13.5 - pf: improve SCTP validation
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 29 Apr 2026 14:50:20 UTC
The branch releng/13.5 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=0ab05345fb408b70f37a6b1c522ef3e084fc5f58
commit 0ab05345fb408b70f37a6b1c522ef3e084fc5f58
Author: Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2026-04-26 09:34:55 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-04-28 20:32:11 +0000
pf: improve SCTP validation
As per RFC5061 "4.2. New Parameter Types" the add/delete IP address
parameters (0xc001, 0xc002) may not be present in an INIT or INIT-ACK
chunk. They are only allowed to be present in an ASCONF chunk.
This also prevents unbounded recursion while parsing an SCTP packet.
Approved by: so
Security: FreeBSD-SA-26:14.pf
Security: CVE-2026-7164
PR: 294799
Reported by: Igor Gabriel Sousa e Souza
MFC after: 3 days
Sponsored by: Orange Business Services
---
sys/netpfil/pf/pf.c | 18 +++++++++++++-----
tests/sys/netpfil/pf/sctp.py | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 5 deletions(-)
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index b5f872d40b02..cf077e001ae9 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -5925,7 +5925,7 @@ again:
static int
pf_multihome_scan(struct mbuf *m, int start, int len, struct pf_pdesc *pd,
- struct pfi_kkif *kif, int op)
+ struct pfi_kkif *kif, int op, bool asconf)
{
int off = 0;
struct pf_sctp_multihome_job *job;
@@ -6019,13 +6019,16 @@ pf_multihome_scan(struct mbuf *m, int start, int len, struct pf_pdesc *pd,
int ret;
struct sctp_asconf_paramhdr ah;
+ if (asconf)
+ return (PF_DROP);
+
if (!pf_pull_hdr(m, start + off, &ah, sizeof(ah),
NULL, NULL, pd->af))
return (PF_DROP);
ret = pf_multihome_scan(m, start + off + sizeof(ah),
ntohs(ah.ph.param_length) - sizeof(ah), pd, kif,
- SCTP_ADD_IP_ADDRESS);
+ SCTP_ADD_IP_ADDRESS, true);
if (ret != PF_PASS)
return (ret);
break;
@@ -6034,12 +6037,15 @@ pf_multihome_scan(struct mbuf *m, int start, int len, struct pf_pdesc *pd,
int ret;
struct sctp_asconf_paramhdr ah;
+ if (asconf)
+ return (PF_DROP);
+
if (!pf_pull_hdr(m, start + off, &ah, sizeof(ah),
NULL, NULL, pd->af))
return (PF_DROP);
ret = pf_multihome_scan(m, start + off + sizeof(ah),
ntohs(ah.ph.param_length) - sizeof(ah), pd, kif,
- SCTP_DEL_IP_ADDRESS);
+ SCTP_DEL_IP_ADDRESS, true);
if (ret != PF_PASS)
return (ret);
break;
@@ -6061,7 +6067,8 @@ pf_multihome_scan_init(struct mbuf *m, int start, int len, struct pf_pdesc *pd,
start += sizeof(struct sctp_init_chunk);
len -= sizeof(struct sctp_init_chunk);
- return (pf_multihome_scan(m, start, len, pd, kif, SCTP_ADD_IP_ADDRESS));
+ return (pf_multihome_scan(m, start, len, pd, kif, SCTP_ADD_IP_ADDRESS,
+ false));
}
int
@@ -6071,7 +6078,8 @@ pf_multihome_scan_asconf(struct mbuf *m, int start, int len,
start += sizeof(struct sctp_asconf_chunk);
len -= sizeof(struct sctp_asconf_chunk);
- return (pf_multihome_scan(m, start, len, pd, kif, SCTP_ADD_IP_ADDRESS));
+ return (pf_multihome_scan(m, start, len, pd, kif, SCTP_ADD_IP_ADDRESS,
+ false));
}
int
diff --git a/tests/sys/netpfil/pf/sctp.py b/tests/sys/netpfil/pf/sctp.py
index 38bb9f2dff74..7cf88c969d48 100644
--- a/tests/sys/netpfil/pf/sctp.py
+++ b/tests/sys/netpfil/pf/sctp.py
@@ -426,6 +426,49 @@ class TestSCTP(VnetTestTemplate):
assert re.search(r"all sctp 192.0.2.4:.*192.0.2.3:1234", states)
assert re.search(r"all sctp 192.0.2.4:.*192.0.2.2:1234", states)
+class TestSCTP_SRV(VnetTestTemplate):
+ REQUIRED_MODULES = ["sctp", "pf"]
+ TOPOLOGY = {
+ "vnet1": {"ifaces": ["if1"]},
+ "vnet2": {"ifaces": ["if1"]},
+ "if1": {"prefixes4": [("192.0.2.1/24", "192.0.2.2/24")]},
+ }
+
+ def vnet2_handler(self, vnet):
+ ToolsHelper.print_output("/sbin/pfctl -e")
+ ToolsHelper.pf_rules([
+ "set state-policy if-bound",
+ "pass inet proto sctp",
+ "pass on lo"])
+
+ # Start an SCTP server process, pipe the ppid + data back to the other vnet?
+ srv = SCTPServer(socket.AF_INET, port=1234)
+ while True:
+ srv.accept(vnet)
+
+ @pytest.mark.require_user("root")
+ @pytest.mark.require_progs(["scapy"])
+ def test_too_many_add_ip(self):
+ import scapy.all as sp
+ DEPTH=90
+ params=[]
+ for i in range(0, DEPTH):
+ ch = sp.SCTPChunkParamAddIPAddr(len=(DEPTH - i) * 8)
+ params.append(ch)
+ packet = sp.IP(src="192.0.2.1", dst="192.0.2.2") \
+ / sp.SCTP(sport=4321, dport=1234) \
+ / sp.SCTPChunkInit(init_tag=1, n_in_streams=1, n_out_streams=1, a_rwnd=1500,
+ params=params)
+ packet.show()
+ sp.hexdump(packet)
+ print("len %d" % len(packet))
+
+ r = sp.sr1(packet, timeout=3)
+ # We should not get a reply to this
+ if r:
+ r.show()
+ assert not r
+
class TestSCTPv6(VnetTestTemplate):
REQUIRED_MODULES = ["sctp", "pf"]
TOPOLOGY = {