Skip to content

Commit 5fa632b

Browse files
committed
fix: address CodeRabbit security and documentation feedback
- Use crypto/subtle.ConstantTimeCompare for webhook secret validation to prevent timing attacks - Fix test script usage comment to match actual filename Signed-off-by: Tanjim Hossain <[email protected]>
1 parent 03ebf4a commit 5fa632b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

config/examples/cloudevents/test-webhook.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# Test script for CloudEvents webhook
3-
# Usage: ./test-cloudevents-webhook.sh <webhook-url> <secret>
3+
# Usage: ./test-webhook.sh <webhook-url> <secret>
44

55
set -e
66

pkg/webhook/cloudevents.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package webhook
22

33
import (
4+
"crypto/subtle"
45
"encoding/json"
56
"fmt"
67
"io"
@@ -63,7 +64,7 @@ func (c *CloudEventsWebhook) Validate(r *http.Request) error {
6364
return fmt.Errorf("missing webhook secret")
6465
}
6566

66-
if secret != c.secret {
67+
if subtle.ConstantTimeCompare([]byte(secret), []byte(c.secret)) != 1 {
6768
return fmt.Errorf("invalid webhook secret")
6869
}
6970
}

0 commit comments

Comments
 (0)