CVE-2020-36559 (published 2022-12-27T22:15Z)

Due to improper sanitization of user input, HTTPEngine.Handle allows for directory traversal, allowing an attacker to read files outside of the target directory that the server has permission to read.

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/go-aah/aah
commit_details: repo_url: https://github.com/go-aah/aah
author: Jeevanandam M
author_date: 2020-03-03 01:27:03-08:00
msg: #266 addressing path traversal issue on static file delivery (#267)
repository: repo_url: https://github.com/go-aah/aah
repo_name: go-aah/aah
description: A secure, flexible, rapid Go web framework
repo_language: Go
owner: go-aah
file_changes: filename: README.md
change_type: ModificationType.MODIFY
diff: @@ -9,6 +9,7 @@
 
 ### News
 
+  * `v0.12.4` [released](https://docs.aahframework.org/release-notes.html) and tagged on Mar 03, 2020.
   * `v0.12.3` [released](https://docs.aahframework.org/release-notes.html) and tagged on Feb 06, 2019.
   * `v0.12.2` [released](https://docs.aahframework.org/release-notes.html) and tagged on Dec 13, 2018.
   * `v0.12.0` [released](https://docs.aahframework.org/release-notes.html) and tagged on Dec 02, 2018.

programming_language: Markdown
filename: http_engine.go
change_type: ModificationType.MODIFY
diff: @@ -8,13 +8,14 @@ import (
 	"errors"
 	"io"
 	"net/http"
+	"path"
 	"sync"
 	"time"
 
 	"aahframe.work/ahttp"
 	"aahframe.work/ainsp"
 	"aahframe.work/aruntime"
-	"aahframe.work/essentials"
+	ess "aahframe.work/essentials"
 	"aahframe.work/internal/settings"
 	"aahframe.work/log"
 	"aahframe.work/security"
@@ -80,6 +81,9 @@ func (e *HTTPEngine) Handle(w http.ResponseWriter, r *http.Request) {
 		defer e.a.accessLog.Log(ctx)
 	}
 
+	// Path Clean
+	r.URL.Path = path.Clean(r.URL.Path)
+
 	ctx.Req, ctx.Res = ahttp.AcquireRequest(r), ahttp.AcquireResponseWriter(w)
 
 	// Recovery handling

programming_language: Go
filename: static.go
change_type: ModificationType.MODIFY
diff: @@ -19,7 +19,7 @@ import (
 	"strings"
 
 	"aahframe.work/ahttp"
-	"aahframe.work/essentials"
+	ess "aahframe.work/essentials"
 	"aahframe.work/internal/util"
 	"aahframe.work/vfs"
 )
@@ -133,6 +133,7 @@ func (s *staticManager) Serve(ctx *Context) error {
 
 	// Serve directory
 	if fi.Mode().IsDir() && ctx.route.ListDir {
+		fmt.Println("here 1")
 		// redirect if the directory name doesn't end in a slash
 		if ctx.Req.Path[len(ctx.Req.Path)-1] != '/' {
 			ctx.Log().Debugf("redirecting to dir: %s", ctx.Req.Path+"/")

programming_language: Go
filename: static_test.go
change_type: ModificationType.MODIFY
diff: @@ -45,15 +45,17 @@ func TestStaticFilesDelivery(t *testing.T) {
 	assert.Equal(t, "no-cache, no-store, must-revalidate", resp.Header.Get(ahttp.HeaderCacheControl))
 
 	// Directory Listing - /assets
-	t.Log("Directory Listing - /assets")
-	resp, err = httpClient.Get(ts.URL + "/assets")
-	assert.Nil(t, err)
-	assert.Equal(t, 200, resp.StatusCode)
-	body := responseBody(resp)
-	assert.True(t, strings.Contains(body, "<title>Listing of /assets/</title>"))
-	assert.True(t, strings.Contains(body, "<h1>Listing of /assets/</h1><hr>"))
-	assert.True(t, strings.Contains(body, `<a href="robots.txt">robots.txt</a>`))
-	assert.Equal(t, "", resp.Header.Get(ahttp.HeaderCacheControl))
+	// t.Log("Directory Listing - /assets")
+	// resp, err = httpClient.Get(ts.URL + "/assets")
+	// fmt.Println("err", err.Error())
+	// assert.Nil(t, err)
+	// assert.Equal(t, 200, resp.StatusCode)
+	// body := responseBody(resp)
+	// fmt.Println("body", body)
+	// assert.True(t, strings.Contains(body, "<title>Listing of /assets/</title>"))
+	// assert.True(t, strings.Contains(body, "<h1>Listing of /assets/</h1><hr>"))
+	// assert.True(t, strings.Contains(body, `<a href="robots.txt">robots.txt</a>`))
+	// assert.Equal(t, "", resp.Header.Get(ahttp.HeaderCacheControl))
 
 	// Static File - /assets/img/aah-framework-logo.png
 	t.Log("Static File - /assets/img/aah-framework-logo.png")

programming_language: Go
filename: version.go
change_type: ModificationType.MODIFY
diff: @@ -5,4 +5,4 @@
 package aah
 
 // Version no. of aah framework
-const Version = "0.12.3"
+const Version = "0.12.4"

programming_language: Go