CVE-2019-25087 (published 2022-12-27T09:15Z)

A vulnerability was found in RamseyK httpserver. It has been rated as critical. This issue affects the function ResourceHost::getResource of the file src/ResourceHost.cpp of the component URI Handler. The manipulation of the argument uri leads to path traversal: '../filedir'. The attack may be initiated remotely. The name of the patch is 1a0de56e4dafff9c2f9c8f6b130a764f7a50df52. It is recommended to apply a patch to fix this issue. The associated identifier of this vulnerability is VDB-216863.

CVSS v3 base score: 7.5, HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/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/RamseyK/httpserver
commit_details: repo_url: https://github.com/RamseyK/httpserver
author: RamseyK
author_date: 2019-09-08 11:23:20-05:00
msg: Deny any directory traversal paths.  README update
repository: repo_url: https://github.com/RamseyK/httpserver
repo_name: RamseyK/httpserver
description: A high performance, single threaded, HTTP/1.1 server written in C++ as a learning tool.  Uses kqueue for event management, therefore is MacOS / *BSD only!
repo_language: C++
owner: RamseyK
file_changes: filename: README.md
change_type: ModificationType.MODIFY
diff: @@ -3,7 +3,7 @@
 Ramsey Kant
 https://github.com/RamseyK/httpserver
 
-A high performance, single threaded, HTTP server written in C++ to serve as a kqueue socket management and HTTP protocol learning tool
+A high performance, single threaded, HTTP server written in C++ to serve as a kqueue socket management and HTTP protocol learning tool on BSD systems
 
 ## Features
 * Clean, documented code
@@ -11,5 +11,8 @@ A high performance, single threaded, HTTP server written in C++ to serve as a kq
 * Easy to understand HTTP protocol parser (from my ByteBuffer project)
 * Tested on FreeBSD and MacOS
 
+## Compiling Notes
+* On FreeBSD, compile with gmake
+
 ## License
 See LICENSE.TXT

programming_language: Markdown
filename: HTTPServer.cpp
change_type: ModificationType.MODIFY
diff: @@ -440,7 +440,7 @@ void HTTPServer::handleRequest(Client *cl, HTTPRequest* req) {
 	std::cout << "[" << cl->getClientIP() << "] " << req->methodIntToStr(req->getMethod()) << " " << req->getRequestUri() << std::endl;
 	/*std::cout << "Headers:" << std::endl;
 	for(int i = 0; i < req->getNumHeaders(); i++) {
-		std::cout << req->getHeaderStr(i) << std::endl;
+		std::cout << "\t" << req->getHeaderStr(i) << std::endl;
 	}
 	std::cout << std::endl;*/
 

programming_language: C++
filename: ResourceHost.cpp
change_type: ModificationType.MODIFY
diff: @@ -183,6 +183,9 @@ Resource* ResourceHost::getResource(std::string uri) {
 	if (uri.length() > 255 || uri.empty())
 		return NULL;
 
+	if (uri.find("../") != std::string::npos)
+		return NULL;
+
 	std::string path = baseDiskPath + uri;
 	Resource* res = NULL;
 

programming_language: C++