{"record":{"id":"e2527203eb1a4a37","repo":"moonD4rk/HackBrowserData","slug":"ciphertext-is-not-a-multiple-of-the-block-size","errorCode":null,"errorMessage":"ciphertext is not a multiple of the block size","messagePattern":"ciphertext is not a multiple of the block size","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crypto/errors.go","lineNumber":8,"sourceCode":"package crypto\n\nimport \"errors\"\n\n// Sentinel errors for crypto operations.\nvar (\n\terrShortCiphertext   = errors.New(\"ciphertext too short\")\n\terrInvalidBlockSize  = errors.New(\"ciphertext is not a multiple of the block size\")\n\terrInvalidIVLength   = errors.New(\"IV length must equal block size\")\n\terrInvalidPadding    = errors.New(\"invalid PKCS5 padding\")\n\terrInvalidNonceLen   = errors.New(\"nonce length must equal GCM nonce size\")\n\terrUnsupportedIVLen  = errors.New(\"unsupported IV length\")\n\terrDecodeASN1        = errors.New(\"failed to decode ASN1 data\")\n\terrDPAPINotSupported = errors.New(\"DPAPI not supported on this platform\") //nolint:unused // used on darwin/linux only\n)\n","sourceCodeStart":1,"sourceCodeEnd":16,"githubUrl":"https://github.com/moonD4rk/HackBrowserData/blob/0503d04d7a8d0379d060268a74f1b149e5a0aad5/crypto/errors.go#L1-L16","documentation":"errInvalidBlockSize is returned by cbcDecrypt when the ciphertext length is not a whole multiple of the AES block size (16 bytes). Block ciphers operate on complete blocks, so an input of any other length cannot be valid CBC ciphertext. The error fires early, before decryption and padding validation are attempted.","triggerScenarios":"Calling DecryptChromiumCBC (or any CBC path) with a blob whose length % 16 != 0 — typically incorrect base64 decoding, truncation, or a plaintext (non-encrypted) value passed in.","commonSituations":"Corrupted or partially-read cookie/login rows; whitespace/newlines corrupting base64 decoding; mixing up the encrypted 'value' with the plaintext 'decrypted_value' column from Chromium databases.","solutions":["Check len(ciphertext)%16 == 0 before calling and skip invalid records.","Re-verify base64 decoding (strip whitespace, use StdEncoding vs RawStdEncoding correctly).","Re-copy the browser database; SQLite rows read from a live/locked file can be torn.","Confirm you are passing the encrypted column, not a plaintext value."],"exampleFix":"// before\ndecrypted, err := crypto.DecryptChromiumCBC(key, blob)\n// after\nif len(blob)%aes.BlockSize != 0 {\n    // skip or treat as plaintext\n} else {\n    decrypted, err := crypto.DecryptChromiumCBC(key, blob)\n}","handlingStrategy":"validation","validationCode":"if len(ct)%16 != 0 { return fmt.Errorf(\"ciphertext len %d not block-aligned\", len(ct)) }","typeGuard":"func isBlockAligned(ct []byte, bs int) bool { return len(ct) > 0 && len(ct)%bs == 0 }","tryCatchPattern":"out, err := crypto.DecryptChromiumCBC(key, iv, ct)\nif errors.Is(err, crypto.ErrInvalidBlockSize) {\n    // skip record or re-decode base64\n    return nil\n}","preventionTips":["Assert block alignment before calling any CBC decrypt.","Strip whitespace/newlines before base64 decoding.","Copy databases while the browser is closed to avoid torn reads.","Distinguish encrypted vs plaintext columns (value vs decrypted_value)."],"tags":["crypto","aes-cbc","decryption","chromium"],"backgroundTag":"invalid-argument-value","analyzedSha":"0503d04d7a8d0379d060268a74f1b149e5a0aad5","analyzedAt":"2026-09-06T13:38:28.707Z","contentChangedAt":"2026-09-06T13:38:28.707Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}