
Proof-of-concept and exploit for CVE-2026-131873, a stack buffer overflow in Gargoyle's Plus interpreter ReadAction(), with an ASan/UBSan differential lab against the vendor fix.
ReadAction() via unterminated action conditions| CVE | CVE-2026-131873 |
| Component | Gargoyle — bundled Plus interpreter, terps/plus/loaddatabase.c::ReadAction() |
| Affected | Gargoyle 2023.1 through 2026.1.1 |
| Fixed in | commit 45385f1 (the Spatterlight 1.5.5 import) — genuine vendor fix |
| CWE | CWE-787 (Out-of-bounds Write), CWE-121 (Stack-based Buffer Overflow) |
| Impact | A crafted or truncated .plus game file crashes the interpreter with attacker-controlled values written past a 1024-entry stack array — arbitrary code execution is plausible in an unsanitized build; this lab proves the out-of-bounds write with ASan+UBSan on both builds |
| Vector | File format — a game library or upload service that opens an untrusted .plus file with Gargoyle/Spatterlight |
| Trigger | one action whose condition chain never sets the 0x8000 terminator bit (a truncated file suffices — EOF makes ReadNum() return 0 forever) |
ReadAction() writes condition/argument pairs into a fixed 1024-entry
stack array without ever checking the index:
// terps/plus/loaddatabase.c @ 2026.1.1 (~L730)
uint16_t conditions[1024];
int condargs = 0;
while (reading_conditions) {
uint16_t argcond = ReadNum(f) * 256 + ReadNum(f);
if (argcond & 0x8000)
reading_conditions = 0;
argcond = argcond & 0x7fff;
uint16_t argument = argcond >> 5;
uint16_t condition = argcond & 0x1f;
conditions[condargs++] = condition; // ← unbounded
conditions[condargs++] = argument;
}
The fix replaces this with AddCondition():
if (*condargs + 2 > MAX_CONDITION_ARGS)
Fatal("Broken database!");
Both trees are compiled with ASan+UBSan and driven through the same
headless harness that calls the real LoadDatabasePlaintext() loader.
The condition chain is a variable-length sequence terminated by a high
bit in the first byte of each 16-bit condition entry. ReadAction()
assumes a well-formed game file will terminate before 1024 entries and
never checks condargs. ReadNum() returns 0 on EOF, so a file truncated
inside the chain turns the loop into an unbounded write of zeros past
the stack array; a crafted file can choose every written value. The
vendor's 1.5.5 import bounds-checks every append and aborts cleanly.
| service | image | role |
|---|---|---|
gargoyle-vuln | cve-2026-131873:vuln | Plus loader from tag 2026.1.1 (ASan+UBSan) |
gargoyle-fixed | cve-2026-131873:fixed | Plus loader from the fix commit 45385f1 (ASan+UBSan) |
poc | cve-2026-131873-poc:local | stdlib-only Python driver that writes the .plus bytes |
The service models a game library: POST /load accepts raw .plus
bytes, saves them, and runs the loader as a child process; the report
contains the exit code, the sanitizer signature and the first lines of
the sanitizer report. The harness is identical on both sides — it only
supplies the common-layer globals that plusmain.c normally owns and
calls the real plaintext loader.
./run-lab.sh build # compile both Plus loaders with ASan+UBSan
./run-lab.sh up # cve131873lab network: gargoyle-vuln / gargoyle-fixed
./run-lab.sh sweep # check / exploit / probe / mitigation on both sides
./run-lab.sh down
A standalone full-chain exploit script ships at exploit/exploit.py
(python3 exploit/exploit.py --host=<target>; exit 1 on confirmed
exploitation, 0 on a safe target).
poc/poc.py (stdlib only) writes a minimal plaintext database: a known
game title, the 18-field header (NumActions=1), then an action with an
unterminated condition chain. Modes:
| case | gargoyle-vuln (2026.1.1) | gargoyle-fixed (fix commit) |
|---|---|---|
| terminated chain (control) | loader continues to later (missing) sections | condition chain accepted; later EOF → clean Fatal |
| unterminated chain | UBSan OOB index + ASan stack-buffer-overflow, SIGABRT | Fatal: Broken database!, exit 1 |
| truncated after 3 pairs | same ASan crash | Fatal: Broken database! |
| long unterminated chain | same ASan crash | Fatal: Broken database! |
Captured runs: evidence/check-*-run.txt, evidence/exploit-*-run.txt,
evidence/probe-*-run.txt, evidence/mitigation-*-run.txt,
evidence/versions.txt, evidence/0day-sweep.txt.
cve131873lab
network.evidence/versions.txt).The fixed build's AddCondition() closes every unterminated-chain form
in the probe matrix, including a chain truncated after three pairs and a
4000-pair chain (evidence/0day-sweep.txt). The terminated-chain control
reaches later sections of the deliberately minimal file and ends in a
clean Fatal("EOF in string"), never an out-of-bounds write. No second
unbounded append was found in the plaintext loader path.
README.md this write-up
run-lab.sh environment driver (build / up / sweep / down)
Makefile convenience targets
exploit/exploit.py standalone full-chain exploit
poc/poc.py the PoC (check / exploit / probe / mitigation)
poc/Dockerfile runner image (python:3.12-alpine)
lab/lab.Dockerfile multi-stage build (both trees, ASan+UBSan)
lab/harness/ headless driver + common-layer stand-ins
lab/service.py game-file loading service (POST /load)
evidence/ captured runs of every mode on both sides
TRACKING.md excluded (working record)