Skip to content
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

XSS injection in webssh hostname field #374

Open
adb014 opened this issue Jan 26, 2024 · 2 comments
Open

XSS injection in webssh hostname field #374

adb014 opened this issue Jan 26, 2024 · 2 comments

Comments

@adb014
Copy link

adb014 commented Jan 26, 2024

There is a XSS injection attack possible against the hostname field of webssh. For example if webssh is port 443 of the local machine

https://localhost/?hostname=%3Cscript%3Ealert(%221%22)%3C/script%3E

will demonstrate the existence of the attack.

@adb014
Copy link
Author

adb014 commented Mar 11, 2024

The patch

--- static/js/main.js.orig      2024-03-11 17:12:37.270301908 +0000
+++ static/js/main.js   2024-03-11 18:31:04.497099056 +0000
@@ -325,7 +325,7 @@
 
   function log_status(text, to_populate) {
     console.log(text);
-    status.html(text.split('\n').join('<br/>'));
+    status.html(text.replace(/&/, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;').split('\n').join('</br>'));
 
     if (to_populate && validated_form_data) {
       populate_form(validated_form_data);

will fix the problem. Can't use "status.text" to replace "status.html" as we're adding "</br>"'s to the text

@abcbarryn
Copy link

When will this patch be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants