vendor:
iOS
by:
Project Zero
7,8
CVSS
HIGH
Heap Buffer Overflow
119
CWE
Product Name: iOS
Affected Version From: N/A
Affected Version To: N/A
Patch Exists: YES
Related CWE: N/A
CPE: N/A
Metasploit:
N/A
Other Scripts:
N/A
Tags: N/A
CVSS Metrics: N/A
Nuclei References:
N/A
Nuclei Metadata: N/A
Platforms Tested: MacOS 10.12.3 (16D32)
2017
Heap Buffer Overflow in TIKeyboardLayout
Using lldb inside a simple hello_world app for iOS, it was discovered that there are over 600 classes which could be deserialized. The TextInput framework which is loaded has a class TIKeyboardLayout. The initWithCoder: implementation has code which reads binary data from the NSCoder, divides the length by 8 and passes that to ensureFrameCapacity which passes it to calloc with an item size of 8. This has the effect of mallocing the original size rounded down to the nearest multiple of 8. The memcpy then uses the original length (not rounded down) causing a controlled heap buffer overflow.
Mitigation:
Ensure that the length of the data being read is properly validated before being passed to the calloc function.