Heap disclosure via unchecked clipboard length in Paste Binary
Notepad++ implements binary copy and paste using two separate clipboard formats: CF_TEXT holds the bytes, and a private registered format named Notepad++ Binary Length holds the byte count. On paste, the byte count is taken from the private format and used directly as the length of the CF_TEXT buffer, with no check that the two agree and no call to GlobalSize . Any local process can publish the two formats independently, declaring a length far larger than the buffer it supplies. Notepad++ then reads that many bytes starting at the small buffer and inserts them into the document. This was confirmed by measurement: with a three byte CF_TEXT buffer and a declared length of 4096, the saved document grew by exactly 4096 bytes, and the 4093 bytes past the source buffer contained live process heap content.
The paste path is PowerEditor/src/NppCommands.cpp:665-700 :
*lpLen comes from one clipboard format and lpchar from another. Nothing requires them to be consistent. The format name is defined at PowerEditor/src/clipboardFormats.h:23 as Notepad++ Binary Length .
The invariant being trusted is established only by the matching copy path at PowerEditor/src/NppCommands.cpp:608-629 , which allocates the length block and sets *lpLenCopy = static_cast (textLen) to match the buffer it just created. An attacker publishing the two formats directly is not bound by that.
GlobalSize is called exactly once in the entire repository, at PowerEditor/src/NppCommands.cpp:3334 , on an unrelated encoding conversion path. It is not used on either consumer of this format.
The same unchecked length appears in the Clipboard History panel at PowerEditor/src/WinControls/ClipboardHistory/clipboardHistoryPanel.cpp:52-59 , where size_t nbBytes = (*lpLen); bounds a copy loop over the CF_TEXT buffer. That path is driven automatically by WM_DRAWCLIPBOARD at :233 when the panel is open, so it requires no user action at all. It was not reproduced in the test environment and is noted here for the maintainer rather than claimed.
Environment used for verification:
Notepad++ built from commit f791061 (v8.9.8) with MinGW w64 GCC 13.2 using the project's own PowerEditor/gcc/makefile .
Run under Wine on a virtual X display inside a container.
Container id 5b9ed5ec78b8 for the controlled comparison and c21432746bf1 for the heap content capture, uid 0 (root), working directory /build2/PowerEditor/gcc/bin.gcc.x86_64 .
Target window owner process id 32, reported by GetWindowThreadProcessId .
Publisher program. Build with x86_64-w64-mingw32-gcc -O1 -o clip.exe clip.c -luser32 . It publishes a two character CF_UNICODETEXT value, a three byte CF_TEXT value, and an attacker chosen length in the private format:
Create a small file, for example containing the five bytes SEED plus a newline, and open it in Notepad++.
Positive control. Run clip.exe 3 , which declares a length equal to the actual three byte CF_TEXT buffer. Invoke Edit then Paste Binary, which is command id 42050, and save.
Test. Run clip.exe 4096 , which declares 4096 bytes over the same three byte buffer. Invoke Paste Binary again and save.
Command ids were delivered with SendMessage(FindWindow(L"Notepad++"), NPPM_MENUCOMMAND, 0, id) , using 42050 for IDM_EDIT_PASTE_BINARY and 41006 for IDM_FILE_SAVE . The same effect is reachable by a user choosing Paste Binary from the Edit and saving.
The positive control inserts exactly the three bytes it was given and the document content reads ABSEED , which confirms the feature works normally in this harness and session. The test inserts exactly the declared 4096 bytes from the same three byte source, which isolates the cause to the length field rather than to the paste operation.
Inspecting the saved file from the second container, the region beyond the three byte source buffer contained 863 non zero bytes, including readable fragments of the process's own memory such as \PowerE and gcc.x86_64 . That confirms the extra bytes are live process heap rather than zero fill.
The declared length is an unsigned long taken verbatim, so the amount read is attacker chosen.
Out of bounds read. A local process that can write the clipboard can cause Notepad++ to read an attacker chosen number of bytes past a small heap allocation and insert them into the open document, where the user can see them and may save or them. The disclosed content is adjacent process heap, which can include other document data and file system paths. Triggering the Paste Binary variant requires the user to invoke that entry. The Clipboard History variant at clipboardHistoryPanel.cpp:55 reaches the same unchecked length automatically when that panel is open. All users of affected versions are impacted.
Thai Son Dinh from VinSOC Labs (R&D)
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
