<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mohamed fahmy on Medium]]></title>
        <description><![CDATA[Stories by Mohamed fahmy on Medium]]></description>
        <link>https://medium.com/@moofaa69?source=rss-d788461ee39a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*KfzmVOI2qD9vHHhB</url>
            <title>Stories by Mohamed fahmy on Medium</title>
            <link>https://medium.com/@moofaa69?source=rss-d788461ee39a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 00:44:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@moofaa69/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Three bugs, one lesson: writing my first Windows x64 file I/O in assembly]]></title>
            <link>https://medium.com/@moofaa69/three-bugs-one-lesson-writing-my-first-windows-x64-file-i-o-in-assembly-5ad047542f9b?source=rss-d788461ee39a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ad047542f9b</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[assembly-language]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <dc:creator><![CDATA[Mohamed fahmy]]></dc:creator>
            <pubDate>Thu, 26 Nov 2026 20:06:27 GMT</pubDate>
            <atom:updated>2026-11-26T20:06:27.713Z</atom:updated>
            <content:encoded><![CDATA[<p>Three bugs, one lesson: writing my first Windows x64 file I/O in assembly</p><p>I wrote 40 lines of assembly to create a file on Windows. It compiled, it linked, it ran — and the file was never created. Here’s what went wrong.</p><p>I’ve been writing Linux x64 assembly for months. Syscalls, stack frames, calling conventions — all muscle memory. So when I moved to Windows x64 assembly, I assumed the transition would be about learning new APIs.</p><p>It was not. It was about learning a different ABI, and the way that ABI punishes you silently.</p><p>The project was simple: write a file to disk using the Win32 API. CreateFileA WriteFile CloseHandle. The Windows equivalent of my Linux cat clone. Three function calls, about 40 lines of assembly.</p><p>The code compiled clean. nasm -f win64 produced a valid object file. GoLink linked it against kernel32.dll without a warning. The .exe ran.</p><p>And then:</p><p>C:\asm&gt; file_write.exe<br>C:\asm&gt; type C:\asm\output.txt<br>The system cannot find the file specified.<br>C:\asm&gt; echo %errorlevel%<br>1</p><p>Exit code 1. My error path. The file was never created.</p><p>Here’s what I learned debugging it — and why the third bug, the one that took longest to find, is a lesson every Linux-trained assembly developer should internalize before writing a single line of Windows code.</p><h3>Bug 1: The missing colon</h3><p>My original filename string:</p><p>filename: db “C\asm\output.txt”, 0</p><p>Looks fine, right? C:\asm\output.txt — a valid absolute path.</p><p>But look carefully. There’s no colon after C.</p><p>&quot;C\asm\output.txt&quot; is not an absolute path. It&#39;s a relative path — a subdirectory named C, containing asm, containing output.txt. Since the program runs from C:\asm, the path resolves to C:\asm\C\asm\output.txt, which doesn&#39;t exist.</p><p>CreateFileA returns INVALID_HANDLE_VALUE (-1). My cmp rbx, -1 / je .fail check fires. ExitProcess(1) runs.</p><p>Fix: one character.</p><p>filename: db “C:\asm\output.txt”, 0</p><p>Diagnostic method: In x64dbg, set a breakpoint before call CreateFileA. Look at RCX — the first argument. Follow the pointer into the dump panel. Read the string byte-by-byte. If the path is wrong, the function will fail every time, no matter what else is correct.</p><p>I found this in about 5 minutes because I knew to check the string argument. That’s the “easy” bug.</p><h3>Bug 2: Misaligned stack (the one that took an hour)</h3><p>My first stack allocation for CreateFileA:</p><p>sub rsp, 64 ; 32 shadow space + 24 stack args + 8 alignment</p><p>The comment even says “8 alignment.” But 32 + 24 + 8 = 64, and 64 is a multiple of 16. That means it doesn’t change RSP’s alignment at all.</p><p>Here’s why that matters, and why I got it wrong.</p><p>When Windows invokes your entry point, it uses call _start. The call instruction pushes 8 bytes (the return address) onto a stack that was aligned to 16 bytes by the kernel. So at your first instruction:</p><p>RSP % 16 == 8</p><p>Every Windows API requires RSP % 16 == 0 at the moment of the call. That&#39;s the ABI. It&#39;s not negotiable misalignment causes silent failures or crashes deep inside kernel32/ntdll where you&#39;ll never find them.</p><p>So sub rsp, N must have N % 16 == 8 to change 8 to 0. Valid values:</p><p>32 % 16 == 0 , 40 % 16 == 8 , 56 % 16 == 8, 64 % 16 == 0 my bug, 72 % 16 ==8</p><p>I used 64. Subtracting a multiple of 16 leaves the alignment unchanged. RSP still ends in 8 at the call. CreateFileA internally calls RtlDosPathNameToNtPathName, which uses SSE movaps requires 16-byte alignment, fails, returns error, CreateFileA returns -1.</p><p>Fix:</p><p>sub rsp, 72 ; 32 shadow + 24 stack args + 8 alignment (72 % 16 == 8)</p><p>The comment was the trap. I wrote “8 alignment” but did the arithmetic as if subtracting a multiple of 16 would help. It doesn’t the point of the “8” is that N itself must end in 8 mod 16.</p><p>Diagnostic method: In x64dbg, look at the last hex digit of RSP. If it ends in 8, you&#39;re misaligned. 0 means aligned. This is the fastest way to check one glance, one digit.</p><p>I hit this same bug earlier on MessageBoxA (sub rsp, 32 — worked, but only after changing to 40). I thought I&#39;d learned the lesson. I hadn&#39;t. The lesson isn&#39;t &quot;use 40&quot; — it&#39;s &quot;N % 16 == 8, always.&quot;</p><h3>Bug 3: The argument placed after the call</h3><p>This one I didn’t notice at all until I traced the calls in x64dbg.</p><p>My original WriteFile sequence:</p><p>lea r9, [written]<br>sub rsp, 40<br>call WriteFile<br>mov qword [rsp + 32], 0 ; 5th arg: lpOverlapped = NULL<br>add rsp, 40</p><p>Look at the order. The 5th argument — lpOverlapped, which must be NULL for synchronous I/O — is being written to [rsp+32] after call WriteFile returns.</p><p>WriteFile executed with whatever garbage happened to be on the stack at [rsp+32]. On this particular run, that garbage happened to be non-NULL, which tells WriteFile &quot;use asynchronous I/O&quot; — but with an invalid OVERLAPPED structure. WriteFile returns 0 (failure), my code ignores the return and continues to CloseHandle.</p><p>Fix: move the 5th-argument setup before the call:</p><p>lea r9, [written]<br>sub rsp, 40<br>mov qword [rsp + 32], 0 ; 5th arg BEFORE call<br>call WriteFile<br>add rsp, 40</p><p>This is a subtle bug because the code looks correct — the sub rsp, 40 and add rsp, 40 are balanced, the register args are set, everything appears symmetric. But the argument-on-stack pattern requires the write before the call because the callee reads [rsp+32] at the moment of the call, not after.</p><p>Diagnostic method: At the call WriteFile breakpoint, check [rsp+32] in the memory dump panel. If it&#39;s not what you intended, the setup ran in the wrong order.</p><p>default rel</p><p>extern CreateFileA<br>extern ExitProcess<br>extern WriteFile<br>extern CloseHandle</p><p>section .data<br> filename: db “C:\asm\output.txt”, 0<br> filevalue: db “Written by moo-fahmii with x64 asm”, 13, 10<br> f_len equ $ — filevalue</p><p>section .bss<br> written: resq 1</p><p>section .text<br> global _start</p><p>_start:<br> ; CreateFileA(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)<br> lea rcx, [filename]<br> mov rdx, 0x40000000 ; GENERIC_WRITE<br> xor r8, r8 ; no sharing<br> xor r9, r9 ; default security<br> sub rsp, 72 ; 32 shadow + 24 stack args + 8 align<br> mov qword [rsp + 32], 2 ; 5th: CREATE_ALWAYS<br> mov qword [rsp + 40], 0x80 ; 6th: FILE_ATTRIBUTE_NORMAL<br> mov qword [rsp + 48], 0 ; 7th: hTemplateFile = NULL<br> call CreateFileA<br> add rsp, 72</p><p>mov rbx, rax ; save handle<br> cmp rbx, -1 ; INVALID_HANDLE_VALUE check<br> je .fail</p><p>; WriteFile(hFile, buf, len, &amp;written, NULL)<br> mov rcx, rbx<br> lea rdx, [filevalue]<br> mov r8, f_len<br> lea r9, [written]<br> sub rsp, 40<br> mov qword [rsp + 32], 0 ; 5th arg BEFORE call<br> call WriteFile<br> add rsp, 40</p><p>; CloseHandle<br> mov rcx, rbx<br> sub rsp, 40<br> call CloseHandle<br> add rsp, 40</p><p>; ExitProcess(0) — success<br> xor rcx, rcx<br> sub rsp, 40<br> call ExitProcess<br> add rsp, 40</p><p>.fail:<br> mov rcx, 1<br> sub rsp, 40<br> call ExitProcess<br> add rsp, 40</p><p>The moment it worked:</p><p>C:\asm&gt; file_write.exe<br>C:\asm&gt; type C:\asm\output.txt<br>Written by moo-fahmii with x64 asm<br>C:\asm&gt; echo %errorlevel%<br>0</p><p>Exit code 0. The file contains the string. A 40-line program had 3 bugs and one of them was hiding in the arithmetic</p><h3>Why this matters for malware analysis</h3><p>CreateFileA WriteFile CloseHandle is one of the most common patterns in Windows malware. It&#39;s how droppers write their payloads, how ransomware encrypts files, how stealers dump stolen data. If you analyze Windows samples, you&#39;ll see this sequence hundreds of times.</p><p>When I analyze a sample now and I see call CreateFileA in the disassembly, I don&#39;t just note &quot;writes a file.&quot; I look at:</p><ul><li>RCX — follow the pointer into .data. What path? %TEMP%? %APPDATA%? C:\Windows\System32\?</li><li>RDX — what access? GENERIC_WRITE means writing; GENERIC_READ means reading; GENERIC_READ|GENERIC_WRITE means both</li><li>[rsp+32] — creation disposition. 2 (CREATE_ALWAYS) = dropper. 3 (OPEN_EXISTING) = config reader. 4 (OPEN_ALWAYS) = logger</li></ul><p>Every one of these reveals a piece of the malware’s intent — without needing to understand the payload it writes.</p><p>The debugging skills I picked up writing this project — reading argument values in x64dbg, following pointers to strings, checking alignment by looking at the last hex digit of RSP — those are the exact skills I use when analyzing real samples. The tools and the thinking are identical. Only the destination changes: I debug my own code now</p><h3>What I’d tell another Linux-assembly learner</h3><ol><li>RSP % 16 == 8 at every function entry. Before every call, RSP % 16 == 0. So sub rsp, N must have N % 16 == 8. Write down 40, 56, 72, 88 on a sticky note.</li><li>Look at the last hex digit of RSP in the debugger. 0 = aligned, 8 = misaligned. One digit tells you everything.</li><li>The first Win32 API argument error is usually a string. Follow the pointer, read the bytes. Don’t trust your eyes when reading your own code — let the debugger show you what’s actually being passed.</li><li>Setup stack arguments before the call, not after.</li><li>“It compiled, it linked, and it ran without crashing” is not the same as “it works.” Every Windows API has silent failure modes. Check the return value, check the exit code, check the side effect (did the file actually appear?).</li></ol><p>The jump from Linux to Windows assembly isn’t about learning a new language. It’s the same assembly. It’s about learning a new ABI and the ABI has traps that don’t announce themselves. The only way to find them is to run the code, watch the debugger, and trust the failure more than your assumptions.</p><p>If you’re making the same transition and your CreateFileA returns -1 for no obvious reason, check three things in this order:</p><ol><li>Is the filename a valid absolute path? (RCX in x64dbg)</li><li>Is RSP aligned? (last hex digit = 0 before the call)</li><li>Are the stack args set up before the call, not after?</li></ol><p><em>This was project 03 of my Windows x64 assembly learning series. The full code and other projects are in my </em><a href="https://github.com/moo-fahmii"><em>github.com/moo-fahmii</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ad047542f9b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an Isolated Malware Analysis Lab with Windows 11, Windows 10, and REMnux]]></title>
            <link>https://medium.com/@moofaa69/building-an-isolated-malware-analysis-lab-with-windows-11-windows-10-and-remnux-0592e0b4d7ec?source=rss-d788461ee39a------2</link>
            <guid isPermaLink="false">https://medium.com/p/0592e0b4d7ec</guid>
            <category><![CDATA[proxmox]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[remnux]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[malware-analysis]]></category>
            <dc:creator><![CDATA[Mohamed fahmy]]></dc:creator>
            <pubDate>Thu, 26 Nov 2026 10:23:21 GMT</pubDate>
            <atom:updated>2026-11-26T10:23:21.722Z</atom:updated>
            <content:encoded><![CDATA[<p>A practical walkthrough of my Proxmox-based reverse engineering lab, including VM specifications, isolated networking, FlareVM setup, and snapshot strategy.</p><h3>Why I Built This Lab</h3><p>I wanted a safe, reproducible environment for malware analysis and reverse engineering practice. The lab needed to provide:</p><ul><li>Windows 11 with FlareVM for analysis tooling</li><li>Windows 10 as a secondary target VM</li><li>REMnux for Linux-based malware analysis</li><li>A fully isolated network with no internet access</li><li>Snapshots for quick rollback after analysis</li><li>A simple way to rebuild or reset the environment</li></ul><p>I used <strong>Proxmox VE</strong> as the hypervisor. The same design works with VirtualBox or VMware, but the bridge and snapshot configuration will differ.</p><p><strong>Safety note:</strong> This lab is intentionally isolated. Never detonate malware on a bridged or NAT network connected to your real LAN. Keep snapshots, avoid shared folders and clipboard sharing where possible, and never use real credentials inside the lab.</p><h3>Lab Topology</h3><p>I created a dedicated isolated bridge in Proxmox called vmbr1. It has no physical uplink and no gateway. All lab VMs connect to vmbr1.</p><p>REMnux<br>Role: Analysis and services<br>OS: REMnux<br>vCPU: 2 | RAM: 4 GB | Disk: 60 GB<br>Network: vmbr1 | IP: 10.0.0.1/24</p><p>Win11-FlareVM<br>Role: Main analysis workstation<br>OS: Windows 11 + FlareVM<br>vCPU: 4 | RAM: 8 GB | Disk: 80 GB<br>Network: vmbr1 | IP: 10.0.0.2/24</p><p>Win10-Victim<br>Role: Secondary target<br>OS: Windows 10<br>vCPU: 2 | RAM: 4 GB | Disk: 60 GB<br>Network: vmbr1 | IP: 10.0.0.3/24</p><p>During initial setup and updates, I temporarily gave the Windows VMs a NAT NIC on vmbr0. After installing updates and FlareVM, I removed the NAT NIC and moved the VMs to vmbr1.</p><h3>Proxmox Configuration</h3><h3>1. Create the isolated bridge</h3><p>In Proxmox:</p><ol><li>Go to <strong>Datacenter → Node → System → Network</strong>.</li><li>Click <strong>Create → Linux Bridge</strong>.</li><li>Name it vmbr1.</li><li>Leave <strong>Bridge ports</strong> empty.</li><li>Do not assign an IP address or gateway.</li><li>Apply the configuration.</li></ol><p>This creates a virtual switch that only the lab VMs can see.</p><h3>2. Create the VMs</h3><p>I created three VMs using the specifications above. For Windows 11, I used:</p><ul><li><strong>BIOS:</strong> OVMF/UEFI</li><li><strong>TPM:</strong> enabled, TPM 2.0</li><li><strong>Disk:</strong> VirtIO or SATA depending on the driver stage</li><li><strong>Network:</strong> VirtIO</li><li><strong>ISO:</strong> Windows 11 ISO</li></ul><p>Windows 10 and REMnux used standard defaults.</p><h3>3. Take an early snapshot</h3><p>Before installing tools or running any samples, I created a snapshot:</p><p>Snapshot name: clean-install</p><p>I also took snapshots after FlareVM installation and after network isolation.</p><h3>REMnux Configuration</h3><p>REMnux is the Linux analysis VM. I assigned it a static IP:</p><p>sudo ip addr add 10.0.0.1/24 dev eth0</p><p>To make the configuration persistent, I configured it through the REMnux/Ubuntu network settings. I did <strong>not</strong> set a default gateway because the isolated network has no internet route.</p><p>I verified connectivity from the Windows VMs:</p><p>ping 10.0.0.1</p><h3>Windows 11 FlareVM Configuration</h3><h3>1. Install Windows 11</h3><p>I installed Windows 11 normally, then installed the Proxmox/QEMU guest tools and VirtIO drivers where needed.</p><h3>2. Install FlareVM</h3><p>Inside the Windows 11 VM, I installed FlareVM using the standard Mandiant/FLARE installer. This takes time and should be done while the VM temporarily has internet access.</p><p>After FlareVM was installed:</p><ol><li>Disable Windows Update as appropriate for the lab.</li><li>Disable Windows Defender real-time protection <strong>only inside the isolated lab</strong>.</li><li>Take a snapshot called flarevm-installed.</li><li>Remove the NAT NIC and connect only to vmbr1.</li><li>Set a static IP</li></ol><h3>3. Verify isolation</h3><p>From Windows 11:</p><p>ping 10.0.0.1<br>ping 10.0.0.3</p><p>Then confirm external access fails:</p><p>ping 8.8.8.8</p><p>It should fail. That is expected and desired.</p><h3>Windows 10 Configuration</h3><p>Windows 10 was configured the same way:</p><ul><li>Install Windows 10.</li><li>Install guest tools.</li><li>Temporarily use NAT for updates.</li><li>Move the VM to vmbr1.</li><li>Set a static IP</li></ul><p>I used this VM as a secondary target for testing, not as the primary analysis workstation.</p><h3>What I’d Do Differently Next Time</h3><ul><li>Automate static IP configuration with a small PowerShell script.</li><li>Keep a separate “update mode” snapshot with NAT enabled.</li><li>Document every tool version in a lab-notes.md file.</li><li>Use a password manager for lab-only credentials.</li><li>Store sample hashes separately from the samples themselves.</li></ul><h3>Final Thoughts</h3><p>This lab provides a safe, repeatable environment for malware analysis and reverse engineering. The key design choices were:</p><ul><li>Proxmox with a dedicated isolated bridge</li><li>Static IPs on 10.0.0.0/24</li><li>REMnux for Linux-based analysis</li><li>Windows 11 + FlareVM for tooling</li><li>Windows 10 as a secondary target</li><li>Snapshots before every risky action</li></ul><p>The result is a clean, isolated setup that can be rolled back quickly and rebuilt when needed</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0592e0b4d7ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Found the Smallest HEIC That Crashes libheif]]></title>
            <link>https://medium.com/@moofaa69/i-found-the-smallest-heic-that-crashes-libheif-3f3ea4b7c5c2?source=rss-d788461ee39a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f3ea4b7c5c2</guid>
            <category><![CDATA[exploit-development]]></category>
            <category><![CDATA[heif]]></category>
            <category><![CDATA[cve-2026-84383]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[Mohamed fahmy]]></dc:creator>
            <pubDate>Sun, 04 Oct 2026 12:51:56 GMT</pubDate>
            <atom:updated>2026-10-10T01:23:39.521Z</atom:updated>
            <content:encoded><![CDATA[<p>I Found the Smallest HEIC That Crashes libheif</p><p>A few weeks ago Hacktron dropped HEIF Heist, a whole family of attacks against image decoders. Buried in there was CVE-2026–84383 — a heap overflow in libheif’s image scaler, CVSS 9.8, fixed in 1.23.2. The advisory is well written. It walks through the whole chain: duplicate alpha planes created through nested iden/auxl references, a 16-bit write into an 8-bit allocation, the overflow happening at pixelimage.cc:1964.</p><p>But something bugged me. The PoC in the advisory uses a 128×128 output. It overflows by about 16 KB past the allocation. That’s not a minimal trigger — that’s just the case the reporter built. It’s a clean 2× upscale from 64×64, easy to reason about, obviously overflowing. There was no attempt to find where the boundary actually sits.</p><p>So I built it myself and swept the widths.<br>First, the boring setup</p><p>I cloned libheif, built both 1.23.1 and 1.23.2 with clang and ASan, and wrote a small Python generator that produces HEIF files with iden chains and auxl alpha references at mismatched bit depths. The generator took a couple of iterations — the first version used illegal mask bit depths and the decoder rejected it before ever reaching the bug. Once that was fixed, the duplicate-alpha preset worked.</p><p>Then I swept heights fixed at 64 and widths from 8 up to 64 in steps of 4, running each file under ASan.<br>What I expected vs. what I got</p><p>I figured the crash threshold would land somewhere around 32 or 48 pixels — one of those round allocator numbers. I was wrong about where.<br>For most of the sweep, the destination allocation is 4,111 bytes regardless of width. That number is constant from width 8 all the way to width 64, which sounds wrong until you realize the destination stride has a 64-byte floor. Below width 64, every 8-bit row is still 64 bytes wide, because the allocator rounds up. So a 40×64 image and an 8×64 image have the same destination allocation.</p><p>What changes is the write extent. The second alpha plane is 16-bit, so the last row writes 2 × width bytes instead of 1 × width. For width 36, that last-row write ends 7 bytes short of the allocation. For width 40, it ends 1 byte past.</p><p>width last write ends alloc gap<br>8 4,048 4,111 −63<br>16 4,064 4,111 −47<br>24 4,080 4,111 −31<br>32 4,096 4,111 −15<br>36 4,104 4,111 −7<br>40 4,112 4,111 +1<br>48 4,128 4,111 +17<br>64 4,160 4,111 +49</p><p>40×64 crashes. 36×64 doesn’t. The gap between them is eight pixels wide, seven bytes of headroom on one side, one byte of overflow on the other.</p><p>The ASan report for the 40×64 case is clean and specific:<br>0x52100000750f is located 0 bytes after 4111-byte region<br>[0x521000006500,0x52100000750f)</p><p>WRITE of size 2 at 0x52100000750e thread T0<br> #0 HeifPixelImage::scale_nearest_neighbor …<br> pixelimage.cc:1964<br> <br>4,111 bytes. Same number the table predicts.<br>The formula, if you want it</p><p>The allocation isn’t width × height. It’s stride-aligned with a floor:<br>stride(W) = round_up_to_16(max(64, W))<br>alloc_size(W,H) = stride(W) × H + 15<br>write_end(W,H) = (H − 1) × stride(W) + 2W</p><p>The crash fires when write_end &gt; alloc_size. The +15 is the allocator’s round-up. The 2W term on the last row is the 16-bit write. The rest of the rows advance by the 8-bit destination stride, which is why the mismatch only shows up on the last line.</p><p>Plug in 128×128 and you get alloc = 16,399, write_end = 16,512. That matches the ASan report in the original advisory exactly, which was a nice sanity check that the model was right.<br>Why small widths survive</p><p>The 64-byte stride floor is doing all the work here. For small images, the destination row padding absorbs the extra byte from the 16-bit write. The bug is still firing — the code really is writing 2 bytes per sample into a 1-byte allocation — but ASan doesn’t see it until the write extends past the region boundary. Below width 40, the padding is bigger than the overflow.</p><p>This is why the advisory’s PoC picked 128×128. Any width above ~40 works. The reporter probably just wanted a comfortable margin.</p><p>What I did with the boundary</p><p>Once I had 36×64 clean and 40×64 crashing, I ran both against 1.23.2 and 1.23.4. All four combinations clean. The fix holds at the exact edge, not just at the larger PoC size.</p><p>That’s the part that actually matters for maintainers. Anyone can verify a fix at 128×128. Testing at the byte boundary is where you find out if the check is off-by-one.<br>Why anyone would care</p><p>Three things:</p><p>Fuzzer corpora benefit from tighter reproducers. A 3.3 KB file that triggers the bug is better than a 16 KB one — fewer mutations to stay in the code path.</p><p>Regression tests benefit from boundary pairs. If someone later changes the allocator or the scaler, the 36×64 clean / 40×64 crash pair catches a shift in the wrong direction.</p><p>Detection heuristics benefit from knowing the minimum. A signature that says “small HEIC with dual-alpha chain” gets tighter when you know the smallest one is 40×64.<br>What this isn’t</p><p>Not a new CVE. Same bug, CVE-2026–84383. Not a fix bypass — both 1.23.2 and 1.23.4 are clean at every width I tested. Not a severity change. The CVSS is still 9.8.</p><p>It’s just a measurement. The advisory didn’t have the boundary. Now it does.<br>One thing I got wrong along the way</p><p>My first model of the overflow was 2W × H versus W × H, which predicted 36×64 should crash. It doesn’t. The correct model is per-row: destination stride on every row except the last, then 2W on the last row. I caught it by comparing against the advisory’s own ASan numbers — if the model didn’t reproduce their 16,399 allocation for 128×128, it was wrong. Worth doing that cross-check before trusting your own arithmetic.<br>Disclosure</p><p>I’ve submitted the refinement to the libheif repository as a documentation note on the existing public advisory. The reproducer is a 10,724-byte file, reproducible from the same generator pattern the advisory’s PoC uses. I’ll link the issue in the comments once it’s up.</p><p>If you’re running something that decodes untrusted HEIF, the actionable advice hasn’t changed: libheif 1.23.2 or later, ideally 1.23.4. This post just tells you what to test with.<br>I did this as local-only research. No exploit code — the boundary measurement is the deliverable.</p><p>All numbers were verified by hand against ASan builds before writing them down.</p><p><a href="https://github.com/strukturag/libheif/issues/1925#issuecomment-6090118539">https://github.com/strukturag/libheif/issues/1925#issuecomment-6090118539</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f3ea4b7c5c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>