Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 12 min read

Math.random() Is Not a Secret: Session Key Lessons From the Check Point Intrusion Campaign

The attacker did not guess the admin password. They predicted the random number generator. That is the first step in an intrusion campaign described this week by GreyNoise, a threat intelligence company. The attacker st

The attacker did not guess the admin password. They predicted the random number generator.

That is the first step in an intrusion campaign described this week by GreyNoise, a threat intelligence company. The attacker started a few logins on a small file server, collected the "random" values it sent back, and worked out the server's secret cookie key from them. With that key they made their own admin cookie and took over the server. They then used that server as a relay to control and steal data from 24 Check Point Security Management Servers at 22 organizations.

Below: the two weak points in that chain, why Math.random() can be predicted, and fixes in Node.js, Java and Python, plus checklists for Check Point and HFS admins.

A note on sources: everything below comes from the GreyNoise report, the Horizon3.ai write-up, vendor advisories and the HFS source code, all linked inline. I have not reproduced the attack. The token samples are standard library calls checked against the official docs.

What GreyNoise saw

GreyNoise runs a large network of sensors that attract attackers. In its report on the campaign, which it tracks as GT13 (GreyNoise Threat 13), the company says:

  • Confirmed attack activity ran from October 17 to November 2, 2026, and hit at least 22 organizations with assets in 17 countries, across sectors such as finance, energy, government and mining.
  • The actor used 99 IP addresses. All of them were either ExpressVPN exits or compromised Check Point devices.
  • A compromised server acted as an "operational relay box" (a hop between the attacker and the victims). The attacker stored command results and data stolen from 24 Check Point Security Management Servers on it.
  • Tools included Nmap, Chisel (a tunnel tool), Impacket and Paramiko.
  • GreyNoise saw hands-on-keyboard activity but believes the actor used LLMs and agent systems for scanning, exploitation, tool building and automated work on compromised machines.
  • GreyNoise's view stopped around November 2. Because the actor still had access to victim devices, the company expects the campaign is ongoing.

GreyNoise does not attribute GT13 to any known group. It also says the attacker already had access to the Check Point servers before compromising the relay box, and it could not determine how that first access happened. Keep that in mind: the two bugs below explain how the attacker built the relay and ran commands, not necessarily how it first got in. The Hacker News thread had 269 points when this was written.

Step 1: How a file server's random numbers became an admin login

The relay box ran Rejetto HFS (HTTP File Server), an open-source file-sharing tool. Version 3 is TypeScript on Node.js with the Koa web framework. The bug is CVE-2026-61500, rated 9.3 (critical), and it affects HFS 3.0.0 through 3.2.0.

Horizon3.ai found it using Anthropic's Mythos model and described the chain in a September 30 write-up. It has three parts.

The signing key came from Math.random(). Koa signs session cookies with a list of keys. A signed cookie cannot be changed by the client without breaking the signature, so the key must stay secret. If the COOKIE_SIGN_KEYS environment variable was not set, HFS made a key at startup like this (from the vulnerable version of src/index.ts):

const keys = process.env.COOKIE_SIGN_KEYS?.split(',')
    || [randomId(30)] // randomness at start gives some extra security, btu also invalidates existing sessions
export const app = new Koa({ keys })

And randomId was built on Math.random():

export function randomId(len = 10): string {
    if (len > 10)
        return randomId(10) + randomId(len - 10)
    return Math.random()
        .toString(36)
        .substring(2, 2+len)
        .replace(/l/g, 'L'); // avoid confusion reading l1
}

So a 30-character key is just three Math.random() outputs, taken one after another when the process starts.

The login handshake leaked more Math.random() outputs. During login, the loginSrp1 endpoint set sid = Math.random() and stored it in the session. Koa session cookies are base64-encoded JSON. They are signed, but not encrypted, so anyone can decode their own cookie and read the exact number. Getting that cookie only needed a valid username, not a password.

The server could run admin-defined JavaScript. HFS has a documented server_code feature that lets an admin add server-side JavaScript. Once you are admin, that is remote code execution.

Put together: request a login a few times, collect the leaked numbers, rebuild the generator's internal state, step it backwards to the three outputs used at startup, rebuild the key, and sign a cookie that says you are admin. Horizon3's exploit sampled the leaking endpoint 12 times and used Z3, a free constraint solver from Microsoft, to recover the state. You can even check a guessed key offline, because your own legitimately issued cookie carries a signature made with the real key.

GreyNoise saw exactly this pattern. On October 2 at 13:17 UTC the actor started sending login requests to the HFS server. At 13:19 UTC, about two minutes later, admin requests with forged cookies arrived. The forged session included allow_session_ip_change:true, so the cookie worked from any IP address. Three days later the actor used the same route to add an SSH key to /root/.ssh/authorized_keys.

