Bug 1194176 - (CVE-2022-23096) VUL-0: CVE-2022-23096: connman: dnsproxy TCP Receive Path does not Check for Presence of Sufficient Header Data
(CVE-2022-23096)
VUL-0: CVE-2022-23096: connman: dnsproxy TCP Receive Path does not Check for ...
Status: RESOLVED FIXED
Classification: Novell Products
Product: SUSE Security Incidents
Classification: Novell Products
Component: Audits
unspecified
Other Other
: P3 - Medium : Normal
: ---
Assigned To: Security Team bot
Security Team bot
https://smash.suse.de/issue/319293
CVSSv3.1:SUSE:CVE-2022-23096:9.1:(AV:...
:
Depends on:
Blocks: 1193801
  Show dependency treegraph
 
Reported: 2021-12-30 11:45 UTC by Matthias Gerstner
Modified: 2022-03-29 12:20 UTC (History)
3 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Gerstner 2021-12-30 11:45:05 UTC
+++ This bug was initially created as a clone of Bug #1193801

This is to track finding 2) of the parent bug:

2) TCP Receive Path does not Check for Presence of Sufficient Header Data
=========================================================================

In the UDP server reply code path a literal size check is performed to make
sure that at least a complete DNS header has been received
(`dnsproxy.c:2257`). This check is missing in the TCP server reply code path
as can be seen in:

- dnsproxy.c:2417: here a heap buffer of the exact claimed packet size is
  allocated (this can cause up to a 64 KB buffer to be allocated by the way).
- dnsproxy.c:2444: here the now completely received packet is passed on to
  `forward_dns_reply()` without any further minimum package size checks.

This means that a malicious DNS server can send a minimum reply message
consisting of four bytes (claiming a TCP message of two bytes size, and then
supplying the correct request ID in the next two bytes). `forward_dns_reply()`
will then be called with the `reply_len` parameter being set to 4. There are
no further input size checks in `forward_dns_reply`:

```
int dns_id, sk, err, offset = protocol_offset(protocol);

if (offset < 0)
	return offset;

hdr = (void *)(reply + offset);
```

`offset` will be 2 for the TCP case. Thus `hdr` will point to the two valid
DNS ID bytes at the end of the heap allocated buffer. All further protocol
processing code in this function will operate on undefined out of bounds heap
data.

From here on the characteristics of this vulnerability are similar to issue
1). There can be undefined behaviour and a possiblity for a remote DoS, a heap
based information leak maybe.

To fix this the `tcp_server_event()` function should not call
`forward_dns_reply()` if no complete header has been received. Furthermore an
upper TCP packet size limit (`TCP_MAX_BUF_LEN` already exists) should be
enforced also. The suggestions for issue 1) regarding the
`forward_dns_reply()` function apply here as well.

A sample run with `valgrind` acting against a malicious DNS server showed
output like this:

    Invalid read of size 2
       at 0x487311: forward_dns_reply.isra.0 (dnsproxy.c:2153)
       by 0x487EBD: tcp_server_event (dnsproxy.c:2447)
       by 0x48C0D9E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.7000.2)
       by 0x48C1127: ??? (in /usr/lib64/libglib-2.0.so.0.7000.2)
       by 0x48C1412: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.7000.2)
       by 0x41217B: main (main.c:932)
     Address 0x587c88c is 2 bytes after a block of size 10 alloc'd
       at 0x48437B5: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
       by 0x48C719F: g_try_malloc (in /usr/lib64/libglib-2.0.so.0.7000.2)
       by 0x4881A9: tcp_server_event (dnsproxy.c:2420)
       by 0x48C0D9E: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.7000.2)
       by 0x48C1127: ??? (in /usr/lib64/libglib-2.0.so.0.7000.2)
       by 0x48C1412: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.7000.2)
       by 0x41217B: main (main.c:932)
Comment 1 Matthias Gerstner 2022-01-11 09:01:37 UTC
Mitre assigned CVE-2022-23096 for this issue.
Comment 2 Matthias Gerstner 2022-01-25 09:32:55 UTC
The issue is public now via Connman's mailing list and oss-sec. Please also
submit updates for the SUSE packages.
Comment 3 Daniel Wagner 2022-01-25 10:51:29 UTC
https://build.opensuse.org/request/show/948995
Comment 4 OBSbugzilla Bot 2022-02-01 14:20:05 UTC
This is an autogenerated message for OBS integration:
This bug (1194176) was mentioned in
https://build.opensuse.org/request/show/950446 Factory / connman
Comment 5 Gabriele Sonnu 2022-02-11 10:35:26 UTC
Hi Daniel, please also submit for:

- openSUSE:Backports:SLE-15-SP3
- openSUSE:Backports:SLE-15-SP4
Comment 6 OBSbugzilla Bot 2022-02-11 16:30:05 UTC
This is an autogenerated message for OBS integration:
This bug (1194176) was mentioned in
https://build.opensuse.org/request/show/953781 Backports:SLE-15-SP3 / connman
https://build.opensuse.org/request/show/953783 Backports:SLE-15-SP4 / connman
Comment 7 Swamp Workflow Management 2022-03-01 20:32:10 UTC
openSUSE-SU-2022:0056-1: An update that solves 17 vulnerabilities and has 62 fixes is now available.

Category: security (important)
Bug References: 1139944,1151927,1152489,1153275,1154353,1154355,1161907,1164565,1166780,1169514,1176242,1176447,1176536,1176544,1176545,1176546,1176548,1176558,1176559,1176774,1176940,1176956,1177440,1178134,1178270,1179211,1179424,1179426,1179427,1179599,1181148,1181507,1181710,1182404,1183534,1183540,1183897,1184318,1185726,1185902,1186332,1187541,1189126,1189158,1191793,1191876,1192267,1192320,1192507,1192511,1192569,1192606,1192691,1192845,1192847,1192874,1192877,1192946,1192969,1192987,1192990,1192998,1193002,1193042,1193139,1193169,1193306,1193318,1193349,1193440,1193442,1193655,1193993,1194087,1194094,1194175,1194176,1194177,1194266
CVE References: CVE-2020-24504,CVE-2020-27820,CVE-2021-28711,CVE-2021-28712,CVE-2021-28713,CVE-2021-28714,CVE-2021-28715,CVE-2021-33098,CVE-2021-4001,CVE-2021-4002,CVE-2021-43975,CVE-2021-43976,CVE-2021-45485,CVE-2021-45486,CVE-2022-23096,CVE-2022-23097,CVE-2022-23098
JIRA References: 
Sources used:
openSUSE Leap 15.3 (src):    kernel-azure-5.3.18-38.34.1, kernel-source-azure-5.3.18-38.34.1, kernel-syms-azure-5.3.18-38.34.1
openSUSE Backports SLE-15-SP3 (src):    connman-1.41-bp153.2.3.1
Comment 8 Gianluca Gabrielli 2022-03-29 12:20:53 UTC
done