{"record":{"id":"10067f3c83160f71","repo":"ginuerzh/gost","slug":"ciphertext-too-short","errorCode":null,"errorMessage":"ciphertext too short","messagePattern":"ciphertext too short","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quic.go","lineNumber":333,"sourceCode":"\t}\n\n\treturn gcm.Seal(nonce, nonce, data, nil), nil\n}\n\nfunc (conn *quicCipherConn) decrypt(data []byte) ([]byte, error) {\n\tc, err := aes.NewCipher(conn.key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tgcm, err := cipher.NewGCM(c)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tnonceSize := gcm.NonceSize()\n\tif len(data) < nonceSize {\n\t\treturn nil, errors.New(\"ciphertext too short\")\n\t}\n\n\tnonce, ciphertext := data[:nonceSize], data[nonceSize:]\n\treturn gcm.Open(nil, nonce, ciphertext, nil)\n}\n\nfunc tlsConfigQUICALPN(tlsConfig *tls.Config) *tls.Config {\n\tif tlsConfig == nil {\n\t\tpanic(\"quic: tlsconfig is nil\")\n\t}\n\ttlsConfigQUIC := tlsConfig.Clone()\n\ttlsConfigQUIC.NextProtos = []string{\"http/3\", \"quic/v1\"}\n\treturn tlsConfigQUIC\n}\n","sourceCodeStart":315,"sourceCodeEnd":348,"githubUrl":"https://github.com/ginuerzh/gost/blob/a33fdbf4c98034f4bfeeaea9868909822b9c526d/quic.go#L315-L348","documentation":"decrypt for QUIC packets requires the ciphertext blob to carry at least a GCM nonce prefix; if the received datagram is shorter than gcm.NonceSize(), there is no room for the nonce and authentication cannot proceed, so it fails early with this error.","triggerScenarios":"ReadFrom receives a UDP datagram whose payload length is less than the AES-GCM nonce size after the packet is routed to decrypt — i.e. a truncated, empty, or non-encrypted packet.","commonSituations":"Random internet UDP noise/scanning hitting the QUIC port, an MTU/truncation issue, or a peer not using the expected encryption.","solutions":["Verify the peer is actually the expected QUIC service using the same key/encryption scheme","Check network path for datagram truncation (MTU, buggy NAT, fragmentation)","Log and drop the offending datagram; a single bad packet doesn't require reconnecting","Confirm both sides use the same cipher configuration (nonce size)"],"exampleFix":"// before\nn, addr, err := conn.ReadFrom(buf) // assume all data is decryptable\n// after\nn, addr, err := conn.ReadFrom(buf)\nif err != nil { continue }\nif n < gcmStandardNonceSize { continue } // drop too-short packets before decrypt","handlingStrategy":"validation","validationCode":"if n < gcmStandardNonceSize {\n    continue // drop too-short datagram before decrypting\n}","typeGuard":null,"tryCatchPattern":"data, err := decrypt(buf[:n])\nif err != nil {\n    log.Log(\"dropping undecryptable packet:\", err)\n    continue\n}","preventionTips":["Verify peer encryption config matches (same key/cipher)","Firewall the QUIC port from random internet UDP noise","Monitor truncation (MTU/NAT) on the network path"],"tags":["quic","encryption","aes-gcm","udp"],"backgroundTag":"ciphertext-too-short","analyzedSha":"a33fdbf4c98034f4bfeeaea9868909822b9c526d","analyzedAt":"2026-09-02T22:15:54.506Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}