577741-Remote Credencial Guard.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
Agenda • A brief Introduction • Prerequisites • A very, very short Kerberos Introduction • What are Credentials? • Credential Guard • Restricted Admin • Remote Credential Guard • MS-CSSP • MS-RDPEAR What I Expect You to Already Know •Kerberos •Restricted Admin Mode •Credential Security Support Provider (CredSSP) Protocol •RPC Marshalling & ASN1 Serialization A Brief Introduction • Remote Credential Guard is the RDP version of Credential Guard • In Credential Guard, Virtualized Environment stores the Credentials • In Remote Credential Guard, instead of Virtualized Environment, RDP Client stores the Clear Credentials • In Credential Guard, LSASS exchange messages with Virtualized Environment when it needs a new ticket or authenticate message to login to a service • RDP server exchanges similar kind of messages with LSASS on the client when it needs a new ticket to authenticate to a service Demo of Remote Credential Guard What Problem We’re trying to Solve? • RDP requires User Credentials to create a User Session on Remote Target • CredSSP (NLA) is employed to ferry the Clear Text Credentials to Remote Target • While the Credentials in transit are doubly encrypted, they are decrypted on the Remote Target to pass to LsaLongonUser API • If the Remote Target is compromised, an attacker can steal the Credentials • Remote Credentials Guard fixes these issues by sending encrypted session key1 and TGT instead of clear text username and password 1. RCG also send encrypted NTOWF which is used to login to services that don’t support Kerberos A very, very short refresher to Kerberos • Require 3 entities to work: client, service, KDC1 (also hosts TGS2) • Client and Service both share long term secrets with KDC (password derived hashes a.k.a long term keys) • Client requests a ticket to authenticate to a service • At the time of logging on, client acquires a ticket for a TGS • The ticket for TGS is called TGT (Ticket Granting Ticket) • Once a TGT is issued, the long-term key is destroyed on client • TGT and associated session key are now the credentials. These need to be protected as they are used to request tickets for other services e.g. SMB (Server Message Block a.k.a File Sharing) 1. Key Distribution Center 2. Ticket Granting Service What are Credentials? • Username & Passwords • Certificates/key pairs • Derived Credentials • NTLM OWF hash of Password • Kerberos long term key • Kerberos TGT Session Key • Kerberos Service Ticket Session Key Credential Guard (CG) • An environment in which LSASS only stores Encrypted Credentials • Credentials are exposed for a very small amount of time when a user is logging in. • After that, the LSASS stores the encrypted credentials and a virtualized environment stores the encryption keys • Whenever LSASS needs to use credentials, it will communicate with virtualized environment • All communication between LSASS and virtualized environment is through RPC. Every message is signed and, as a result, no chance of tampering • Virtualized Environment will do encryption or decryption, since it has the keys (like TPM or SmartCard do). Restricted Admin • A mode for RDP where no credentials are sent to RDP server • The user is logged in without any credentials if they are an admin on the RDP host • The login session is running under machine account. • Cannot login to any other service from the RDP host • Prevents “pass the hash” attacks. • As name implies, it is very restricting. Remote Credential Guard • A improvement on Restricted Admin Mode • Encrypted Credentials are sent to RDP server (like LSASS in CG) • Only client can decrypt/encrypt the credentials (like virtualized environment in CG) • When the user in RDP session needs to login to another service, it send encrypted credentials to client with a specific requests • Client decrypts credentials, generates the requested data and sends it back to RDP server. • Server pass along the received data to service and usual authentication then happens. Requirement for Remote Guard • Client and Server must be domain joined • Client and Server must be running Windows 10 v.1607/WS2016 or later • On server, add DWORD DisableRestrictedAdmin and set it to 0 in the registry HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa • Only classical mstsc supports remote guard (not the store version) • On client: enable GP or on command line by running C:>Mstsc [.rdp filename] /remoteGuard • More details here: https://docs.microsoft.com/en-us/windows/access-protection/remote-credential-guard User’s Device Remote Remote Host Desktop User’s Session Connection User’s Session Credentials TGT NTLM NTOWF TGT key NTOWF Key Kerberos NTLM TGT NTOWF TGT key Kerberos TGT TGT Key User’s Device Remote Host TGS TGT key User’s Session User’s Session exchange Authenticator TGS-REP NTLM TGT key NTOWF Key Unsigned TGS-REQ Kerberos NTLM Signed TGS-REQ File TGT server TGT key TGT key Kerberos User’s TGS-REP ST Session TGT Authenticator ST Key TGT Key TGS-REP Changes to MS-CSSP • MS-CSSP is augmented to send encrypted credentials to RDP server • New ASN1 data type is introduced to carry the payload called TSRemoteGuardCreds TSRemoteGuardCreds ::= SEQUENCE{ logonCred [0] TSRemoteGuardPackageCred, supplementalCreds [1] SEQUENCE OF TSRemoteGuardPackageCred OPTIONAL, } TSRemoteGuardPackageCred ::= SEQUENCE{ packageName [0] OCTET STRING, credBuffer [1] OCTET STRING, } TSRemoteGuardCreds on the Wire 00000000: 30 82 0B 3E ; SEQUENCE (2878 bytes) 00000004: A0 82 0A 53 ; [0] (2643 bytes) 00000008: | 30 82 0A 4F ; SEQUENCE (2639 bytes) logonCred 0000000c: | A0 12 ; [0] (18 bytes) 0000000e: | | 04 10 ; OCTETSTRING (16 bytes) 00000010: | | 4B 00 65 Kerberos00 72 00 62 00 65 00 72 00 6F 00 73 00 ; K.e.r.b.e.r.o.s. 00000020: | A1 82 0A 37 ; [1] (2615 bytes) 00000024: | 04 82 0A 33 ; OCTETSTRING (2611 bytes) --------------------------------------Kerberos CredBuffer--------------------------------------- 00000a5b: A1 81 E4 ; [1] (228 bytes) supplementalCreds 00000a5e: 30 81 E1 ; SEQUENCE (225 bytes) 00000a61: 30 81 DE ; SEQUENCE (222 bytes) 00000a64: A0 0A ; [0] (10 bytes) 00000a66: | 04 08 ; OCTETSTRING (8 bytes) 00000a68: | 4E 00 54 00 NTLM4C 00 4D 00 ; N.T.L.M. 00000a70: A1 81 CF ; [1] (207 bytes) 00000a73: 04 81 CC ; OCTETSTRING (204 bytes) ------------------------------------------NTLM CredBuffer--------------------------------------- logonCred • Kerberos credentials are RPC marshalled KERB_TICKET_LOGON structure https://msdn.microsoft.com/en-us/library/windows/desktop/aa378143(v=vs.85).aspx typedef struct _KERB_TICKET_LOGON { KERB_LOGON_SUBMIT_TYPE MessageType; ULONG Flags; ULONG ServiceTicketLength; ULONG TicketGrantingTicketLength; PUCHAR ServiceTicket; PUCHAR TicketGrantingTicket; } KERB_TICKET_LOGON, *PKERB_TICKET_LOGON; TicketGrantingTicket • TicketGrantingTicket field of KERB_TICKET_LOGON structure is actually a KRB_CRED message • KRB_CRED message is specified in RFC4120, section 5.8.1 • The enc-part contains KERB_RPC_ENCRYPTION_KEY specified in MS-RDPEAR section 2.2.1.2.1 supplementalCreds • SupplementalCreds contain MSV1_0_REMOTE_ENCRYPTED_SECRETS • MSV1_0_REMOTE_ENCRYPTED_SECRETS are specified in MS-RDPEAR section 2.2.1.3.1 • These are encrypted secrets for NTLM • They are used in case of logging in to a service when use of Kerberos is not possible (e.g. due to absence of SPN) New Protocol MS-RDPEAR • Since the target does not possess the TGT session key, it needs help from the client to sign, encrypt and decrypt messages. • A new protocol is created to allow target to send data to client for cryptographic functions involving TGT session key. • The data is exchanged on a dynamic virtual channel (DVC) named Microsoft::Windows::RDS::AuthRedirection • Target Server acts as MS-RDPEAR client and initiate request • RDP client acts as MS-RDPEAR server and carry out requested cryptographic operations. Example Exchange of Messages For More Information • Credential Guard https://channel9.msdn.com/events/Ignite/Microsoft-Ignite-Orlando-2017/BRK2077 • Remote Credential Guard https://docs.microsoft.com/en-us/windows/security/identity-protection/remote-credential-guard • RFC4120 http://www.rfc-editor.org/rfc/rfc4120.txt.