8000 Always use the same address format in session trackers by rosstimothy · Pull Request #52920 · gravitational/teleport · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Always use the same address format in session trackers #52920

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 fo 8000 r 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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rosstimothy
Copy link
Contributor
@rosstimothy rosstimothy commented Mar 10, 2025

It is assumed that the target_address of a SessionTracker is the host UUID for SSH sessions. However, this was only the case when in node recording mode. The value is derived from the ServerID in the return value from lib/srv 8000 .Server.TargetMetadata. In node recording mode the value is populated from the host uuid of the process running the SSH service. In proxy recording mode, the value is populated from the server id in the dial request. The discrepancy arises from the fact that the router was altering the server id to include the cluster name suffix to populate the prinicpals appropriately.

To remedy this some slight tweaks were made to the semantics of the srv.Server.HostUUID and the reversetunnelclient.DialParams. All dial requests for SSH targets now provide the resolved types.Server. This server is used as the source of truth for the hostname and host uuid of the target by the forward server. (forward.Server) ID() now returns the proxy host uuid instead of a uuid generated when creating the server. (forward.Server) HostUUID() now returns the host uuid of the target server.

Fixes #42346.

@rosstimothy rosstimothy added the no-changelog Indicates that a PR does not require a changelog entry label Mar 10, 2025
@rosstimothy rosstimothy force-pushed the tross/session_tracker_address branch 8 times, most recently from d764f65 to c13a75c Compare March 11, 2025 17:48
@rosstimothy rosstimothy marked this pull request as ready for review March 11, 2025 21:57
@rosstimothy rosstimothy force-pushed the tross/session_tracker_address branch from c13a75c to 59610fe Compare March 17, 2025 19:50
It is assumed that the `target_address` of a SessionTracker is the
host UUID for SSH sessions. However, this was only the case when in
node recording mode. The value is derived from the `ServerID` in the
return value from `lib/srv.Server.TargetMetadata`. In node recording
mode the value is populated from the host uuid of the process running
the SSH service. In proxy recording mode, the value is populated
from the server id in the dial request. The discrepency arises from
the fact that the router was altering the server id to include the
cluster name suffix to populate the prinicpals appropriately.

To remedy this some slight tweaks were made to the semantics of the
srv.Server.HostUUID and the reversetunnelclient.DialParams. All
dial requests for SSH targets now provide the resolved types.Server.
This server is used as the source of truth for the hostname and
host uuid of the target by the forward server. `(forward.Server) ID()`
now returns the proxy host uuid instead of a uuid generated when
creating the server. `(forward.Server) HostUUID()` now returns the
host uuid of the target server.

Fixes #42346.
@rosstimothy rosstimothy force-pushed the tross/session_tracker_address branch from 59610fe to efdb95e Compare March 17, 2025 19:59
Comment on lines -123 to 131
// ID is the unique ID of the server.
// ID is the unique ID of the server. For the forwarding server
// this is the UUID of the forwarding proxy, NOT the UUID of
// the target host.
ID() string

// HostUUID is the UUID of the underlying host. For the forwarding
// server this is the proxy the forwarding server is running in.
// server this is the UUID of the target host, NOT the UUID of
// the forwarding proxy.
HostUUID() string
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this change basically just flipping the claimed purpose of these methods? The original meaning of ID() was "id of the target" and the original meaning of HostUUID() was ID of wherever this logic is running. We were already bad about that distinction, and now it seems they are being fully flipped. That seems confusing. I have in progress PRs right now that would have their behavior silently changed by this change, and it seems plausible others might as well.

Admittedly, we're very inconsistent about using these and seem to use them wrong often, so I get the idea of trying to flip them to mean what they are currently being used as, but it might be better to just dump these two names and pick two new and highly unambiguous names. E.g. TargetResourceID and LocalAgentID or something along those lines. That way we make sure that anything affected by this change is actually forced to pick the one it really wants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original meaning of ID() was "id of the target" and the original meaning of HostUUID() was ID of wherever this logic is running

I don't think this is accurate for proxy recording mode. Each forward server was assigned new UUID and that is what was returned by ID(). I do agree that silently changing the meaning of these fields is probably not what we want to do and choosing new, less ambiguous names likely makes more sense.

Renaming and naming choices aside, do you foresee any other issues with the changes in this PR? Now that open dial has been removed I can't see why requiring the dial target to always be a non nil types.Server would cause issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I'm 100% on board with requiring that the target is always non-nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a PR does not require a changelog entry size/sm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misleading error when joining SSH session using Web UI in proxy recording mode
2 participants
0