Menu

JPEG header, PHP payload: why I built UploadGuard for ASP.NET Core uploads
📰

JPEG header, PHP payload: why I built UploadGuard for ASP.NET Core uploads

DEV Community: dotnet·Grant Totinov, M. Eng.·about 15 hours ago
#zurMGbPz
#devtodotnet#devto#dev#xx#file
Reading 0:00
15s threshold

Most ASP.NET Core apps accept files from users somewhere: avatars, CVs, CSV imports. The validation is usually a few lines. Compare the extension with a list, maybe read the first bytes with a signature library, and save the file. The OWASP File Upload Cheat Sheet is blunt about signature checks: "This should not be used on its own, as bypassing it is pretty common and easy."

A JPEG header followed by <?php , a Word document with a VBA project inside, and a ZIP that unpacks to a hundred times its size all start with the right magic bytes. I wanted one place that does the rest of the work, so I built UploadGuard . It's MIT licensed, it targets .NET 10, and the first preview went up on NuGet on 7 November 2026. This post is about what it checks, in what order, and the parts I deliberately left out.

One policy per kind of upload

You describe each kind of upload once, as a named allow-list with limits:

builder . Services . AddUploadGuard ( o => { o . StoragePath = "/var/app/uploads" ; o .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.