File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -2505,17 +2505,24 @@ func parseChunkSize(r *bufio.Reader) (int, error) {
2505
2505
c , err := r .ReadByte ()
2506
2506
if err != nil {
2507
2507
return - 1 , ErrBrokenChunk {
2508
- error : fmt .Errorf ("cannot read '\r ' char at the end of chunk size: %w" , err ),
2508
+ error : fmt .Errorf ("cannot read '\\ r' char at the end of chunk size: %w" , err ),
2509
2509
}
2510
2510
}
2511
2511
// Skip chunk extension after chunk size.
2512
2512
// Add support later if anyone needs it.
2513
2513
if c != '\r' {
2514
+ // Security: Don't allow newlines in chunk extensions.
2515
+ // This can lead to request smuggling issues with some reverse proxies.
2516
+ if c == '\n' {
2517
+ return - 1 , ErrBrokenChunk {
2518
+ error : errors .New ("invalid character '\\ n' after chunk size" ),
2519
+ }
2520
+ }
2514
2521
continue
2515
2522
}
2516
2523
if err := r .UnreadByte (); err != nil {
2517
2524
return - 1 , ErrBrokenChunk {
2518
- error : fmt .Errorf ("cannot unread '\r ' char at the end of chunk size: %w" , err ),
2525
+ error : fmt .Errorf ("cannot unread '\\ r' char at the end of chunk size: %w" , err ),
2519
2526
}
2520
2527
}
2521
2528
break
You can’t perform that action at this time.
0 commit comments