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

Fix the new license flow #43

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix the new license flow #43

wants to merge 2 commits into from

Conversation

zmb3
Copy link

@zmb3 zmb3 commented Oct 13, 2024

Fixes several bugs with the new license flow and allows us to successfully obtain a license. The next step will be to add hooks to save this license so that we can reuse it for the upgrade license flow on subsequent attempts.

Additionally, uses a client-provided UUID to identify itself to the RDP server for licensing purposes (we were previously using the Windows domain, which would cause all Teleport RDP clients to appear identical to the server).

@zmb3 zmb3 force-pushed the zmb3/fix-newlicense-flow branch 4 times, most recently from 8f382cf to a2274ea Compare October 16, 2024 02:25
@zmb3 zmb3 force-pushed the zmb3/enhance-license-parsing branch from b87a883 to b14690c Compare October 16, 2024 21:36
Base automatically changed from zmb3/enhance-license-parsing to master October 16, 2024 21:51
@zmb3 zmb3 force-pushed the zmb3/fix-newlicense-flow branch 3 times, most recently from de2196f to 42efb5f Compare October 16, 2024 22:40
@zmb3 zmb3 marked this pull request as ready for review October 16, 2024 22:40
Copy link

@espadolini espadolini left a comment

Choose a reason for hiding this comment

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

I don't have nearly enough context to understand the business logic parts of this, fwiw.

src/core/license.rs Outdated Show resolved Hide resolved
return Err(Error::RdpError(RdpError::new(
RdpErrorKind::InvalidData,
"SEC: Invalid Licence packet",
format!("SEC: Invalid Licence packet (flag={:x})", security_flag).as_str(),

Choose a reason for hiding this comment

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

Suggested change
format!("SEC: Invalid Licence packet (flag={:x})", security_flag).as_str(),
&format!("SEC: Invalid Licence packet (flag={security_flag:x})"),

src/core/license.rs Outdated Show resolved Hide resolved
/// ServerNewLicense message.
///
/// See MS-RDPELE section 2.2.2.6.
type ServerUpgradeLicense = ServerNewLicense;

/// License data that has been obtained from the sever
#[allow(dead_code)]

Choose a reason for hiding this comment

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

Suggested change
#[allow(dead_code)]

src/core/license.rs Show resolved Hide resolved
src/core/license.rs Outdated Show resolved Hide resolved
];

message.read(raw)?;
let server_random = cast!(DataType::Slice, message["ServerRandom"])?;
let version = cast!(DataType::U32, message["dwVersion"])?;
let server_certificate = cast!(DataType::Component, message["ServerCertificate"])?;
let mut blob_data = cast!(DataType::Slice, server_certificate["blobData"])?;
let scope_count = cast!(DataType::U32, message["ScopeCount"])?;

let mut scopes = Vec::with_capacity(scope_count as usize);

Choose a reason for hiding this comment

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

Where is that ScopeCount coming from? Is it trustworthy?

Copy link
Author

Choose a reason for hiding this comment

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

It's coming from the Windows server that is requesting a license from us.

I've never seen anything other than 1, but I don't have a very sophisticated setup. Maybe we should put some reasonable maximum (100?) here to avoid unbounded allocations?

(Now that you point this out, the with_capacity doesn't do much because thats the number of scopes, not any sort of byte-length).

Fixes several bugs with the new license flow and allows us to
successfully obtain a license.

Additionally, use a client-provided UUID to identify the client
instead of using the Windows domain (which isn't unique per-agent).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants