Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v8] Clear terminal when auth server is in FIPS mode (#10095) #10533

Merged
merged 7 commits into from
Mar 2, 2022
1,079 changes: 561 additions & 518 deletions api/client/proto/authservice.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions api/client/proto/authservice.proto
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ message PingResponse {
Features ServerFeatures = 3 [ (gogoproto.jsontag) = "server_features" ];
// ProxyPublicAddr is the server's public proxy address.
string ProxyPublicAddr = 4 [ (gogoproto.jsontag) = "proxy_public_addr" ];
// IsBoring signals whether or not the server was compiled with BoringCrypto.
bool IsBoring = 5 [ (gogoproto.jsontag) = "is_boring" ];
}

// Features are auth server features.
Expand Down
4 changes: 1 addition & 3 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3445,9 +3445,7 @@ func testAuditOff(t *testing.T, suite *integrationTestSuite) {
}

// audit log should have the fact that the session occurred recorded in it
sessions, err = site.GetSessions(apidefaults.Namespace)
require.NoError(t, err)
require.Len(t, sessions, 1)
// but the session could have been garbage collected at this point.

// however, attempts to read the actual sessions should fail because it was
// not actually recorded
Expand Down
1 change: 1 addition & 0 deletions lib/auth/auth_with_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,7 @@ func (a *ServerWithRoles) Ping(ctx context.Context) (proto.PingResponse, error)
ServerVersion: teleport.Version,
ServerFeatures: modules.GetModules().Features().ToProto(),
ProxyPublicAddr: a.getProxyPublicAddr(),
IsBoring: modules.GetModules().IsBoringBinary(),
}, nil
}

Expand Down
4 changes: 4 additions & 0 deletions lib/auth/keystore/testhelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@ func (t TestModules) Features() modules.Features {
func (t TestModules) BuildType() string {
return modules.BuildEnterprise
}

func (t TestModules) IsBoringBinary() bool {
return false
}
10 changes: 10 additions & 0 deletions lib/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,16 @@ func (proxy *ProxyClient) NewWatcher(ctx context.Context, watch types.Watch) (ty
return watcher, nil
}

// isAuthBoring checks whether or not the auth server for the current cluster was compiled with BoringCrypto.
func (proxy *ProxyClient) isAuthBoring(ctx context.Context) (bool, error) {
site, err := proxy.ConnectToCurrentCluster(ctx, false)
if err != nil {
return false, trace.Wrap(err)
}
resp, err := site.Ping(ctx)
return resp.IsBoring, trace.Wrap(err)
}

// FindServersByLabels returns list of the nodes which have labels exactly matching
// the given label set.
//
Expand Down
16 changes: 15 additions & 1 deletion lib/client/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ type NodeSession struct {

terminal *terminal.Terminal

// shouldClearOnExit marks whether or not the terminal should be cleared
// when the session ends.
shouldClearOnExit bool
// clientXAuthEntry contains xauth data which provides
// access to the client's local XServer.
clientXAuthEntry *x11.XAuthEntry
Expand Down Expand Up @@ -155,13 +158,24 @@ func newSession(client *NodeClient,

ns.env[sshutils.SessionEnvVar] = string(ns.id)

// Determine if terminal should clear on exit.
ns.shouldClearOnExit = isFIPS()
if client.Proxy != nil {
boring, err := client.Proxy.isAuthBoring(context.TODO())
if err != nil {
return nil, trace.Wrap(err)
}
ns.shouldClearOnExit = ns.shouldClearOnExit || boring
}

// Close the Terminal when finished.
ns.closeWait.Add(1)
go func() {
defer ns.closeWait.Done()

<-ns.closer.C
if isFIPS() {

if ns.shouldClearOnExit {
if err := ns.terminal.Clear(); err != nil {
log.Warnf("Failed to clear screen: %v.", err)
}
Expand Down