OWASP A06:2025 – Remove destructive endpoint, enforce input constraints, fix SQL injection#43
Draft
OWASP A06:2025 – Remove destructive endpoint, enforce input constraints, fix SQL injection#43
Conversation
…ling documentation
…ve error handling documentation
- Added global exception handling middleware to improve error management and response consistency. - Refactored repository methods to use `FirstOrDefaultAsync` and handle null returns appropriately. - Enhanced endpoint methods to validate input and return proper HTTP status codes. - Fixed SQL injection vulnerabilities by replacing raw SQL queries with parameterized LINQ queries. - Added comprehensive input validation using FluentValidation. - Created integration tests for mythology endpoints to ensure correct behavior and responses. - Updated unit tests for god and mythology endpoints to use NSubstitute for mocking dependencies.
…t validation and safe deletion Co-authored-by: aatmmr <15815012+aatmmr@users.noreply.github.com> Agent-Logs-Url: https://github.com/SolidifyDemo/mythapi-training-demo/sessions/1a20643c-86a6-4e4e-9d03-bcfc71dd1573
Copilot
AI
changed the title
[WIP] Start work on issue 35
OWASP A06:2025 – Remove destructive endpoint, enforce input constraints, fix SQL injection
Mar 25, 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.
The API exposed an unauthenticated
DELETE /api/v1/gods(delete-all) endpoint, accepted unbounded bulk inputs, had no model-level validation, and used raw SQL string interpolation in name searches — a combination of insecure-by-design flaws per OWASP A06:2025.Endpoint changes
DELETE /api/v1/gods(unprotected delete-all)DELETE /api/v1/gods/{id}— targeted deletion onlyGetGodByIdandSearchGodsByNamefrom anonymous lambdas into named static methods with validationInput validation
AddOrUpdateGods: rejects empty lists and batches > 100 items →400 BadRequestGetGodById: rejectsid ≤ 0→400 BadRequest; missing god →404 NotFoundSearchGodsByName: rejects empty/whitespace names →400 BadRequestModel constraints (
GodInput)SQL injection fix
Replaced
FromSqlRawwith string interpolation inGetGodByNameAsyncwith parameterizedEF.Functions.Like()LINQ queries — including alias search path.Repository interface
GetGodAsyncnow returnsGod?+FirstOrDefaultAsync(was throwing on missing records)DeleteAllGodsAsyncremoved;DeleteGodByIdAsync(GodParameter)addedOriginal prompt
Created from VS Code.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.