fix(sqli): use prepared statements to prevent SQL injection (CWE-89) - #268
Open
markuszaki wants to merge 1 commit into
Open
markuszaki wants to merge 1 commit into
markuszaki wants to merge 1 commit into
Conversation
OWASP Top 10: A03:2021 - Injection Affected: SQL Injection (Low/Medium/High) Changes: - Replace mysqli_query() with mysqli_prepare() + mysqli_stmt_bind_param() - Use mysqli_stmt_get_result() for fetching - Add htmlspecialchars() on all output (XSS prevention) - Generic error messages (no SQL leakage) - Proper resource cleanup with mysqli_stmt_close() Files: - vulnerabilities/sqli/source/low.php (+20 -14) - vulnerabilities/sqli/source/medium.php (+20 -12) - vulnerabilities/sqli/source/high.php (+20 -12) Security Pattern: Prepared statements with type-safe parameter binding
🏆 DVWA — CTF Patch Score3 / 55 challenges patched
Commit: 🎉 Your result is on the leaderboard — see where you rank! 🏆 |
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.
SQL Injection Fix
Vulnerability: CWE-89 - SQL Injection
OWASP Top 10: A03:2021 - Injection
Challenges Fixed: 3 (Low, Medium, High)
Issue
User input was concatenated directly into SQL queries, allowing SQL injection attacks.
Fix
All three security levels now use:
Files Changed
Total: 3 files, +44 −20 lines
Testing
✓ Valid queries return correct results
✓ SQL injection payloads neutralized
✓ No error-based information leakage
✓ php -l clean on all files
Security Pattern: Prepared statements for ALL database queries
Verification: Ad-hoc script validated all patterns ✓