Implement comprehensive input validation and HTML sanitization#48
Draft
Implement comprehensive input validation and HTML sanitization#48
Conversation
Co-authored-by: JFenderson <24466206+JFenderson@users.noreply.github.com>
Co-authored-by: JFenderson <24466206+JFenderson@users.noreply.github.com>
Co-authored-by: JFenderson <24466206+JFenderson@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement enhanced input validation and sanitization for APIs
Implement comprehensive input validation and HTML sanitization
Feb 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
API endpoints lacked systematic input validation and sanitization, creating attack vectors for injection exploits. Implemented validation attribute framework and HTML sanitization service to enforce data integrity at DTO level.
Type of Change
Related Issues
N/A
Changes Made
Custom Validation Attributes (
Podium.Application/Validation/)SafeStringAttribute- Detects XSS patterns: HTML tags, javascript:/vbscript:/data: URIs, event handlers (on*=)EmailDomainAttribute- Validates email structure (single @ with content before/after) and optional domain restrictions (.edu)PhoneNumberAttribute- US phone formats (10 digits exactly), optional +1 prefixGPAAttribute- 0.0-4.0 range validation (decimal/double/float)GraduationYearAttribute- Current year to current year + 4InstrumentAttribute- 40+ band instruments (woodwinds, brass, percussion)ValidRoleAttribute- Uses centralizedRolesconstants, case-insensitiveHTML Sanitization
IHtmlSanitizerServiceinterface in CoreHtmlSanitizerServiceimplementation: allows only<b>,<i>,<em>,<strong>,<p>,<br>tags, strips all attributes/event handlers/dangerous schemesDTO Updates
RegisterDto- Email, password, names, phone, role (ValidRole), instrument, graduation year, high schoolLoginDto- Email and password validation with length constraintsChangePasswordDto- Password strength and confirmation matchingUpdateStudentDto- GPA, graduation year, instrument, case-insensitive state codesCreateVideoRequest/UpdateVideoRequest- Title, description, instrument, metadata validationTesting
Testing Checklist
Documentation Checklist
Code Quality Checklist
Breaking Changes
Breaking Changes Description:
None. Validation is additive and enforced at DTO level via DataAnnotations.
Screenshots / Videos
N/A - Backend validation changes only
Deployment Notes
Deployment Instructions:
Standard deployment. No additional configuration required. HtmlSanitizer package restores automatically during build.
Performance Impact
Performance Notes:
Validation executes during model binding (existing framework mechanism). Regex patterns are pre-compiled. HtmlSanitizer uses efficient DOM parsing. Negligible overhead per request.
Security Considerations
Security Notes:
Mitigates:
Dependencies:
Rollback Plan
How to rollback:
Revert commit. Validation attributes are declarative; removing them restores previous behavior. No data migrations or schema changes.
Additional Context
Validation follows fail-fast principle: invalid requests rejected at controller level before business logic executes. Error messages are user-friendly and specify validation failures.
SafeStringAttribute uses comprehensive regex but is defense-in-depth, not silver bullet. User-generated HTML content should still use HtmlSanitizerService for rendering.
Reviewer Notes
Review Checklist (for reviewers)
Note to Reviewers: Please ensure all CI checks pass before approving.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
http://api.nuget.org:443/DigiCertCSRSA4096RootG5.crl/usr/bin/dotnet dotnet build --configuration Release(http block)http://api.nuget.org:443/DigiCertHighAssuranceEVRootCA.crl/usr/bin/dotnet dotnet build --configuration Release(http block)http://api.nuget.org:443/NETFoundationProjectsCodeSigningCA.crl/usr/bin/dotnet dotnet build --configuration Release(http block)http://api.nuget.org:443/NETFoundationProjectsCodeSigningCA2.crl/usr/bin/dotnet dotnet build --configuration Release(http block)http://api.nuget.org:443/sha2-assured-cs-g1.crl/usr/bin/dotnet dotnet build --configuration Release(http block)http://api.nuget.org:443/sha2-assured-ts.crl/usr/bin/dotnet dotnet build --configuration Release(http block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.