{"record":{"id":"f49e9cec55ed0976","repo":"XTLS/Xray-core","slug":"xpaddingbytes-cannot-be-disabled","errorCode":null,"errorMessage":"xPaddingBytes cannot be disabled","messagePattern":"xPaddingBytes cannot be disabled","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"infra/conf/transport_method.go","lineNumber":335,"sourceCode":"\t}\n\n\tswitch c.Mode {\n\tcase \"\":\n\t\tc.Mode = \"auto\"\n\tcase \"auto\", \"packet-up\", \"stream-up\", \"stream-one\":\n\tdefault:\n\t\treturn nil, errors.New(\"unsupported mode: \" + c.Mode)\n\t}\n\n\t// Priority (client): host > serverName > address\n\tfor k := range c.Headers {\n\t\tif strings.ToLower(k) == \"host\" {\n\t\t\treturn nil, errors.New(`\"headers\" can't contain \"host\"`)\n\t\t}\n\t}\n\n\tif c.XPaddingBytes != (Int32Range{}) && (c.XPaddingBytes.From <= 0 || c.XPaddingBytes.To <= 0) {\n\t\treturn nil, errors.New(\"xPaddingBytes cannot be disabled\")\n\t}\n\n\tif c.XPaddingKey == \"\" {\n\t\tc.XPaddingKey = \"x_padding\"\n\t}\n\n\tif c.XPaddingHeader == \"\" {\n\t\tc.XPaddingHeader = \"X-Padding\"\n\t}\n\n\tswitch c.XPaddingPlacement {\n\tcase \"\":\n\t\tc.XPaddingPlacement = \"queryInHeader\"\n\tcase \"cookie\", \"header\", \"query\", \"queryInHeader\":\n\tdefault:\n\t\treturn nil, errors.New(\"unsupported padding placement: \" + c.XPaddingPlacement)\n\t}\n","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/infra/conf/transport_method.go#L317-L353","documentation":"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).","triggerScenarios":"\"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.","commonSituations":"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.","solutions":["Remove the \"xPaddingBytes\" field to use defaults","Use strictly positive bounds: \"xPaddingBytes\": {\"from\": 100, \"to\": 1000}","Never set from or to to 0 or negative — there is no supported 'disabled' range value"],"exampleFix":"// before\n\"xPaddingBytes\": { \"from\": 0, \"to\": 0 }\n// after\n\"xPaddingBytes\": { \"from\": 100, \"to\": 1000 }","handlingStrategy":"validation","validationCode":"// Go: padding range must be fully positive if set\nif cfg.XPaddingBytes != (Int32Range{}) && (cfg.XPaddingBytes.From <= 0 || cfg.XPaddingBytes.To <= 0) {\n\treturn errors.New(\"xPaddingBytes needs from>0 and to>0, or omit it\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not use 0/0 to disable padding — omit the field instead","Both bounds must be strictly positive"],"tags":["config","splithttp","padding","validation"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}