We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1122
    • 209 Posts
    Recently I discovered that MODx site might be led to crash by requesting pages comprising a call of Jot snippet. Malicious scripts add to the query string something like "?somevariable[]=somevalue". Jot analyzes this extended string and crashes while executing urlencode() function on url’s component being an array instead of expected string. Below is a Jot’s function preserveUrl() with weak piece of code patched:
    	function preserveUrl($docid = '', $alias = '', $array_values = array(), $suffix = false) {
    		global $modx;
    		$array_get = $_GET;
    		$urlstring = array();
    		
    		unset($array_get["id"]);
    		unset($array_get["q"]);
    		
    		$array_url = array_merge($array_get, $array_values);
    		foreach ($array_url as $name => $value) {
    			if (!is_null($value)) {
    			  #### WEAK PIECE OF CODE ####
    			  ####$urlstring[] = $name . '=' . urlencode($value);
    			  $urlstring[] = $name . '=' . urlencode((is_array($value) ? implode('', $value) : $value));
    			  ####
    			}
    		}
    		
    		$url = join('&',$urlstring);
    		if ($suffix) {
    			if (empty($url)) { $url = "?"; }
    			 else { $url .= "&"; }
    		}
    
    		return $modx->makeUrl($docid, $alias, $url);
    	}
    

    On my site (http://setpro.net.pl/software/modx-stuff) I am providing code of entire Jot classes with above correction applied - ver. 1.1.2, 1.1.3, and 1.1.4. Code on my site also includes another patch that is described in the article.
      • 22303 MODX Staff
      • 10,725 Posts
      I’ll agree this looks like a bug, but definitely not a security vulnerability.
        • 1122
        • 209 Posts
        I do not claim that it poses any threat to site’s security, but it looks far from it how we would like: "MODx Parse error, etc., etc..."
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: Alik at Dec 22, 2008, 04:40 PM

          I do not claim that it poses any threat to site’s security, but it looks far from it how we would like: "MODx Parse error, etc., etc..."
          But your subject is "Vulnerability in Jot 1.1.4", which implies you are identifying an attack vector for a security vulnerability. It’s one way to get attention on your thread, but in a time when security matters more and more each day, it is misleading to the community. How about "Parse error in Jot 1.1.4" or "Bug in Jot 1.1.4"?
            • 1122
            • 209 Posts
            You are right -- corrected; attracting an extensive attention to the thread is not my motive.