{"id":"792c57f9a91e4e3a","repo":"actix/actix-web","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":"io::Error","httpStatus":null,"severity":"error","filePath":"actix-http/src/h1/chunked.rs","lineNumber":95,"sourceCode":"                Poll::Ready(Ok(ChunkedState::Size))\n            }\n            None => {\n                debug!(\"chunk size would overflow u64\");\n                Poll::Ready(Err(io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    \"Invalid chunk size line: Size is too big\",\n                )))\n            }\n        }\n    }\n\n    fn read_size_lws(rdr: &mut BytesMut) -> Poll<Result<ChunkedState, io::Error>> {\n        match byte!(rdr) {\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(rdr: &mut BytesMut) -> Poll<Result<ChunkedState, io::Error>> {\n        match byte!(rdr) {\n            b'\\r' => Poll::Ready(Ok(ChunkedState::SizeLf)),\n            // strictly 0x20 (space) should be disallowed but we don't parse quoted strings here\n            0x00..=0x08 | 0x0a..=0x1f | 0x7f => Poll::Ready(Err(io::Error::new(\n                io::ErrorKind::InvalidInput,\n                \"Invalid character in chunk extension\",\n            ))),\n            _ => Poll::Ready(Ok(ChunkedState::Extension)), // no supported extensions\n        }\n    }\n    fn read_size_lf(rdr: &mut BytesMut, size: u64) -> Poll<Result<ChunkedState, io::Error>> {\n        match byte!(rdr) {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/actix/actix-web/blob/937960ca67f20e14ffe2a075bf6d4593502be12c/actix-http/src/h1/chunked.rs#L77-L113","documentation":"io::Error(InvalidInput, \"Invalid chunk size linear white space\") (chunked.rs:95-98) is returned by ChunkedState::read_size_lws when, after the chunk size and its optional linear whitespace, a character other than ';', CR, or more LWS appears. RFC 7230 allows only LWS, an extension delimiter ';', or CRLF after the size token.","triggerScenarios":"A chunked body has a size line like '4 X\\r\\n' — a stray non-LWS character after the hex size. read_size transitions to SizeLws on a space, then read_size_lws sees 'X' and errors.","commonSituations":"Hand-rolled chunk encoder inserting extra tokens, or a proxy injecting garbage after the size.","solutions":["Ensure the chunk size line is exactly '<hex> [;ext] CRLF'.","Prefer Content-Length when the body size is known.","Inspect the raw stream to find the stray character."],"exampleFix":"// before\nb\"4 X\\r\\ndata\\r\\n0\\r\\n\\r\\n\"\n\n// after\nb\"4\\r\\ndata\\r\\n0\\r\\n\\r\\n\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Same InvalidInput PayloadError handling as other chunked framing errors.\nuse actix_http::error::PayloadError;\nif let Some(Err(PayloadError::Io(e))) = payload.next().await {\n    if e.kind() == io::ErrorKind::InvalidInput {\n        return HttpResponse::BadRequest().finish();\n    }\n}","preventionTips":["Ensure chunk size lines are strictly '<hex> [;ext] CRLF'.","Avoid hand-rolling chunked encoding; use a vetted library.","Validate Transfer-Encoding at a reverse proxy."],"tags":["http","transfer-encoding","chunked","actix-http","protocol"],"analyzedSha":"937960ca67f20e14ffe2a075bf6d4593502be12c","analyzedAt":"2026-08-06T01:15:46.978Z","schemaVersion":2}