ada-dotnet-api-security

Hardens ASP.NET Core APIs with JWT revocation, rate limiting, sanitization, and upload validation.

Updated Jul 23, 2026
One-click install
npx skills add https://github.com/wubing7755/Ada --skill ada-dotnet-api-security-wubing7755
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ada-dotnet-api-security
Source: https://github.com/wubing7755/Ada/tree/main/skills/software-development/ada-dotnet-api-security
Command: npx skills add https://github.com/wubing7755/Ada --skill ada-dotnet-api-security-wubing7755

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? ASP.NET Core backends often ship with exploitable gaps: regex-based HTML sanitizers that are trivially bypassed, JWTs that cannot be revoked, login endpoints without rate limiting, and file uploads vulnerable to polyglot attacks. This Skill provides a verified, attacker-perspective workflow to find and fix these issues in your own codebase. ## Core Features & Use Cases - Threat modeling and security review: Maps trust boundaries, high-value assets, and attacker models, then produces a severity-ranked report (HIGH/MED/MINOR/NIT) with CWE references, attack paths, fixes, and verification steps. - Concrete hardening recipes: Parser-level HTML sanitization with Ganss.Xss HtmlSanitizer, layered media upload validation with ImageSharp re-encoding, JWT jti revocation with algorithm whitelisting, and net8 built-in rate limiting with lazy IOptions reads. - Supply-chain CI gates: NuGet vulnerability JSON gating, SQLitePCLRaw CVE pinning, workflow security contract tests, and no-token gitleaks scanning. - Use Case: You are open-sourcing an ASP.NET Core blog API with comments and image uploads. Use this Skill to audit the codebase, replace the regex sanitizer, add login rate limiting and JWT logout, and gate CI on dependency vulnerabilities. ## Quick Start Ask the agent to perform a security review of your ASP.NET Core API covering authentication, comments, and file uploads, and produce a severity-ranked hardening report.

Frequently Asked Questions about ada-dotnet-api-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I secure an ASP.NET Core API against XSS in markdown comments?

Replace regex blacklists with a parser-level allowlist using Ganss.Xss HtmlSanitizer, which decodes entities and re-serializes from a DOM. Clear AllowedTags, AllowedAttributes, and AllowedSchemes, then keep regression tests for each bypass class like entity-encoded javascript: URLs.

How to add rate limiting to a .NET 8 login endpoint?

Use the built-in AddRateLimiter with a fixed-window policy partitioned by client IP, returning 429 with a Retry-After header. Read limits lazily via IOptions inside the partition delegate so test overrides apply, and ensure the edge proxy overwrites X-Forwarded-For to prevent spoofing.

How do I implement JWT token revocation in ASP.NET Core?

Add a jti claim at token issue, maintain an in-memory revoked-jti store, and reject revoked tokens in JwtBearerEvents.OnTokenValidated. Expose a logout endpoint that revokes the current jti, and whitelist HmacSha256 via ValidAlgorithms to block algorithm confusion.

Why does dotnet list package --vulnerable not fail my CI build?

The command exits 0 even when vulnerabilities exist, so a bare workflow step never fails. Gate CI by running it with --format json and parsing the output to count vulnerability entries, exiting nonzero when any are found.

How do I prevent polyglot file upload attacks in .NET?

Layer validation: extension allowlist excluding SVG, magic-byte checks, real decode with ImageSharp, dimension caps, then re-encode the image to strip trailing non-image bytes. Serve files with X-Content-Type-Options: nosniff so polyglots cannot execute.

Which ImageSharp version works on .NET 8 without a license key?

SixLabors.ImageSharp 4.x enforces a build-time license gate requiring a SixLaborsLicenseKey. Use version 3.1.x instead, which has no gate, the same API, .NET 8 support, and WebP in the default decoder set.