fix(xss): encode all output with htmlspecialchars() to prevent XSS (C… - #271
Open
markuszaki wants to merge 1 commit into
Open
markuszaki wants to merge 1 commit into
markuszaki wants to merge 1 commit into
Conversation
…WE-79)
Fix all 9 XSS challenges across Reflected, Stored, and DOM-based XSS:
Reflected XSS (xss_r):
- low.php: Replace direct output with htmlspecialchars(ENT_QUOTES, 'UTF-8')
- medium.php: Replace str_replace('<script>') with proper output encoding
- high.php: Replace regex filtering with htmlspecialchars()
Stored XSS (xss_s):
- low.php: Add htmlspecialchars() to message and name fields
- medium.php: Replace strip_tags/str_replace with htmlspecialchars()
- high.php: Replace preg_replace regex with htmlspecialchars()
DOM-based XSS (xss_d):
- low.php: Add comment documenting proper fix approach
- medium.php: Replace stripos script detection with htmlspecialchars()
- high.php: Add htmlspecialchars() alongside whitelist validation
- index.php: Replace document.write() with safe DOM manipulation using
createElement and textContent to prevent DOM XSS injection
Pattern: htmlspecialchars(ENT_QUOTES, 'UTF-8') on ALL user-controlled output
CWE: CWE-79 (Cross-site Scripting)
OWASP: A03:2021 - Injection
🏆 DVWA — CTF Patch Score6 / 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.
…WE-79)
Fix all 9 XSS challenges across Reflected, Stored, and DOM-based XSS:
Reflected XSS (xss_r):
Stored XSS (xss_s):
DOM-based XSS (xss_d):
Pattern: htmlspecialchars(ENT_QUOTES, 'UTF-8') on ALL user-controlled output
CWE: CWE-79 (Cross-site Scripting)
OWASP: A03:2021 - Injection