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

Clear terminal when auth server is in FIPS mode #10095

Merged
merged 10 commits into from
Feb 17, 2022
1,187 changes: 615 additions & 572 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 @@ -364,6 +364,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" ];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not exposed on the public unauth /ping endpoint right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. This is only exposed on auth's grpc server.

}

// 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 @@ -3454,9 +3454,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.
timothyb89 marked this conversation as resolved.
Show resolved Hide resolved

// 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 @@ -1510,6 +1510,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
10 changes: 10 additions & 0 deletions lib/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,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 @@ -78,6 +78,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 @@ -156,13 +159,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