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

[v7] Clear terminal when auth server is in FIPS mode (#10095) #16391

Merged
merged 3 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
815 changes: 429 additions & 386 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 @@ -303,6 +303,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 @@ -3056,9 +3056,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 @@ -1244,6 +1244,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 @@ -542,6 +542,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
17 changes: 16 additions & 1 deletion lib/client/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ type NodeSession struct {
enableEscapeSequences bool

terminal *terminal.Terminal

// shouldClearOnExit marks whether or not the terminal should be cleared
// when the session ends.
shouldClearOnExit bool
}

// newSession creates a new Teleport session with the given remote node
Expand Down Expand Up @@ -143,13 +147,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
4 changes: 4 additions & 0 deletions lib/srv/db/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ func (m *testModules) Features() modules.Features {
}
}

func (m *testModules) IsBoringBinary() bool {
return false
}

// TestAccessDisabled makes sure database access can be disabled via modules.
func TestAccessDisabled(t *testing.T) {
defaultModules := modules.GetModules()
Expand Down
4 changes: 4 additions & 0 deletions lib/web/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2090,6 +2090,10 @@ func (m *testModules) Features() modules.Features {
}
}

func (m *testModules) IsBoringBinary() bool {
return false
}

func TestClusterDatabasesGet(t *testing.T) {
env := newWebPack(t, 1)

Expand Down