{"id":"2b5cfb3c1e41035d","repo":"hyperium/hyper","slug":"invalid-chunk-size-linear-white-space","errorCode":null,"errorMessage":"Invalid chunk size linear white space","messagePattern":"Invalid chunk size linear white space","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"src/proto/h1/decode.rs","lineNumber":417,"sourceCode":"                return Poll::Ready(Err(io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    \"Invalid chunk size line: Invalid Size\",\n                )));\n            }\n        }\n        Poll::Ready(Ok(ChunkedState::Size))\n    }\n    fn read_size_lws<R: MemRead>(\n        cx: &mut Context<'_>,\n        rdr: &mut R,\n    ) -> Poll<Result<ChunkedState, io::Error>> {\n        trace!(\"read_size_lws\");\n        match byte!(rdr, cx) {\n            // LWS can follow the chunk size, but no more digits can come\n            b'\\t' | b' ' => Poll::Ready(Ok(ChunkedState::SizeLws)),\n            b';' => Poll::Ready(Ok(ChunkedState::Extension)),\n            b'\\r' => Poll::Ready(Ok(ChunkedState::SizeLf)),\n            _ => Poll::Ready(Err(io::Error::new(\n                io::ErrorKind::InvalidInput,\n                \"Invalid chunk size linear white space\",\n            ))),\n        }\n    }\n    fn read_extension<R: MemRead>(\n        cx: &mut Context<'_>,\n        rdr: &mut R,\n        extensions_cnt: &mut u64,\n    ) -> Poll<Result<ChunkedState, io::Error>> {\n        trace!(\"read_extension\");\n        // We don't care about extensions really at all. Just ignore them.\n        // They \"end\" at the next CRLF.\n        //\n        // However, some implementations may not check for the CR, so to save\n        // them from themselves, we reject extensions containing plain LF as\n        // well.\n        match byte!(rdr, cx) {","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/hyperium/hyper/blob/084473f728f9d07b3be5845475aa2f62ed9ff579/src/proto/h1/decode.rs#L399-L435","documentation":"Thrown in the SizeLws state (src/proto/h1/decode.rs:417) after linear whitespace (tab/space) following the chunk size. RFC 7230 allows LWS there, but the next byte must be more LWS, ';' (extension), or '\\r' (end of line). Anything else yields io::ErrorKind::InvalidInput, e.g. a digit or letter appearing where only a terminator is permitted.","triggerScenarios":"A chunk-size line such as \"Ff   X\\r\\n\" or \"a   q\\r\\n\" — a non-LWS, non-terminator byte after the spaces following the hex size. Reading \"1 A\\r\\n\" also lands here once the space transitions to SizeLws.","commonSituations":"A sender that pads the size with spaces and then accidentally appends a comment or second size token; copy-paste of HTTP examples that include explanatory text after the size.","solutions":["Check that nothing follows the size's trailing whitespace except an optional ';ext' and a CRLF.","Strip any annotation/comment the sender writes after the chunk size.","Format sizes with no trailing decoration: \"{:x}\\r\\n\" or \"{:x};ext\\r\\n\"."],"exampleFix":"// before: annotation after padded size\nwrite!(w, \"{:x}   chunk#1\\r\\n\", len).await?; // -> error 22\n\n// after: optional extension only\nwrite!(w, \"{:x};name=val\\r\\n\", len).await?;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Some(Err(e)) => {\n    let kind = e.source()\n        .and_then(|s| s.downcast_ref::<std::io::Error>())\n        .map(|io| io.kind());\n    if matches!(kind, Some(std::io::ErrorKind::InvalidInput)) {\n        tracing::warn!(error=%e, \"bad byte after chunk-size LWS\");\n        break; // drop stream, the framing is unrecoverable\n    }\n    return Err(e.into());\n}","preventionTips":["After the hex size, emit only an optional ';ext' and CRLF — nothing else.","Avoid padding sizes with spaces in generated output; it's legal but fragile.","Re-validate any proxy that rewrites chunk framing."],"tags":["http","http1","chunked","framing","hyper","rust"],"analyzedSha":"084473f728f9d07b3be5845475aa2f62ed9ff579","analyzedAt":"2026-08-06T01:20:18.522Z","schemaVersion":2}