{"slug": "math-random-is-not-a-secret-session-key-lessons-from-the-check-point-intrusion", "title": "Math.random() Is Not a Secret: Session Key Lessons From the Check Point Intrusion Campaign", "summary": "GreyNoise detailed an intrusion campaign, tracked as GT13, in which an attacker predicted the Math.random()-based session signing key of a Rejetto HFS 3 file server (CVE-2026-61500, CVSS 9.3), forged an admin cookie, and used the box as a relay to control and steal data from 24 Check Point Security Management Servers at 22 organizations. Horizon3.ai, which found the flaw using Anthropic's Mythos model, traced the chain through HFS's use of Math.random() for cookie signing keys and a login handshake that leaked generator outputs, plus an admin-defined server_code feature enabling remote code execution. GreyNoise did not attribute GT13 to a known group and said it could not determine how attackers first gained access to the Check Point servers.", "body_md": "The attacker did not guess the admin password. They predicted the random number generator.\n\nThat 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.\n\nBelow: 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.\n\nA 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.\n\nGreyNoise runs a large network of sensors that attract attackers. In its [report on the campaign](https://www.greynoise.io/blog/check-point-security-management-servers-intrusion-campaign), which it tracks as GT13 (GreyNoise Threat 13), the company says:\n\nGreyNoise 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](https://news.ycombinator.com/item?id=50630594) had 269 points when this was written.\n\nThe 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](https://www.cve.org/CVERecord?id=CVE-2026-61500), rated 9.3 (critical), and it affects HFS 3.0.0 through 3.2.0.\n\nHorizon3.ai found it using Anthropic's Mythos model and described the chain in a [September 30 write-up](https://horizon3.ai/attack-research/disclosures/anthropic-mythos-rejetto-hfs-rce/). It has three parts.\n\n**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](https://github.com/rejetto/hfs/blob/5a0c3962f0a70adac7a488101afe5492f50c2085/src/index.ts)):\n\n``` js\nconst keys = process.env.COOKIE_SIGN_KEYS?.split(',')\n    || [randomId(30)] // randomness at start gives some extra security, btu also invalidates existing sessions\nexport const app = new Koa({ keys })\n```\n\nAnd `randomId` was built on `Math.random()`:\n\n```\nexport function randomId(len = 10): string {\n    if (len > 10)\n        return randomId(10) + randomId(len - 10)\n    return Math.random()\n        .toString(36)\n        .substring(2, 2+len)\n        .replace(/l/g, 'L'); // avoid confusion reading l1\n}\n```\n\nSo a 30-character key is just three `Math.random()` outputs, taken one after another when the process starts.\n\n**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.\n\n**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.\n\nPut 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.\n\nGreyNoise 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`.\n\nThe fix shipped in [HFS v3.2.1](https://github.com/rejetto/hfs/releases/tag/v3.2.1) on July 13, 2026. The current code looks like this ([src/index.ts on main](https://github.com/rejetto/hfs/blob/main/src/index.ts)):\n\n``` js\nconst keys = process.env.COOKIE_SIGN_KEYS?.split(',')\n    || [randomBytes(32).toString('base64url')] // cookie signatures need randomness that cannot be reconstructed from observable Math.random() output\n```\n\nThe login handshake now uses `randomUUID()` from `node:crypto` for `sid`. Both changes swap a predictable generator for Node's cryptographically secure one.\n\nThe timing matters too. The patch was out in July. A public proof-of-concept appeared in late September, and [BleepingComputer reported](https://www.bleepingcomputer.com/news/security/rejetto-hfs-servers-now-actively-scanned-for-critical-rce-flaw) scanning for the flaw on October 5. The server GreyNoise watched was still unpatched on October 2.\n\n`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.\n\nIn V8, the JavaScript engine inside Chrome and Node.js, that formula is xorshift128+. The [V8 team's blog post](https://v8.dev/blog/math-random) 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.\"\n\nTwo facts make that warning real:\n\nA 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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random): `Math.random()` does not \"provide cryptographically secure random numbers. Do not use them for anything related to security.\"\n\nThis is a known weakness class with its own number, [CWE-338](https://cwe.mitre.org/data/definitions/338.html) (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.\n\nThe same rule applies outside JavaScript. The [Java docs for java.util.Random](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/Random.html) say: \"Instances of java.util.Random are not cryptographically secure. Consider instead using SecureRandom.\" The [Python random module](https://docs.python.org/3/library/random.html) says its generators \"should not be used for security purposes\" and points to the `secrets` module.\n\nWith 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](https://www.cve.org/CVERecord?id=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.\n\nOn 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.\n\nCheck Point disclosed CVE-2026-16232 on July 22, 2026, in a [security advisory](https://blog.checkpoint.com/security/security-advisory-action-required-active-exploitation-of-check-point-smartconsole-authentication-bypass-cve-2026-16232/), and said it was already exploited in the wild, affecting \"a handful of customers.\" Its support article [sk185169](https://support.checkpoint.com/results/sk/sk185169) lists the details:\n\n[Rapid7's technical analysis](https://www.rapid7.com/blog/post/ra-check-point-smartconsole-authentication-bypass-technical-analysis-cve-2026-16232/) 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.\n\nThe two bugs look different, but they share one root problem: the server trusted a value the attacker could see or set.\n\nIn 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.\n\nThe OWASP [Session Management Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html) 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.\n\n**Node.js.** Use the built-in [crypto module](https://nodejs.org/api/crypto.html). The docs describe `randomBytes` as \"cryptographically strong pseudorandom data\", and `randomUUID` also uses a cryptographic generator.\n\n``` js\nimport { randomBytes, randomUUID } from 'node:crypto'\n\n// A signing key or API token: 32 random bytes, URL-safe text\nconst signingKey = randomBytes(32).toString('base64url')\n\n// A session or request id\nconst sessionId = randomUUID()\n```\n\nIn the browser, use `crypto.getRandomValues()` or `crypto.randomUUID()` from the Web Crypto API instead of `Math.random()`.\n\n**Java.** Use `java.security.SecureRandom`, and share one instance instead of creating one per call.\n\n``` python\nimport java.security.SecureRandom;\nimport java.util.Base64;\n\npublic final class Tokens {\n    private static final SecureRandom RNG = new SecureRandom();\n\n    private Tokens() {}\n\n    public static String newToken() {\n        byte[] bytes = new byte[32];\n        RNG.nextBytes(bytes);\n        return Base64.getUrlEncoder().withoutPadding().encodeToString(bytes);\n    }\n}\n```\n\nSpring 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.\n\n**Python.** Use the [secrets module](https://docs.python.org/3/library/secrets.html).\n\n``` python\nimport secrets\n\ntoken = secrets.token_urlsafe(32)  # 32 random bytes, URL-safe text\n```\n\nBeyond the generator itself, four habits close the gaps behind this bug:\n\n`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.`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.\nFrom Check Point's sk185169 and the GreyNoise report:\n\n`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`.` server_code` scripts and new SSH keys.\nThere are two AI claims in this story, and they are different.\n\nThe 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.\n\nThe 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.\n\nThe 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.\n\nHave 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?", "url": "https://wpnews.pro/news/math-random-is-not-a-secret-session-key-lessons-from-the-check-point-intrusion", "canonical_source": "https://dev.to/jamilxt/mathrandom-is-not-a-secret-session-key-lessons-from-the-check-point-intrusion-campaign-1a8b", "published_at": "2026-11-25 03:09:46+00:00", "updated_at": "2026-11-25 03:12:19.306042+00:00", "lang": "en", "topics": ["ai-safety", "ai-research", "artificial-intelligence"], "entities": ["GreyNoise", "Check Point", "Rejetto HFS", "Horizon3.ai", "Anthropic", "Mythos", "Node.js", "Koa"], "also_reported_by": [], "takeaway": "Never generate session signing keys with Math.random(): HFS 3.0.0-3.2.0 built its 30-character Koa cookie key from three sequential Math.random() outputs and leaked further outputs via a login sid, letting attackers reconstruct the generator state and forge admin cookies.", "recommendation": {"advice": "Generate session signing keys with a cryptographically secure source like crypto.randomBytes and never expose PRNG outputs in cookies or login handshakes.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/math-random-is-not-a-secret-session-key-lessons-from-the-check-point-intrusion", "markdown": "https://wpnews.pro/news/math-random-is-not-a-secret-session-key-lessons-from-the-check-point-intrusion.md", "text": "https://wpnews.pro/news/math-random-is-not-a-secret-session-key-lessons-from-the-check-point-intrusion.txt", "jsonld": "https://wpnews.pro/news/math-random-is-not-a-secret-session-key-lessons-from-the-check-point-intrusion.jsonld"}}