XTLS/Xray-core · error
read padding body
Error message
read padding body: %w
What it means
readPaddingTurn wraps an io.ReadFull failure while draining the remaining padding body bytes after the header. The peer closed the connection or the stream was truncated mid-record, so the padding cannot be fully consumed.
Solutions
- Close the connection on truncated padding bodies
- Retrying is unsafe mid-stream; renegotiate the session instead
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at transport/internet/finalmask/xmc/padding.go:247 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/a1f712b587aeb99f.
Report an issue: GitHub.
Appendix: source
Thrown at transport/internet/finalmask/xmc/padding.go:247
}
recordLength := int(encodedLength)
if recordLength < headerLength || recordLength > maxPaddingTurnLength {
return fmt.Errorf("invalid padding record length: %d", recordLength)
}
totalLength := prefixLength + recordLength
if !paddingTurnAcceptsLength(turn, totalLength) {
if len(turn.variants) > 0 {
return fmt.Errorf("padding turn length %d is not an allowed variant", totalLength)
}
return fmt.Errorf("padding turn length %d is outside %d-%d", totalLength, turn.minLength, turn.maxLength)
}
var buffer [paddingBufferLength]byte
remaining := recordLength - headerLength
for remaining > 0 {
chunkLength := min(remaining, len(buffer))
if _, err := io.ReadFull(r, buffer[:chunkLength]); err != nil {
return fmt.Errorf("read padding body: %w", err)
}
remaining -= chunkLength
}
return nil
}
func selectPaddingVariant(turn paddingTurn, prefixLength int) (int, []int, []paddingDelayRange, error) {
if len(turn.variants) == 0 {
minimum, maximum := turn.minLength, turn.maxLength
if turn.sendMinLength != 0 || turn.sendMaxLength != 0 {
minimum, maximum = turn.sendMinLength, turn.sendMaxLength
}
targetLength, err := randomPaddingTarget(minimum, maximum)
return targetLength, nil, nil, err
}
indices := turn.sendVariants
if len(indices) == 0 {View on GitHub (pinned to 7d214f8b09)