Skip to content

Commit 34ad5c0

Browse files
committed
security: reject empty signing secret for NewSecretsVerifier
1 parent c6edc27 commit 34ad5c0

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.23.1] - 2026-05-10
11+
12+
### Fixed
13+
14+
- `NewSecretsVerifier` now rejects empty signing secrets to avoid accepting forged request
15+
signatures when applications are misconfigured.
16+
1017
## [0.23.0] - 2026-04-22
1118

1219
### Added
@@ -559,7 +566,8 @@ for details.
559566
[#1196]: https://github.com/slack-go/slack/issues/1196
560567
[#1547]: https://github.com/slack-go/slack/pull/1547
561568
562-
[Unreleased]: https://github.com/slack-go/slack/compare/v0.23.0...HEAD
569+
[Unreleased]: https://github.com/slack-go/slack/compare/v0.23.1...HEAD
570+
[0.23.1]: https://github.com/slack-go/slack/compare/v0.23.0...v0.23.1
563571
[0.23.0]: https://github.com/slack-go/slack/compare/v0.22.0...v0.23.0
564572
[0.22.0]: https://github.com/slack-go/slack/compare/v0.21.1...0.22.0
565573
[0.21.1]: https://github.com/slack-go/slack/compare/v0.21.0...v0.21.1

security.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ func unsafeSignatureVerifier(header http.Header, secret string) (_ SecretsVerifi
3030
bsignature []byte
3131
)
3232

33+
if secret == "" {
34+
return SecretsVerifier{}, ErrInvalidConfiguration
35+
}
36+
3337
signature := header.Get(hSignature)
3438
stimestamp := header.Get(hTimestamp)
3539

security_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package slack
22

33
import (
4+
"errors"
45
"io"
56
"log"
67
"net/http"
@@ -32,6 +33,20 @@ func TestExpiredTimestamp(t *testing.T) {
3233
}
3334
}
3435

36+
func TestNewSecretsVerifierRejectsEmptySigningSecret(t *testing.T) {
37+
_, err := NewSecretsVerifier(newHeader(true), "")
38+
if !errors.Is(err, ErrInvalidConfiguration) {
39+
t.Fatalf("expected ErrInvalidConfiguration, got %v", err)
40+
}
41+
}
42+
43+
func TestUnsafeSignatureVerifierRejectsEmptySigningSecret(t *testing.T) {
44+
_, err := unsafeSignatureVerifier(newHeader(true), "")
45+
if !errors.Is(err, ErrInvalidConfiguration) {
46+
t.Fatalf("expected ErrInvalidConfiguration, got %v", err)
47+
}
48+
}
49+
3550
func TestUnsafeSignatureVerifier(t *testing.T) {
3651
tests := []struct {
3752
title string

0 commit comments

Comments
 (0)