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 .…