Skip to content

Commit 63123f3

Browse files
author
Yunus AYDIN
committed
Add GoChi Rule
1 parent ba4f861 commit 63123f3

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

go/ql/src/experimental/CWE-525/WebCacheDeceptionGoChi.expected

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* @name Web Cache Deception
3+
* @description A caching system has been detected on the application and is vulnerable to web cache deception on GoChi. By manipulating the URL it is possible to force the application to cache pages that are only accessible by an authenticated user. Once cached, these pages can be accessed by an unauthenticated user.
4+
* @kind problem
5+
* @problem.severity error
6+
* @security-severity 9
7+
* @precision high
8+
* @id go/web-cache-deception
9+
* @tags security
10+
* external/cwe/cwe-525
11+
*/
12+
13+
import go
14+
15+
from DataFlow::CallNode httpHandleFuncCall, ImportSpec importSpec
16+
where
17+
importSpec.getPath() = "github.com/go-chi/chi/v5" and
18+
httpHandleFuncCall.getCall().getArgument(0).toString().matches("%/*%") and
19+
not httpHandleFuncCall.getCall().getArgument(0).toString().matches("%$%") and
20+
importSpec.getFile() = httpHandleFuncCall.getFile()
21+
select httpHandleFuncCall.getCall().getArgument(0), importSpec,
22+
"Wildcard Endpoint used with " + httpHandleFuncCall.getCall().getArgument(0) + " in file: " + importSpec.getFile().getBaseName()
23+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/go-chi/chi/v5"
7+
"github.com/go-chi/chi/v5/middleware"
8+
)
9+
10+
func main() {
11+
r := chi.NewRouter()
12+
r.Use(middleware.Logger)
13+
r.Get("/*", func(w http.ResponseWriter, r *http.Request) {
14+
w.Write([]byte("welcome"))
15+
})
16+
http.ListenAndServe(":3000", r)
17+
}

0 commit comments

Comments
 (0)