# Threat Researcher’s Notebook: BubbleLoader

BubbleLoader patches benign executables' entry points and embeds two PNGs to decrypt and reflectively load malicious payloads, evading static detection.

- Payout: Real-world hack
- Program: BubbleLoader
- Analysis by: ReversingLabs
- Disclosed: 2026-11-17
- Write-up quality: 8/10
- Original: https://www.reversinglabs.com/blog/threat-researchers-notebook-bubbleloader
- Library page: https://bugbountylibrary.com/r/blog%3Areversinglabs-com-blog-threat-researchers-notebook-bubbleloader
- Tags: area:os domain:desktop impact:rce kind:incident platform:threat-intel tech:windows technique:reverse-engineering technique:source-review vuln:misconfiguration vuln:secrets-leak

**Target:** Windows PE executables (WinRAR, x64dbg, Windows Media Player, Firefox Launcher, virtiofs)
**Root cause:** The loader overwrites the host PE entry point with position-independent shellcode that allocates executable memory and copies two embedded PNGs; the second fake PNG hides stage-2 shellcode and XOR-encrypted stage-3, keyed by the first PNG.
**Steps:**
1. Patch host PE entry point with obfuscated prologue using GetPC to compute image base into `rbx`.
2. Fabricate a call to `GetModuleHandleW` via call/pop and jump to IAT offset; ASCII attempt fails, falls back to wide `kernel32` string.
3. Resolve `GetProcAddress` and `VirtualAlloc` similarly, allocate RWX memory.
4. Copy both PNGs into allocated memory and jump to shellcode offset in the second (fake) PNG.
5. Stage-2 shellcode compares PNG magic bytes, then uses first PNG bytes as rolling XOR key to decrypt stage-3 from fake PNG.
6. Stage-3 loader reads image base from PEB `gs:0x60`, resolves ExitProcess/RtlAddFunctionTable/RtlPcToFileHeader/VirtualAlloc/VirtualProtect.
7. Decrypt final payload PE, overwrite compiler `0xcc` padding with `rdtsc` randomness for runtime polymorphism, leaving the leftmost `0xcc` byte untouched.
8. Reflectively load payload: map sections, relocations, TLS callbacks, imports, VirtualProtect; register `.pdata` via RtlAddFunctionTable and inline-hook RtlPcToFileHeader for SEH support.
9. Call payload entry point with DLL_PROCESS_ATTACH semantics, then ExitProcess.
**How found:** Reverse engineering of samples: noticed obfuscated entry-point prologue, GetPC image-base computation, call/pop string tricks, invalid PNG with truncated IHDR, sparse XOR key leaving plaintext strings, and opaque predicates in the decryption loop.
**Exploitation:** Adversaries distribute patched legitimate binaries (WinRAR, x64dbg, etc.) carrying two PNG resources; on execution the entry-point patch decrypts and reflectively loads a variable final payload, delivering secondary malware while evading static hash detection via runtime polymorphism.
**Escalation:** Runtime polymorphism rewrites compiler padding with CPU timestamps so the in-memory payload hash changes every execution, defeating signature-based detection.
**Insight:** A gradient PNG used as XOR key yields long null stretches that leave plaintext shellcode strings visible; also check embedded PNGs whose IHDR width field is truncated (non-zero MSB) as a cheap static detector for hidden stages.