The fix shipped in HFS v3.2.1 on July 13, 2026. The current code looks like this (src/index.ts on main):

const keys = process.env.COOKIE_SIGN_KEYS?.split(',')
    || [randomBytes(32).toString('base64url')] // cookie signatures need randomness that cannot be reconstructed from observable Math.random() output

The login handshake now uses randomUUID() from node:crypto for sid. Both changes swap a predictable generator for Node's cryptographically secure one.

The timing matters too. The patch was out in July. A public proof-of-concept appeared in late September, and BleepingComputer reported scanning for the flaw on October 5. The server GreyNoise watched was still unpatched on October 2.

Why Math.random() can be predicted

Math.random() is a pseudo-random number generator (PRNG). It keeps a small internal state, runs a fixed formula on it, and gives you a number. Same state in, same numbers out.

In V8, the JavaScript engine inside Chrome and Node.js, that formula is xorshift128+. The V8 team's blog post explains that it uses 128 bits of internal state, and then warns: "even though xorshift128+ is a huge improvement over MWC1616, it is still not cryptographically secure."

Two facts make that warning real:

  1. The state is small and the formula is public.
  2. Each output reveals bits of the state, and the steps can be reversed. With a handful of consecutive outputs, a solver can rebuild the full state. From there it can produce future outputs and step back to earlier ones.

A cryptographically secure PRNG (CSPRNG) is designed so that seeing outputs tells you nothing useful about other outputs. Secrets need that property, and Math.random() does not have it. MDN says it directly: Math.random() does not "provide cryptographically secure random numbers. Do not use them for anything related to security."

This is a known weakness class with its own number, CWE-338 (use of a cryptographically weak PRNG). What made CVE-2026-61500 exploitable was the combination: a weak generator, plus the same generator's raw output handed to anyone who asked.

The same rule applies outside JavaScript. The Java docs for java.util.Random say: "Instances of java.util.Random are not cryptographically secure. Consider instead using SecureRandom." The Python random module says its generators "should not be used for security purposes" and points to the secrets module.

Step 2: The relay box and the Check Point servers

With the relay box in place, the attacker tunneled into a victim network (GreyNoise calls it Victim A) using Chisel. Over that tunnel they used a script for CVE-2026-16232, an authentication bypass in the Check Point SmartConsole login process. GreyNoise says the actor launched over 100 management tasks on multiple Check Point Management Servers. These included copying the firewall database and the internal certificate authority (CA), minting a new certificate named pivot.p12, and unloading security policies, which would disable the firewall.

On October 26 a bulk certificate task went out to all 24 compromised servers. It failed, but the result files sent back to the relay box contained victim IP addresses, which let GreyNoise and government partners notify many victims.

Check Point disclosed CVE-2026-16232 on July 22, 2026, in a security advisory, and said it was already exploited in the wild, affecting "a handful of customers." Its support article sk185169 lists the details:

  • Products: Security Management Server and Multi-Domain Security Management Server.
  • Affected versions: R77.30 through R82.10.
  • Condition: the Management Server IP is reachable from the internet and Trusted Clients (the list of GUI client addresses allowed to connect) is not restricted.
  • Fix: Jumbo Hotfix Accumulator for R82.10 from Take 36, R82 from Take 118, and R81.20 from Take 158. R81.10 and older are end of support and have no fix listed, so they need an upgrade.

Rapid7's technical analysis found the root cause. The Java login service accepted an identity (a SIC distinguished name, Check Point's certificate-based name for a management component) that the caller simply typed into the request. It should have used the identity from the certificate the caller actually presented. An attacker could read the server's own name during the unauthenticated setup step, send it back, and be treated as a trusted internal application. Rapid7 also found that an unrestricted Trusted Clients setting was the default in its testing. The patch uses the certificate's name for remote callers and rejects mismatches.

The same mistake, twice

The two bugs look different, but they share one root problem: the server trusted a value the attacker could see or set.

  • In HFS, the "secret" key came from a generator whose output the server showed to every login attempt.
  • In SmartConsole, the "verified" identity came from a text field the client filled in.

