Implement max input dimensions and path traversal validation

- Reject input images exceeding MaxInputDimension (8192px) to prevent DoS
- Detect path traversal: ../, encoded variants, backslashes, null bytes
This commit is contained in:
2026-01-08 08:50:18 -08:00
parent c964feac7e
commit 95408e68d4
2 changed files with 69 additions and 0 deletions

View File

@@ -53,6 +53,11 @@ func (p *ImageProcessor) Process(
origWidth := bounds.Dx()
origHeight := bounds.Dy()
// Validate input dimensions to prevent DoS via decompression bombs
if origWidth > MaxInputDimension || origHeight > MaxInputDimension {
return nil, ErrInputTooLarge
}
// Determine target dimensions
targetWidth := req.Size.Width
targetHeight := req.Size.Height