Skip to content

Commit 47f8b52

Browse files
authored
Add G408: SSH PublicKeyCallback Authentication Bypass Analyzer (#1513)
* Add G408: SSH PublicKeyCallback Authentication Bypass Analyzer Implements a new SSA-based security analyzer (G408) that detects stateful misuse of ssh.PublicKeyCallback in SSH server configurations. This vulnerability can lead to authentication bypass where a server authenticates one SSH key but performs authorization checks on a different key. This addresses a critical security vulnerability (CVE-2024-45337, CVSS 9.1) that has affected production systems including Kubernetes and other SSH-based services. The vulnerability occurs when developers incorrectly capture and modify state within PublicKeyCallback closures, enabling attackers to authenticate with one key while the server operates on another key's credentials. Signed-off-by: Cosmin Cojocar <cosmin@cojocar.ch> * Fix tests Signed-off-by: Cosmin Cojocar <cosmin@cojocar.ch> --------- Signed-off-by: Cosmin Cojocar <cosmin@cojocar.ch>
1 parent 4f1f362 commit 47f8b52

File tree

7 files changed

+743
-0
lines changed

7 files changed

+743
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ directory you can supply `./...` as the input argument.
213213
- G405: Detect the usage of DES or RC4
214214
- G406: Detect the usage of MD4 or RIPEMD160
215215
- G407: Detect the usage of hardcoded Initialization Vector(IV)/Nonce
216+
- G408: Stateful misuse of ssh.PublicKeyCallback leading to auth bypass
216217
- G501: Import blocklist: crypto/md5
217218
- G502: Import blocklist: crypto/des
218219
- G503: Import blocklist: crypto/rc4

analyzers/analyzers_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ var _ = Describe("gosec analyzers", func() {
5959
runner("G407", testutils.SampleCodeG407)
6060
})
6161

62+
It("should detect SSH PublicKeyCallback stateful misuse", func() {
63+
runner("G408", testutils.SampleCodeG408)
64+
})
65+
6266
It("should detect out of bounds slice access", func() {
6367
runner("G602", testutils.SampleCodeG602)
6468
})

analyzers/analyzerslist.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ var defaultAnalyzers = []AnalyzerDefinition{
116116
{"G115", "Type conversion which leads to integer overflow", newConversionOverflowAnalyzer},
117117
{"G602", "Possible slice bounds out of range", newSliceBoundsAnalyzer},
118118
{"G407", "Use of hardcoded IV/nonce for encryption", newHardCodedNonce},
119+
{"G408", "Stateful misuse of ssh.PublicKeyCallback leading to auth bypass", newSSHCallbackAnalyzer},
119120
{"G701", "SQL injection via taint analysis", newSQLInjectionAnalyzer},
120121
{"G702", "Command injection via taint analysis", newCommandInjectionAnalyzer},
121122
{"G703", "Path traversal via taint analysis", newPathTraversalAnalyzer},

0 commit comments

Comments
 (0)