T09 · Insecure Skill Coding Practices
- Location
schemas/input.schema.json:21- Finding
Unbounded Image Dimensions Permit Resource-Exhaustion Denial of Service
- Content
View full analysis
- Remediation
View remediation
None: if width < 1 or height < 1: raise ValueError("Image dimensions must be positive") if width > MAX_DIMENSION or height > MAX_DIMENSION: raise ValueError("Image dimension exceeds the permitted maximum") if width * height > MAX_PIXELS: raise ValueError("Output image exceeds the permitted pixel count") ``` 3. Calculate final dimensions first and validate them before every `resize()`, crop, canvas creation, or conversion operation. 4. Configure Pillow's decompression-bomb protection and reject source images that exceed an explicit input-pixel policy. 5. Run image processing with operating-system memory, CPU, and execution-time limits so malformed or extreme jobs cannot affect unrelated services. 6. Add tests for zero, negative, extremely large, and overflow-adjacent values, including combinations where individually acceptable dimensions exceed the total-pixel limit. ]]>
