{"record":{"id":"b358040005a12c97","repo":"moonD4rk/HackBrowserData","slug":"ciphertext-too-short","errorCode":null,"errorMessage":"ciphertext too short","messagePattern":"ciphertext too short","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crypto/errors.go","lineNumber":7,"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":"errShortCiphertext means the input to a Chromium decryption routine (GCM or CBC) is smaller than the minimum structure of a version-prefixed encrypted blob: the 'v10'/'v20' 3-byte version prefix plus at least a GCM nonce (12B) or an AES-CBC block (16B). The library throws it before attempting decryption because such a blob cannot possibly be valid. It is a sentinel error returned from DecryptChromiumGCM, DecryptChromiumCBC, and AESGCMDecryptBlob.","triggerScenarios":"Calling DecryptChromiumGCM with len(ciphertext) < versionPrefixLen+gcmNonceSize, or DecryptChromiumCBC/AESGCMDecryptBlob with len(ciphertext) < versionPrefixLen+aes.BlockSize. Typical cause: passing a raw base64-decoded value that was never encrypted (e.g. plaintext cookies or empty strings stored in the DB), or a truncated blob.","commonSituations":"Extracting cookies where Chromium stored unencrypted values in the 'value' column (older cookies with no v10 prefix); reading rows from an incomplete SQLite export; mis-decoded base64; pointing the tool at a corrupted database file.","solutions":["Check that the ciphertext actually begins with a version prefix ('v10' or 'v20') before calling decryption and skip plaintext rows.","Verify the base64 decoding produced non-trivial bytes: log len(ciphertext) when the error occurs.","Skip the record and continue extraction instead of failing the whole run; treat it as a plaintext/unencrypted value.","Ensure the source database (Cookies/Login Data) was fully copied before reading; re-copy the DB if it may have been truncated."],"exampleFix":"// before\ndecrypted, err := crypto.DecryptChromiumGCM(key, encValue)\nif err != nil {\n    return err\n}\n// after\ndecrypted, err := crypto.DecryptChromiumGCM(key, encValue)\nif errors.Is(err, errShortCiphertext) || len(encValue) < 4 {\n    return string(encValue), nil // treat as plaintext\n}\nif err != nil {\n    return err\n}","handlingStrategy":"validation","validationCode":"func hasValidChromiumPrefix(ct []byte) bool {\n    return len(ct) >= 3+12 && (bytes.HasPrefix(ct, []byte(\"v10\")) || bytes.HasPrefix(ct, []byte(\"v20\")))\n}\nif !hasValidChromiumPrefix(encValue) { /* treat as plaintext / skip */ }","typeGuard":"func isEncryptedBlob(b []byte) bool { return len(b) >= versionPrefixLen+gcmNonceSize }","tryCatchPattern":"dec, err := crypto.DecryptChromiumGCM(key, ct)\nif errors.Is(err, crypto.ErrShortCiphertext) {\n    dec = ct // plaintext fallback\n} else if err != nil {\n    return err\n}","preventionTips":["Check for the 'v10'/'v20' prefix before decrypting; values without it are usually plaintext.","Log ciphertext length on failure to spot truncation early.","Always copy SQLite databases before reading them.","Never assume a decoded base64 field is encrypted — verify structure first."],"tags":["crypto","aes-gcm","chromium","decryption"],"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-14T00:17:10.932Z"}