Skip to content
SPIG

SPIG

Secure Pre-Execution Image Guard

Created on 29th November 2026

•

SPIG

SPIG

Secure Pre-Execution Image Guard

The problem SPIG solves

Windows renders images automatically. Opening a folder generates thumbnails, a chat or email client previews an attachment, and a browser decodes a download. In each case the image decoder parses attacker-controlled bytes before the user has decided to trust the file.

Image decoders are complex native code, and they have had many memory-corruption bugs. A crafted JPEG, PNG or WebP can trigger one of them with no click and no "run" step. Typically the image only has to be displayed. This is the zero-click case.

Why current defenses don't cover it

Antivirus mostly scans after a file lands, or matches known signatures. A new malformed image can be parsed by the decoder before any verdict exists.
Rendering is treated as safe, so nothing sits between "file arrives" and "decoder touches it".
A file can change between the scan and the open (TOCTOU), so a scan result doesn't prove the opened bytes are the ones that were scanned.
Many tools fail open. On a timeout or error, the file goes through anyway.

What SPIG does

Holds each new image in a quarantine folder, so nothing renders it until it is scanned.
Scans it in six layers: structure, metadata, entropy, polyglot, sandboxed decode and anomaly score.
Releases it only on a SAFE verdict, and only if the SHA-256 of the released bytes equals the SHA-256 of the scanned bytes.
Holds the file on any error, timeout or unknown result (fail closed).

One-line pitch: "SPIG scans images before anything renders them, and it releases only the exact bytes it scanned."

What it does not claim

It does not detect every exploit. A perfectly well-formed file that exploits a real decoder bug can pass, because there is no signature database.
It catches malformed, polyglot and decompression-bomb images, and images with payloads hidden in metadata or appended data.
The Windows build works. The release, hold and destroy behaviour has not been run on Windows yet.

Challenges we ran into

False positives. Our first heuristics held or destroyed legitimate files. A bare MZ or #! byte pair inside compressed data looked like a hidden executable, and high entropy and extreme compression ratios flagged normal photos. We tightened each check. A hit now needs a real PE header (an MZ marker whose header offset points at PE\0\0) or a real shebang line. Entropy and compression ratio alone now hold a file instead of destroying it, and only a real malicious finding destroys one.
Closing the time-of-check/time-of-use gap. Scanning a file does not prove the bytes later released are the same ones. The watcher opens the file exclusively, rejects reparse points, and moves it through the open handle. The SHA-256 is checked at the watcher, the scanner, the policy gate and again in quarantine.exe at release.
A release loop. A released file landed back in the watched folder and was scanned again. We fixed it by releasing only to C:\ProgramData\SPIG\release, enforced in both the policy engine and quarantine.exe.
Files already present or missed. The watcher only saw new events, so we added a startup sweep and a rescan when the change buffer overflows.
Unsupported formats were being destroyed. We found that GIF, BMP, TIFF and ICO files were marked MALICIOUS only because the scanner doesn't parse them. They are now held as SUSPICIOUS. We found this by checking our own claims against the code, so we corrected the docs to match.
Overclaiming. Some of our own early claims were wrong, such as "registry lockdown is off by default" and "unknown formats are held". We fixed the code and the wording, so the demo claims only what has passed tests.
Three languages, one trust boundary. The C watcher, the Python orchestrator and the Rust scanner each had to agree on message formats, hashes and fail-closed behaviour. The orchestrator decides, and only the C side moves files.
Windows tooling. Include-path errors in VS Code and the MSVC/MinGW/CMake differences cost us time. Most of the "bugs" were IntelliSense configuration, not code. build_all.bat now completes on Windows.
Limited testing. The unit tests (18 Rust, 10 Python) ran on Linux, and on Windows only the build has been verified. We don't yet know how release, hold and destroy behave there, which is why the demo avoids claims we haven't tested.
Known gaps we chose to state. The decoder sandbox has no restricted token or Low integrity level. A legitimate photo with trailing data can be treated as malicious. There is no signature database. The tool runs as a console process, not a service.

Discussion

Builders also viewed

See more projects on Devfolio