-
Notifications
You must be signed in to change notification settings - Fork 0
Fix typos in index.html #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | |||||||||||||||||||||||||||||||||
| <!doctype html> | |||||||||||||||||||||||||||||||||
| <html> | |||||||||||||||||||||||||||||||||
| <head> | |||||||||||||||||||||||||||||||||
| <meta charset="utf-8" /> | |||||||||||||||||||||||||||||||||
| <title>Vulnerable XSS Test Page (Local test)</title> | |||||||||||||||||||||||||||||||||
| </head> | |||||||||||||||||||||||||||||||||
| <body> | |||||||||||||||||||||||||||||||||
| <h1>Vulnerable Testt</h1> | |||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||
| <h1>Vulnerable Testt</h1> | |
| <h1>Vulnerable Test</h1> |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is vulnerable to XSS attacks as it directly inserts user input into innerHTML without sanitization. For a test page demonstrating vulnerabilities, this is intentional, but consider adding a comment explaining this is the vulnerable behavior being demonstrated.
| const q = document.getElementById('input').value; | |
| const q = document.getElementById('input').value; | |
| // WARNING: This is intentionally vulnerable code for XSS demonstration purposes. | |
| // Do NOT use this pattern in production. Always sanitize user input before inserting into innerHTML. |
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
DOM text
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To prevent DOM-based XSS, you should never assign untrusted user input directly to innerHTML. Instead, use a method that treats the input as plain text. In the case of this example, replacing innerHTML with either textContent or ensuring output is properly escaped before assignment is safest.
The best way to fix this specific issue:
- Change line 23 from
document.getElementById('out').innerHTML = q;todocument.getElementById('out').textContent = q;.
This change ensures that any characters in q with HTML significance (such as <, >, &) will be rendered as text, not interpreted as markup or script.
No new imports or library dependencies are required for this fix.
-
Copy modified line R23
| @@ -20,7 +20,7 @@ | ||
| form.addEventListener('submit', (ev) => { | ||
| ev.preventDefault(); | ||
| const q = document.getElementById('input').value; | ||
| document.getElementById('out').innerHTML = q; | ||
| document.getElementById('out').textContent = q; | ||
| }); | ||
| </script> | ||
| </body> |
Copilot
AI
Jan 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is vulnerable to Cross-Site Scripting (XSS) attacks. User input is directly inserted into the DOM via innerHTML without any sanitization. An attacker could inject malicious scripts by entering HTML/JavaScript code. Use textContent instead of innerHTML, or implement proper input sanitization if HTML content is genuinely needed.
| document.getElementById('out').innerHTML = q; | |
| document.getElementById('out').textContent = q; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo in the heading text. 'Testt' should be 'Test'.