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

Improve credssp credentials handling #173

Merged
merged 5 commits into from
Sep 22, 2023

Conversation

TheBestTvarynka
Copy link
Collaborator

Hi, I wrote a fix for the #152 issue.

When we try to connect using the mstsc we have two options for the source of the credentials: enter them manually or mstsc will use the saved credentials. The mstsc passes the CredsspSubmitBufferBothOld (51) only when we try to log in using the saved credentials. Moreover, it also sets the credssp_cred.p_spnego_cred pointer to NULL. So, in this case, we don't even have any actual credentials to use.

Why we can't read the saved creds:

Because they are saved as CRED_TYPE_DOMAIN_PASSWORD. If we try to read them using the CredRead function then we'll get an empty password blob (even when the function succeeded).
"The credentials exposed here do not have to be manipulated in user applications, but by the Windows authentication manager ( LSASS), so there is no reason for them to be accessible in the user area." (src)
"Also, for CRED_TYPE_DOMAIN_PASSWORD, this member can only be read by the authentication packages." (src)

Workaround:

The TSSSP security package is supported only in Windows. So, we can just ask the user to re-enter the credentials and then use them for the authentication. This is what I've implemented in this fix.

Doc & references:

closes #152

@TheBestTvarynka TheBestTvarynka force-pushed the fix/CredsspSubmitBufferBothOld-handling branch from 955325d to f4cf01e Compare September 22, 2023 13:44
@CBenoit CBenoit self-assigned this Sep 22, 2023
Comment on lines 14 to 16
use windows_sys::Win32::Security::Authentication::Identity::SspiIsAuthIdentityEncrypted;
use winapi::um::wincred::{CredUIPromptForWindowsCredentialsW, CREDUI_INFOW};
Copy link
Member

Choose a reason for hiding this comment

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

Note that the winapi crate is abandoned, and we should only use the windows crate from now on

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done
Should we create an issue (task) to replace all winapi usage with the windows crate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because we have a lot of winapi crate usage

Copy link
Member

@CBenoit CBenoit Sep 22, 2023

Choose a reason for hiding this comment

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

Yes, you are right 👍
Do you think you could open this issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, I can do it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you think you could open this issue?

#174

@TheBestTvarynka TheBestTvarynka force-pushed the fix/CredsspSubmitBufferBothOld-handling branch from 8610f84 to 5d971fa Compare September 22, 2023 15:40
@CBenoit CBenoit enabled auto-merge (squash) September 22, 2023 15:49
@CBenoit CBenoit enabled auto-merge (squash) September 22, 2023 15:49
@CBenoit CBenoit merged commit 2f26687 into master Sep 22, 2023
40 checks passed
@CBenoit CBenoit deleted the fix/CredsspSubmitBufferBothOld-handling branch September 22, 2023 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Fix mstsc.exe CREDSSP_CRED.Type CredsspSubmitBufferBothOld (51) handling
3 participants