-
Notifications
You must be signed in to change notification settings - Fork 1
🔒 Fix DoS vulnerability in image resizing logic #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…llocation - Introduced `MaxImagePixelHeight` (32000px) constant in `pkg/graphics/processing.go` - Added check in `ResizeImage` to clamp target height to `MaxImagePixelHeight` - Added `pkg/graphics/processing_security_test.go` to verify the fix and prevent regression This prevents an attacker from causing an Out-Of-Memory (OOM) crash by supplying an image with dimensions that result in an excessively large target height during resizing. Co-authored-by: adcondev <38170282+adcondev@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
👋 Thanks for opening this PR, @adcondev! Here's what will happen next:
Please make sure:
|
⚡ Benchmark Results📈 Performance Comparison📊 Click to expand detailed resultsCurrent Branch ResultsBase Branch Results💡 Note: Use 🎯 Summary
|
…llocation - Introduced `MaxImagePixelHeight` (32000px) constant in `pkg/graphics/processing.go` - Added check in `ResizeImage` to clamp target height to `MaxImagePixelHeight` - Added `pkg/graphics/processing_security_test.go` to verify the fix and prevent regression This prevents an attacker from causing an Out-Of-Memory (OOM) crash by supplying an image with dimensions that result in an excessively large target height during resizing. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This PR fixes a potential Denial of Service (DoS) vulnerability in
pkg/graphics/processing.go.The
ResizeImagefunction previously calculated the target height based on the source image's aspect ratio without any upper bound. This allowed an attacker to provide an image with dimensions (e.g., extremely large height, small width) that would result in a massivetargetH, causingimage.NewRGBAto attempt allocating gigabytes of memory, leading to an OOM crash.Changes:
const MaxImagePixelHeight = 32000(approx 4 meters at 203 DPI) as a safety limit.ResizeImageto clamp the calculatedtargetHtoMaxImagePixelHeight.pkg/graphics/processing_security_test.gothat attempts to trigger the excessive allocation and verifies that the height is correctly capped.PR created automatically by Jules for task 10886718502609095160 started by @adcondev