CVE-2014-125068 (published 2023-01-08T11:15Z)

A vulnerability was found in saxman maps-js-icoads and classified as critical. This issue affects some unknown processing of the file http-server.js. The manipulation leads to path traversal. The patch is named 34b8b0cce2807b119f4cffda2ac48fc8f427d69a. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-217643.

CVSS v3 base score: 5.3, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N)

Weakness information:
cwe_id: CWE-22
cwe_name: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
description: The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
extended_description: 
            Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin" to access unexpected files. This is referred to as absolute path traversal.
         
         

Fix information:
repo_url: https://github.com/saxman/maps-js-icoads
commit_details: repo_url: https://github.com/saxman/maps-js-icoads
author: saxman
author_date: 2014-09-02 13:07:09-07:00
msg: Return index.html for directory req's and prevent directory traversal req's
repository: repo_url: https://github.com/saxman/maps-js-icoads
repo_name: saxman/maps-js-icoads
repo_language: JavaScript
owner: saxman
file_changes: filename: http-server.js
change_type: ModificationType.MODIFY
diff: @@ -1,5 +1,6 @@
 var http = require('http');
 var fs = require('fs');
+var path = require('path');
 
 fs.exists = fs.exists || require('path').exists;
 
@@ -17,7 +18,7 @@ var MIME_TYPE_JS = 'text/javascript';
 var MIME_TYPE_CSS = 'text/css';
 
 function log(code, string) {
-  //console.log('[' + code + '] ' + string);
+//  console.log('[' + code + '] ' + string);
 }
 
 var server = http.createServer(function(request, response) {
@@ -28,17 +29,33 @@ var server = http.createServer(function(request, response) {
     filePath = filePath.substr(0, filePath.indexOf('?'));
   }
 
-  filePath = '.' + filePath;
+  // Get the absolute path for the request
+  filePath = path.resolve('.' + filePath);
+
+  // Rejesct queries ouside of the server root
+  var serverPath = path.resolve('.');
+  if (filePath.indexOf(serverPath) != 0 ) {
+    log(403, filePath);
+    response.writeHeader(403);
+    response.end();
+
+    return;
+  }
 
   fs.exists(filePath, function(exists) {
     if (!exists) {
-      log(404, filePath)
+      log(404, filePath);
       response.writeHead(404);
       response.end();
 
       return;
     }
 
+    // Return index.html if directroy requested.
+    if (fs.statSync(filePath).isDirectory()) {
+      filePath += '/index.html';
+    }
+
     var mimeType = '';
     var fileType = -1;
 

programming_language: JavaScript