{"id":"54f609f9dcd01e72","repo":"actix/actix-web","slug":"invalid-chunk-size-line-invalid-size","errorCode":null,"errorMessage":"Invalid chunk size line: Invalid Size","messagePattern":"Invalid chunk size line: Invalid Size","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"actix-http/src/h1/chunked.rs","lineNumber":65,"sourceCode":"            BodyLf => ChunkedState::read_body_lf(body),\n            EndCr => ChunkedState::read_end_cr(body),\n            EndLf => ChunkedState::read_end_lf(body),\n            End => Poll::Ready(Ok(ChunkedState::End)),\n        }\n    }\n\n    fn read_size(rdr: &mut BytesMut, size: &mut u64) -> Poll<Result<ChunkedState, io::Error>> {\n        let radix = 16;\n\n        let rem = match byte!(rdr) {\n            b @ b'0'..=b'9' => b - b'0',\n            b @ b'a'..=b'f' => b + 10 - b'a',\n            b @ b'A'..=b'F' => b + 10 - b'A',\n            b'\\t' | b' ' => return Poll::Ready(Ok(ChunkedState::SizeLws)),\n            b';' => return Poll::Ready(Ok(ChunkedState::Extension)),\n            b'\\r' => return Poll::Ready(Ok(ChunkedState::SizeLf)),\n            _ => {\n                return Poll::Ready(Err(io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    \"Invalid chunk size line: Invalid Size\",\n                )));\n            }\n        };\n\n        match size.checked_mul(radix) {\n            Some(n) => {\n                *size = n;\n                *size += rem as u64;\n\n                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\",","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/actix/actix-web/blob/937960ca67f20e14ffe2a075bf6d4593502be12c/actix-http/src/h1/chunked.rs#L47-L83","documentation":"io::Error(InvalidInput, \"Invalid chunk size line: Invalid Size\") (chunked.rs:65-68) is returned by ChunkedState::read_size when the first byte of a chunk size field is not a hex digit, whitespace, ';', or CR. It aborts decoding of a Transfer-Encoding: chunked HTTP/1.1 body whose framing is malformed, surfacing as PayloadError::Io to the request/response reader.","triggerScenarios":"A chunked HTTP/1.1 request or response begins a chunk-size line with an illegal character, e.g. 'G\\r\\n' instead of a hex size. The state machine in chunked.rs:54-69 hits the default arm.","commonSituations":"A buggy client/server hand-rolling chunked encoding, a proxy corrupting the stream, or a fuzzer probing the parser. Browsers and curl never produce this.","solutions":["Fix the peer to emit valid hex chunk sizes terminated by CRLF.","If you do not need chunked encoding, send a Content-Length instead.","Capture the raw bytes on the wire to locate the malformed line."],"exampleFix":"// before: non-hex chunk size\nb\"G\\r\\ndata\\r\\n0\\r\\n\\r\\n\"\n\n// after: valid hex size\nb\"4\\r\\ndata\\r\\n0\\r\\n\\r\\n\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// PayloadError surfaces when reading the request/response body.\nuse actix_http::error::PayloadError;\nmatch body.next().await {\n    Some(Err(PayloadError::Io(e))) if e.kind() == io::ErrorKind::InvalidInput => {\n        // malformed chunked framing; reject the request as 400\n        return HttpResponse::BadRequest().finish();\n    }\n    Some(other) => { /* ... */ }\n    None => { /* done */ }\n}","preventionTips":["Use a well-tested HTTP client/server library that emits correct chunked framing.","Prefer Content-Length for fixed-size bodies.","Reject malformed Transfer-Encoding at the edge (reverse proxy)."],"tags":["http","transfer-encoding","chunked","actix-http","protocol"],"analyzedSha":"937960ca67f20e14ffe2a075bf6d4593502be12c","analyzedAt":"2026-08-06T01:15:46.978Z","schemaVersion":2}