XTLS/Xray-core · error

xPaddingBytes cannot be disabled

Error message

xPaddingBytes cannot be disabled

What it means

SplitHTTPConfig.Build() rejects xPaddingBytes settings that disable padding at transport_method.go:334-336. If the range is set (non-zero Int32Range) but either From or To is <= 0, the config is invalid: an explicitly configured padding range must be positive on both ends. Leaving xPaddingBytes entirely unset is allowed (the zero range is skipped).

Source

Thrown at infra/conf/transport_method.go:335

	}

	switch c.Mode {
	case "":
		c.Mode = "auto"
	case "auto", "packet-up", "stream-up", "stream-one":
	default:
		return nil, errors.New("unsupported mode: " + c.Mode)
	}

	// Priority (client): host > serverName > address
	for k := range c.Headers {
		if strings.ToLower(k) == "host" {
			return nil, errors.New(`"headers" can't contain "host"`)
		}
	}

	if c.XPaddingBytes != (Int32Range{}) && (c.XPaddingBytes.From <= 0 || c.XPaddingBytes.To <= 0) {
		return nil, errors.New("xPaddingBytes cannot be disabled")
	}

	if c.XPaddingKey == "" {
		c.XPaddingKey = "x_padding"
	}

	if c.XPaddingHeader == "" {
		c.XPaddingHeader = "X-Padding"
	}

	switch c.XPaddingPlacement {
	case "":
		c.XPaddingPlacement = "queryInHeader"
	case "cookie", "header", "query", "queryInHeader":
	default:
		return nil, errors.New("unsupported padding placement: " + c.XPaddingPlacement)
	}

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Remove the "xPaddingBytes" field to use defaults
  2. Use strictly positive bounds: "xPaddingBytes": {"from": 100, "to": 1000}
  3. Never set from or to to 0 or negative — there is no supported 'disabled' range value

Example fix

// before
"xPaddingBytes": { "from": 0, "to": 0 }
// after
"xPaddingBytes": { "from": 100, "to": 1000 }
Defensive patterns

Strategy: validation

Validate before calling

// Go: padding range must be fully positive if set
if cfg.XPaddingBytes != (Int32Range{}) && (cfg.XPaddingBytes.From <= 0 || cfg.XPaddingBytes.To <= 0) {
	return errors.New("xPaddingBytes needs from>0 and to>0, or omit it")
}

Prevention

When it happens

Trigger: "xPaddingBytes": {"from": 0, "to": 0} or {"from": -1, "to": 500} or {"from": 100, "to": 0} in splithttp transportSettings. Any single non-zero field makes the range non-zero and enters the check.

Common situations: Users trying to turn padding OFF by setting from/to to 0 (padding cannot be disabled this way — omit the field or use xPaddingObfsMode semantics per current docs); typo'd negative values; partial range objects where only one bound was intended.

Related errors


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/f49e9cec55ed0976. Report an issue: GitHub.