CVE-2015-10079: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (CWE-79)
value: A vulnerability was found in juju2143 WalrusIRC 0.0.2. It has been rated as problematic. This issue affects the function parseLinks of the file public/parser.js. The manipulation of the argument text leads to cross site scripting. The attack may be initiated remotely. Upgrading to version 0.0.3 is able to address this issue. The patch is named 45fd885895ae13e8d9b3a71e89d59768914f60af. It is recommended to upgrade the affected component. The associated identifier of this vulnerability is VDB-220751.
CWE description: The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
CVSS v3 base score: 6.1
Published: 2023-02-13T22:15Z
Repository: https://github.com/juju2143/walrusirc
Language: JavaScript
Files changed: public/parser.js
Commit date: 2015-04-11 17:59:12 +0000
Commit message: Fix JS injection exploit

Diff: diff --git a/public/parser.js b/public/parser.js
index 2a14cd3..1d937b3 100644
--- a/public/parser.js
+++ b/public/parser.js
@@ -12,14 +12,14 @@ function parseLinks(text,nav)
   if (!text || text === null || text === undefined){
     return;
   }
   text = text.replace(/http:\/\/img.codewalr\.us\//g,"\x01img.codewalr.us/");
   text = text.replace(/http:\/\/codewalr\.us\//g,"\x01codewalr.us/");
-  text = text.replace(RegExp("(^|.)(((f|ht)(tp|tps):\/\/)[^\\s\x02\x03\x0f\x16\x1d\x1f]*)","g"),'$1<a target="_blank" href="$2"'+(nav?' class="navbar-link"':'')+'>$2</a>');
-  text = text.replace(RegExp("(^|\\s)(www\\.[^\\s\x02\x03\x0f\x16\x1d\x1f]*)","g"),'$1<a target="_blank" href="http://$2"'+(nav?' class="navbar-link"':'')+'>$2</a>');
-  text = text.replace(RegExp("(^|.)\x01(img.codewalr.us\/[^\\s\x02\x03\x0f\x16\x1d\x1f]*)","g"),'$1<a target="_top" href="http://$2"'+(nav?' class="navbar-link"':'')+'><img src="http://$2" class="picture" /></a>');
-  text = text.replace(RegExp("(^|.)\x01([^\\s\x02\x03\x0f\x16\x1d\x1f]*)","g"),'$1<a target="_top" href="http://$2"'+(nav?' class="navbar-link"':'')+'>http://$2</a>');
+  text = text.replace(RegExp("(^|.)(((f|ht)(tp|tps):\/\/)[^\\s\x02\x03\x0f\x16\x1d\x1f\"]*)","g"),'$1<a target="_blank" href="$2"'+(nav?' class="navbar-link"':'')+'>$2</a>');
+  text = text.replace(RegExp("(^|\\s)(www\\.[^\\s\x02\x03\x0f\x16\x1d\x1f\"]*)","g"),'$1<a target="_blank" href="http://$2"'+(nav?' class="navbar-link"':'')+'>$2</a>');
+  text = text.replace(RegExp("(^|.)\x01(img.codewalr.us\/[^\\s\x02\x03\x0f\x16\x1d\x1f\"]*)","g"),'$1<a target="_top" href="http://$2"'+(nav?' class="navbar-link"':'')+'><img src="http://$2" class="picture" /></a>');
+  text = text.replace(RegExp("(^|.)\x01([^\\s\x02\x03\x0f\x16\x1d\x1f\"]*)","g"),'$1<a target="_top" href="http://$2"'+(nav?' class="navbar-link"':'')+'>http://$2</a>');
   return text;
 }
 
 function parseColors(colorStr)
 {

Vulnerable code:   text = text.replace(RegExp("(^|.)(((f|ht)(tp|tps):\/\/)[^\\s\x02\x03\x0f\x16\x1d\x1f]*)","g"),'$1<a target="_blank" href="$2"'+(nav?' class="navbar-link"':'')+'>$2</a>');
  text = text.replace(RegExp("(^|\\s)(www\\.[^\\s\x02\x03\x0f\x16\x1d\x1f]*)","g"),'$1<a target="_blank" href="http://$2"'+(nav?' class="navbar-link"':'')+'>$2</a>');
  text = text.replace(RegExp("(^|.)\x01(img.codewalr.us\/[^\\s\x02\x03\x0f\x16\x1d\x1f]*)","g"),'$1<a target="_top" href="http://$2"'+(nav?' class="navbar-link"':'')+'><img src="http://$2" class="picture" /></a>');
  text = text.replace(RegExp("(^|.)\x01([^\\s\x02\x03\x0f\x16\x1d\x1f]*)","g"),'$1<a target="_top" href="http://$2"'+(nav?' class="navbar-link"':'')+'>http://$2</a>');
Fixed code:   text = text.replace(RegExp("(^|.)(((f|ht)(tp|tps):\/\/)[^\\s\x02\x03\x0f\x16\x1d\x1f\"]*)","g"),'$1<a target="_blank" href="$2"'+(nav?' class="navbar-link"':'')+'>$2</a>');
  text = text.replace(RegExp("(^|\\s)(www\\.[^\\s\x02\x03\x0f\x16\x1d\x1f\"]*)","g"),'$1<a target="_blank" href="http://$2"'+(nav?' class="navbar-link"':'')+'>$2</a>');
  text = text.replace(RegExp("(^|.)\x01(img.codewalr.us\/[^\\s\x02\x03\x0f\x16\x1d\x1f\"]*)","g"),'$1<a target="_top" href="http://$2"'+(nav?' class="navbar-link"':'')+'><img src="http://$2" class="picture" /></a>');
  text = text.replace(RegExp("(^|.)\x01([^\\s\x02\x03\x0f\x16\x1d\x1f\"]*)","g"),'$1<a target="_top" href="http://$2"'+(nav?' class="navbar-link"':'')+'>http://$2</a>');