]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netfilter: nf_conntrack_h323: fix OOB read in decode_int() CONS case
authorJenny Guanni Qu <qguanni@gmail.com>
Thu, 12 Mar 2026 02:29:32 +0000 (02:29 +0000)
committerFlorian Westphal <fw@strlen.de>
Fri, 13 Mar 2026 14:31:15 +0000 (15:31 +0100)
In decode_int(), the CONS case calls get_bits(bs, 2) to read a length
value, then calls get_uint(bs, len) without checking that len bytes
remain in the buffer. The existing boundary check only validates the
2 bits for get_bits(), not the subsequent 1-4 bytes that get_uint()
reads. This allows a malformed H.323/RAS packet to cause a 1-4 byte
slab-out-of-bounds read.

Add a boundary check for len bytes after get_bits() and before
get_uint().

Fixes: 5e35941d9901 ("[NETFILTER]: Add H.323 conntrack/NAT helper")
Reported-by: Klaudia Kloc <klaudia@vidocsecurity.com>
Reported-by: Dawid Moczadło <dawid@vidocsecurity.com>
Signed-off-by: Jenny Guanni Qu <qguanni@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nf_conntrack_h323_asn1.c

index 62aa22a07876950fa9c073819e65c7661f24c1c8..c972e9488e16f63c7084b92285f72bbaff124ce9 100644 (file)
@@ -331,6 +331,8 @@ static int decode_int(struct bitstr *bs, const struct field_t *f,
                if (nf_h323_error_boundary(bs, 0, 2))
                        return H323_ERROR_BOUND;
                len = get_bits(bs, 2) + 1;
+               if (nf_h323_error_boundary(bs, len, 0))
+                       return H323_ERROR_BOUND;
                BYTE_ALIGN(bs);
                if (base && (f->attr & DECODE)) {       /* timeToLive */
                        unsigned int v = get_uint(bs, len) + f->lb;