In both cases the right value was nearby (crypto.randomBytes(), the peer certificate's name), and the code took the easier one. When you review code that handles keys, tokens or identities, ask one question about each value: could the other side have seen it or chosen it? If yes, it is not a secret and it is not proof.

Fix it in your own code: session tokens and signing keys

The OWASP Session Management Cheat Sheet sets the baseline: session IDs need "at least 64 bits of entropy" and must come from a CSPRNG. The examples below use 32 bytes (256 bits), which is more than enough and the same size HFS now uses.

Node.js. Use the built-in crypto module. The docs describe randomBytes as "cryptographically strong pseudorandom data", and randomUUID also uses a cryptographic generator.

import { randomBytes, randomUUID } from 'node:crypto'

// A signing key or API token: 32 random bytes, URL-safe text
const signingKey = randomBytes(32).toString('base64url')

// A session or request id
const sessionId = randomUUID()

In the browser, use crypto.getRandomValues() or crypto.randomUUID() from the Web Crypto API instead of Math.random().

Java. Use java.security.SecureRandom, and share one instance instead of creating one per call.

import java.security.SecureRandom;
import java.util.Base64;

public final class Tokens {
    private static final SecureRandom RNG = new SecureRandom();

    private Tokens() {}

    public static String newToken() {
        byte[] bytes = new byte[32];
        RNG.nextBytes(bytes);
        return Base64.getUrlEncoder().withoutPadding().encodeToString(bytes);
    }
}

Spring Session and servlet containers generate session IDs for you. The rule still applies to anything you create by hand: reset links, invite codes, API keys and one-time tokens.

Python. Use the secrets module.

import secrets

token = secrets.token_urlsafe(32)  # 32 random bytes, URL-safe text

Beyond the generator itself, four habits close the gaps behind this bug:

  1. Set signing keys explicitly in production. HFS only fell back to the weak key when COOKIE_SIGN_KEYS was not set. A CSPRNG-generated key from a secret manager removes that path. Koa accepts a list of keys, so you can rotate by adding a new key while keeping the old one for a while.
  2. Remember that signed is not encrypted. Koa session cookies were readable by the client. Do not put anything in a signed cookie that you would not show the user.
  3. Search for weak generators. A quick search finds most of them: grep -rnE "Math\.random\(|new Random\(|random\.random\(" src/. Most hits are harmless (shuffling, test data). Look closely at any hit near token, key, secret, session, nonce or reset.
  4. Treat "only needs a username" endpoints as public. The HFS leak sat behind a valid username, which is not a secret either. Endpoints that anyone can call should never return raw generator output or other internal state.

Check-and-fix list for Check Point admins

From Check Point's sk185169 and the GreyNoise report:

  • Patch. Confirm the Jumbo Hotfix take on every Security Management Server and Multi-Domain server: R82.10 Take 36 or later, R82 Take 118 or later, R81.20 Take 158 or later. Plan an upgrade for R81.10 and older.
  • Restrict Trusted Clients. In SmartConsole, go to Manage & Settings, then Permissions & Administrators, then Trusted Clients. Make sure no entry uses "Any" as the type.
  • Keep management off the internet. Allow management access only from trusted IP ranges, and check that the implied rules for control connections are enabled.
  • Search the audit log. In Logs & Monitor, search the Audit Logs view for "Authentication method: application token" and "Authentication method: Password based application token". Check Point says any hit should be treated as suspicious and checked for an unknown admin name or IP address.
  • Hunt for GT13 indicators. GreyNoise lists the domain newpayapp.com and subdomains data-zt, api-zt and 2ev5, the user agent strings Mozilla/5.0 (X11; Linux x86_64) research and Mozilla/5.0 research, and a long list of ExpressVPN IP addresses. One victim's output showed /usr/lib/.libproc.so registered in /etc/ld.so.preload, which may indicate an implant. Check for that file and for unknown keys in /root/.ssh/authorized_keys.
  • Patching is not cleanup. The attacker copied firewall databases, credentials and internal CA files. If you find signs of compromise, rotate credentials and treat the internal CA as exposed.

Check-and-fix list for HFS and other "quick" servers

  • Update HFS. Anything before 3.2.1 is vulnerable. The current release as of November 25, 2026 is v3.4.2.
  • Set COOKIE_SIGN_KEYS to a value from a CSPRNG, as shown above.
  • Restrict access to a VPN or trusted network. A file-sharing tool rarely needs to face the whole internet.
  • Review old internet-facing installs for unknown admin sessions, custom server_code scripts and new SSH keys.
  • Keep an inventory. The relay box here was one unpatched file server. List small tools like this with an owner so they get updates.

What the AI part does and does not mean

There are two AI claims in this story, and they are different.

The first is about finding the bug. Horizon3 says Mythos spotted the weak key and the separate leak, linked them, and wrote a working exploit. The researchers wrote that they "do not recall ever seeing an SMT solver being used to attack a cryptographic flaw like this in a real application." Their point is that bugs which used to be too slow or too mathematical to weaponize are now cheap to turn into exploits.

The second is about the attacker. GreyNoise believes GT13 used LLMs and agent systems, partly because of odd gaps in the timeline, such as the actor gaining SSH access and then not using it for two weeks. That is GreyNoise's assessment, not something it proves in the report.

The defensive lesson does not depend on either claim. Math.random() has never been safe for secrets, and the docs for JavaScript, Java and Python all say so. What has changed is how quickly someone will notice. If a weak generator sits next to a secret in your code, assume an automated tool will find it soon.

Have you ever found Math.random() or java.util.Random guarding a token in a codebase you worked on, and how did the team decide what to rotate after the fix?

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.