Skip to content

Commit 3dfc9f6

Browse files
committed
Manual fixes
1 parent 56ec153 commit 3dfc9f6

18 files changed

Lines changed: 74 additions & 74 deletions

go/ql/src/experimental/CWE-525/WebCacheDeception.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/**
22
* @name Web Cache Deception
33
* @description A caching system has been detected on the application and is vulnerable to web cache deception. 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.
44
* @kind problem

go/ql/test/experimental/CWE-285/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
func bad() error {
1010
t, _ := pam.StartFunc("", "", func(s pam.Style, msg string) (string, error) {
1111
return "", nil
12-
}) // $ Alert[go/pam-auth-bypass]
12+
}) // $ Alert
1313
return t.Authenticate(0)
1414

1515
}

go/ql/test/experimental/CWE-321-V2/HardCodedKeys.expected

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#select
2+
| go-jose.v3.go:24:32:24:37 | JwtKey | go-jose.v3.go:13:21:13:33 | "AllYourBase" | go-jose.v3.go:24:32:24:37 | JwtKey | This $@. | go-jose.v3.go:13:21:13:33 | "AllYourBase" | Constant Key is used as JWT Secret key |
3+
| golang-jwt-v5.go:27:9:27:15 | JwtKey1 | golang-jwt-v5.go:19:22:19:34 | "AllYourBase" | golang-jwt-v5.go:27:9:27:15 | JwtKey1 | This $@. | golang-jwt-v5.go:19:22:19:34 | "AllYourBase" | Constant Key is used as JWT Secret key |
14
edges
25
| go-jose.v3.go:13:14:13:34 | type conversion | go-jose.v3.go:24:32:24:37 | JwtKey | provenance | |
36
| go-jose.v3.go:13:21:13:33 | "AllYourBase" | go-jose.v3.go:13:14:13:34 | type conversion | provenance | |
@@ -11,6 +14,3 @@ nodes
1114
| golang-jwt-v5.go:19:22:19:34 | "AllYourBase" | semmle.label | "AllYourBase" |
1215
| golang-jwt-v5.go:27:9:27:15 | JwtKey1 | semmle.label | JwtKey1 |
1316
subpaths
14-
#select
15-
| go-jose.v3.go:24:32:24:37 | JwtKey | go-jose.v3.go:13:21:13:33 | "AllYourBase" | go-jose.v3.go:24:32:24:37 | JwtKey | This $@. | go-jose.v3.go:13:21:13:33 | "AllYourBase" | Constant Key is used as JWT Secret key |
16-
| golang-jwt-v5.go:27:9:27:15 | JwtKey1 | golang-jwt-v5.go:19:22:19:34 | "AllYourBase" | golang-jwt-v5.go:27:9:27:15 | JwtKey1 | This $@. | golang-jwt-v5.go:19:22:19:34 | "AllYourBase" | Constant Key is used as JWT Secret key |

go/ql/test/experimental/CWE-321-V2/go-jose.v3.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
// NOT OK
13-
var JwtKey = []byte("AllYourBase") // $ Source[go/parse-jwt-with-hardcoded-key] Alert[go/parse-jwt-with-hardcoded-key]
13+
var JwtKey = []byte("AllYourBase") // $ Source
1414

1515
func main2(r *http.Request) {
1616
signedToken := r.URL.Query().Get("signedToken")
@@ -21,7 +21,7 @@ func verifyJWT(signedToken string) {
2121
fmt.Println("verifying JWT")
2222
DecodedToken, _ := jwt.ParseSigned(signedToken)
2323
out := CustomerInfo{}
24-
if err := DecodedToken.Claims(JwtKey, &out); err != nil { // $ Alert[go/parse-jwt-with-hardcoded-key] Source[go/parse-jwt-with-hardcoded-key]
24+
if err := DecodedToken.Claims(JwtKey, &out); err != nil { // $ Alert
2525
panic(err)
2626
}
2727
fmt.Printf("%v\n", out)

go/ql/test/experimental/CWE-321-V2/golang-jwt-v5.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ type CustomerInfo struct {
1616
}
1717

1818
// BAD constant key
19-
var JwtKey1 = []byte("AllYourBase") // $ Source[go/parse-jwt-with-hardcoded-key] Alert[go/parse-jwt-with-hardcoded-key]
19+
var JwtKey1 = []byte("AllYourBase") // $ Source
2020

2121
func main1(r *http.Request) {
2222
signedToken := r.URL.Query().Get("signedToken")
2323
verifyJWT_golangjwt(signedToken)
2424
}
2525

2626
func LoadJwtKey(token *jwt.Token) (interface{}, error) {
27-
return JwtKey1, nil // $ Alert[go/parse-jwt-with-hardcoded-key] Source[go/parse-jwt-with-hardcoded-key]
27+
return JwtKey1, nil // $ Alert
2828
}
2929

3030
func verifyJWT_golangjwt(signedToken string) {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#select
2+
| DatabaseCallInLoop.go:9:3:9:41 | call to First | DatabaseCallInLoop.go:7:2:11:2 | range statement | DatabaseCallInLoop.go:9:3:9:41 | call to First | This calls call to First in a $@. | DatabaseCallInLoop.go:7:2:11:2 | range statement | loop |
3+
| test.go:11:2:11:13 | call to Take | test.go:20:2:22:2 | for statement | test.go:11:2:11:13 | call to Take | This calls call to Take in a $@. | test.go:20:2:22:2 | for statement | loop |
4+
| test.go:11:2:11:13 | call to Take | test.go:24:2:26:2 | for statement | test.go:11:2:11:13 | call to Take | This calls call to Take in a $@. | test.go:24:2:26:2 | for statement | loop |
15
edges
26
| DatabaseCallInLoop.go:7:2:11:2 | range statement | DatabaseCallInLoop.go:9:3:9:41 | call to First |
37
| test.go:10:1:12:1 | function declaration | test.go:11:2:11:13 | call to Take |
@@ -7,7 +11,3 @@ edges
711
| test.go:21:3:21:14 | call to runQuery | test.go:10:1:12:1 | function declaration |
812
| test.go:24:2:26:2 | for statement | test.go:25:3:25:17 | call to runRunQuery |
913
| test.go:25:3:25:17 | call to runRunQuery | test.go:14:1:16:1 | function declaration |
10-
#select
11-
| DatabaseCallInLoop.go:9:3:9:41 | call to First | DatabaseCallInLoop.go:7:2:11:2 | range statement | DatabaseCallInLoop.go:9:3:9:41 | call to First | This calls call to First in a $@. | DatabaseCallInLoop.go:7:2:11:2 | range statement | loop |
12-
| test.go:11:2:11:13 | call to Take | test.go:20:2:22:2 | for statement | test.go:11:2:11:13 | call to Take | This calls call to Take in a $@. | test.go:20:2:22:2 | for statement | loop |
13-
| test.go:11:2:11:13 | call to Take | test.go:24:2:26:2 | for statement | test.go:11:2:11:13 | call to Take | This calls call to Take in a $@. | test.go:24:2:26:2 | for statement | loop |

go/ql/test/experimental/CWE-400/DatabaseCallInLoop.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ func getUsers(db *gorm.DB, names []string) []User {
66
res := make([]User, 0, len(names))
77
for _, name := range names {
88
var user User
9-
db.Where("name = ?", name).First(&user) // $ Alert[go/examples/database-call-in-loop] Source[go/examples/database-call-in-loop]
9+
db.Where("name = ?", name).First(&user) // $ Alert
1010
res = append(res, user)
11-
} // $ Source[go/examples/database-call-in-loop] Alert[go/examples/database-call-in-loop]
11+
} // $ Source
1212
return res
1313
}

go/ql/test/experimental/CWE-400/test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ type User struct {
88
}
99

1010
func runQuery(db *gorm.DB) {
11-
db.Take(nil) // $ Alert[go/examples/database-call-in-loop] Source[go/examples/database-call-in-loop]
12-
} // $ Alert[go/examples/database-call-in-loop] Source[go/examples/database-call-in-loop]
11+
db.Take(nil) // $ Alert
12+
}
1313

1414
func runRunQuery(db *gorm.DB) {
15-
runQuery(db) // $ Source[go/examples/database-call-in-loop] Alert[go/examples/database-call-in-loop]
16-
} // $ Alert[go/examples/database-call-in-loop] Source[go/examples/database-call-in-loop]
15+
runQuery(db)
16+
}
1717

1818
func main() {
1919
var db *gorm.DB
2020
for i := 0; i < 10; i++ {
21-
runQuery(db) // $ Source[go/examples/database-call-in-loop] Alert[go/examples/database-call-in-loop]
22-
} // $ Source[go/examples/database-call-in-loop] Alert[go/examples/database-call-in-loop]
21+
runQuery(db)
22+
} // $ Source
2323

2424
for i := 10; i > 0; i-- {
25-
runRunQuery(db) // $ Source[go/examples/database-call-in-loop] Alert[go/examples/database-call-in-loop]
26-
} // $ Source[go/examples/database-call-in-loop] Alert[go/examples/database-call-in-loop]
25+
runRunQuery(db)
26+
} // $ Source
2727
}

go/ql/test/experimental/CWE-525/WebCacheDeceptionBad.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func badRoutingNet() {
7979

8080
http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets/"))))
8181

82-
http.HandleFunc("/adminusers/", ShowAdminPageCache) // $ Alert[go/web-cache-deception]
82+
http.HandleFunc("/adminusers/", ShowAdminPageCache) // $ Alert
8383
err := http.ListenAndServe(":1337", nil)
8484
if err != nil {
8585
log.Fatal("ListenAndServe: ", err)

go/ql/test/experimental/CWE-525/WebCacheDeceptionFiber.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ func badRouting() {
1212
log.Println("We are logging in Golang!")
1313

1414
// GET /api/register
15-
app.Get("/api/*", func(c *fiber.Ctx) error { // $ Alert[go/web-cache-deception]
15+
app.Get("/api/*", func(c *fiber.Ctx) error { // $ Alert
1616
msg := fmt.Sprintf("✋")
1717
return c.SendString(msg) // => ✋ register
1818
})
1919

20-
app.Post("/api/*", func(c *fiber.Ctx) error { // $ Alert[go/web-cache-deception]
20+
app.Post("/api/*", func(c *fiber.Ctx) error { // $ Alert
2121
msg := fmt.Sprintf("✋")
2222
return c.SendString(msg) // => ✋ register
2323
})

0 commit comments

Comments
 (0)