File tree 2 files changed +9
-2
lines changed 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 5
5
package routers
6
6
7
7
import (
8
+ "crypto/subtle"
9
+
8
10
"github.com/prometheus/client_golang/prometheus/promhttp"
9
11
10
12
"code.gitea.io/gitea/modules/context"
@@ -22,7 +24,9 @@ func Metrics(ctx *context.Context) {
22
24
ctx .Error (401 )
23
25
return
24
26
}
25
- if header != "Bearer " + setting .Metrics .Token {
27
+ got := []byte (header )
28
+ want := []byte ("Bearer " + setting .Metrics .Token )
29
+ if subtle .ConstantTimeCompare (got , want ) != 1 {
26
30
ctx .Error (401 )
27
31
return
28
32
}
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ package repo
8
8
9
9
import (
10
10
"container/list"
11
+ "crypto/subtle"
11
12
"fmt"
12
13
"io"
13
14
"path"
@@ -771,7 +772,9 @@ func TriggerTask(ctx *context.Context) {
771
772
if ctx .Written () {
772
773
return
773
774
}
774
- if secret != base .EncodeMD5 (owner .Salt ) {
775
+ got := []byte (base .EncodeMD5 (owner .Salt ))
776
+ want := []byte (secret )
777
+ if subtle .ConstantTimeCompare (got , want ) != 1 {
775
778
ctx .Error (404 )
776
779
log .Trace ("TriggerTask [%s/%s]: invalid secret" , owner .Name , repo .Name )
777
780
return
You can’t perform that action at this time.
0 commit comments