• Articles
  • API Documentation
Search Results for

    Show / Hide Table of Contents
    • ImageSharp
      • Getting Started
        • Pixel Formats
        • Image Formats
        • Processing Images
          • Resizing Images
          • Create an animated GIF
        • Working with Pixel Buffers
        • Configuration
        • Memory Management
        • Security Considerations
    • ImageSharp.Drawing
      • Getting Started
    • ImageSharp.Web
      • Getting Started
        • Processing Commands
        • Image Providers
        • Image Caches
    • Fonts
      • Getting Started
      • Custom Rendering

    Security Considerations

    Image processing is a memory-intensive application. Most image processing libraries (including ImageSharp, SkiaSharp, and Magick.NET) decode images into in-memory buffers for further processing. Without additional measures, any publicly facing service that consumes images coming from untrusted sources might be vulnerable to DoS attacks attempting to deplete process memory.

    Such measures can be:

    • Authentication, for example by using HMAC. See Securing Processing Commands in ImageSharp.Web.
    • Offloading to separate services/containers.
    • Placing the solution behind a reverse proxy.
    • Rate Limiting.
    • Imposing conservative allocation limits by configuring a custom MemoryAllocator:
    Configuration.Default.MemoryAllocator = MemoryAllocator.Create(new MemoryAllocatorOptions()
    {
        // Note that this limits the maximum image size to 64 megapixels of Rgba32.
        // Any attempt to create a larger image will throw.
        AllocationLimitMegabytes = 256
    });
    
    • Edit this page
    In this article
    Back to top Generated by DocFX