Skip to content

Commit 4ab8e56

Browse files
earl-warrenGustedGiteaBot
authored
restrict certificate type for builtin SSH server (#26789)
- While doing some sanity checks over OpenSSH's code for how they handle certificates authentication. I stumbled on an condition that checks the certificate type is really an user certificate on the server-side authentication. This checks seems to be a formality and just for the sake of good domain seperation, because an user and host certificate don't differ in their generation, verification or flags that can be included. - Add this check to the builtin SSH server to stay close to the unwritten SSH specification. - This is an breaking change for setups where the builtin SSH server is being used and for some reason host certificates were being used for authentication. - (cherry picked from commit de35b141b79a3d6efe2127ed2c73fd481515e481) Refs: https://codeberg.org/forgejo/forgejo/pulls/1172 ## ⚠️ BREAKING ⚠️ Like OpenSSH, the built-in SSH server will now only accept SSH user certificates, not server certificates. Co-authored-by: Gusted <[email protected]> Co-authored-by: Giteabot <[email protected]>
1 parent 9eb4a9e commit 4ab8e56

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modules/ssh/ssh.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ func publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) bool {
191191
return false
192192
}
193193

194+
if cert.CertType != gossh.UserCert {
195+
log.Warn("Certificate Rejected: Not a user certificate")
196+
log.Warn("Failed authentication attempt from %s", ctx.RemoteAddr())
197+
return false
198+
}
199+
194200
// look for the exact principal
195201
principalLoop:
196202
for _, principal := range cert.ValidPrincipals {

0 commit comments

Comments
 (0)