Skip to content

Commit f1d1abe

Browse files
Igor Drozdovstanhu
authored andcommitted
Merge branch 'sh-relax-fips-algorithms' into 'main'
Relax FIPS default algorithms See merge request https://gitlab.com/gitlab-org/gitlab-shell/-/merge_requests/1322 Merged-by: Igor Drozdov <idrozdov@gitlab.com> Approved-by: Igor Drozdov <idrozdov@gitlab.com> Co-authored-by: Stan Hu <stanhu@gmail.com>
2 parents 7077705 + 36c2ab1 commit f1d1abe

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
// Please do not override. Once v16.11.1 is released, this comment
2424
// can be removed.
2525
gitlab.com/gitlab-org/gitaly/v16 v16.11.0-rc1.0.20250408053233-c6d43513e93c
26-
gitlab.com/gitlab-org/labkit v1.25.0
26+
gitlab.com/gitlab-org/labkit v1.26.0
2727
golang.org/x/crypto v0.41.0
2828
golang.org/x/sync v0.16.0
2929
google.golang.org/grpc v1.72.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,8 @@ gitlab.com/gitlab-org/gitaly/v16 v16.11.0-rc1.0.20250408053233-c6d43513e93c h1:x
554554
gitlab.com/gitlab-org/gitaly/v16 v16.11.0-rc1.0.20250408053233-c6d43513e93c/go.mod h1:/rkj6992VsNymUeG6N3VnLZ8Pvb1Y9ZUo00Yy35t8WQ=
555555
gitlab.com/gitlab-org/go/reopen v1.0.0 h1:6BujZ0lkkjGIejTUJdNO1w56mN1SI10qcVQyQlOPM+8=
556556
gitlab.com/gitlab-org/go/reopen v1.0.0/go.mod h1:D6OID8YJDzEVZNYW02R/Pkj0v8gYFSIhXFTArAsBQw8=
557-
gitlab.com/gitlab-org/labkit v1.25.0 h1:ON+pf8hk5nmrFLwT4CVLniBf1kSYvBujyGp1+jW9++g=
558-
gitlab.com/gitlab-org/labkit v1.25.0/go.mod h1:ZHOQIOVQKeOEKvQ/GhGBjUNbV3zWsx8nty6D/SRCyd4=
557+
gitlab.com/gitlab-org/labkit v1.26.0 h1:UMfo6S/VmYXwquddR++odEsuTphfZvqhxAs4240syTU=
558+
gitlab.com/gitlab-org/labkit v1.26.0/go.mod h1:ZHOQIOVQKeOEKvQ/GhGBjUNbV3zWsx8nty6D/SRCyd4=
559559
go.etcd.io/raft/v3 v3.6.0 h1:5NtvbDVYpnfZWcIHgGRk9DyzkBIXOi8j+DDp1IcnUWQ=
560560
go.etcd.io/raft/v3 v3.6.0/go.mod h1:nLvLevg6+xrVtHUmVaTcTz603gQPHfh7kUAwV6YpfGo=
561561
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=

internal/sshd/server_config.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,14 @@ func (s *serverConfig) get(parentCtx context.Context) *ssh.ServerConfig {
237237
// for previous versions that support both secure and insecure defaults.
238238
if fips.Enabled() {
239239
// This can be dropped once https://github.com/golang-fips/go/issues/316 is supported.
240-
// We need to constrain the list of supported algorithms for FIPS.
241-
algorithms := fips.SupportedAlgorithms()
240+
// We need to constrain the list of supported algorithms for FIPS because
241+
// ED25519 algorithms cause gitlab-sshd to panic.
242+
//
243+
// Right now we use fips.DefaultAlgorithms() instead of fips.SupportedAlgorithms()
244+
// to preserve backwards compatibility with clients that are not configured properly.
245+
// fips.DefaultAlgorithms() still allows ssh-rsa and ssh-dss. Admins can lock down
246+
// these algorithms by setting `public_key_algorithms`.
247+
algorithms := fips.DefaultAlgorithms()
242248
sshCfg.PublicKeyAuthAlgorithms = algorithms.PublicKeyAuths
243249
sshCfg.Ciphers = algorithms.Ciphers
244250
sshCfg.KeyExchanges = algorithms.KeyExchanges

internal/sshd/server_config_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,17 @@ func TestFipsDefaultAlgorithms(t *testing.T) {
255255
srvCfg := &serverConfig{cfg: &config.Config{}}
256256
sshServerConfig := srvCfg.get(context.Background())
257257

258-
algorithms := fips.SupportedAlgorithms()
258+
algorithms := fips.DefaultAlgorithms()
259259

260260
require.Equal(t, algorithms.PublicKeyAuths, sshServerConfig.PublicKeyAuthAlgorithms)
261261
require.Equal(t, algorithms.MACs, sshServerConfig.MACs)
262262
require.Equal(t, algorithms.KeyExchanges, sshServerConfig.KeyExchanges)
263263
require.Equal(t, algorithms.Ciphers, sshServerConfig.Ciphers)
264264

265+
// Ensure ssh-rsa and ssh-dss are there for backwards compatibility.
266+
require.Contains(t, algorithms.PublicKeyAuths, "ssh-rsa")
267+
require.Contains(t, algorithms.PublicKeyAuths, "ssh-dss")
268+
265269
sshServerConfig.SetDefaults()
266270

267271
// Go automatically adds curve25519-sha256@libssh.org as alias for curve25519-sha256

0 commit comments

Comments
 (0)