Skip to content

Commit db74567

Browse files
Merge pull request #67 from SixLabors/af/security
Security Considerations
2 parents 396bdc3 + 03ece61 commit db74567

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

articles/imagesharp/security.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Security Considerations
2+
3+
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.
4+
5+
Such measures can be:
6+
- Authentication, for example by using HMAC. See [Securing Processing Commands in ImageSharp.Web](../imagesharp.web/processingcommands.md#securing-processing-commands).
7+
- Offloading to separate services/containers.
8+
- Placing the solution behind a reverse proxy.
9+
- Rate Limiting.
10+
- Imposing conservative allocation limits by configuring a custom `MemoryAllocator`:
11+
12+
```csharp
13+
Configuration.Default.MemoryAllocator = MemoryAllocator.Create(new MemoryAllocatorOptions()
14+
{
15+
// Note that this limits the maximum image size to 64 megapixels of Rgba32.
16+
// Any attempt to create a larger image will throw.
17+
AllocationLimitMegabytes = 256
18+
});
19+
```

articles/toc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
### [Working with Pixel Buffers](imagesharp/pixelbuffers.md)
99
### [Configuration](imagesharp/configuration.md)
1010
### [Memory Management](imagesharp/memorymanagement.md)
11+
### [Security Considerations](imagesharp/security.md)
1112

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

0 commit comments

Comments
 (0)