Skip to content

Commit

Permalink
add paragraph: Security Considerations
Browse files Browse the repository at this point in the history
  • Loading branch information
antonfirsov committed Apr 10, 2024
1 parent c84baa2 commit 6eb15bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions articles/imagesharp/security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Security Considerations

Image processing is a memory-intensive application. Most image processing libraries (including ImageSharp and SkiaSharp) decode images into in-memory buffers. Any publicly facing service using such a library might be vulnerable to DoS attacks without implementing further measures.

For solutions using ImageSharp such measures can be:
- Authentication, for example by using HMAC. See [Securing Processing Commands in ImageSharp.Web](../imagesharp.web/processingcommands.md#securing-processing-commands).
- Offloading to separate services/containers.
- Placing the solution behind a reverse proxy.
- Rate Limiting.
- Imposing conservative allocation limits by configuring a custom `MemoryAllocator`:

```csharp
Configuration.Default.MemoryAllocator = MemoryAllocator.Create(new MemoryAllocatorOptions()
{
// Note that this limits the maximum image size to 64 megapixels.
// Any attempt to create a larger image will throw.
AllocationLimitMegabytes = 256
});
```
1 change: 1 addition & 0 deletions articles/toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
### [Working with Pixel Buffers](imagesharp/pixelbuffers.md)
### [Configuration](imagesharp/configuration.md)
### [Memory Management](imagesharp/memorymanagement.md)
### [Security Considerations](imagesharp/security.md)

# [ImageSharp.Drawing](imagesharp.drawing/index.md)
## [Getting Started](imagesharp.drawing/gettingstarted.md)
Expand Down

0 comments on commit 6eb15bd

Please sign in to comment.