Skip to content

Commit

Permalink
[core,redirect] extract and check redirection cert
Browse files Browse the repository at this point in the history
* extract the certificate from the redirection PDU
* if there is a certificate provided accept it if it matches the
  redirection target certificate without further user checks
  • Loading branch information
akallabeth committed Feb 28, 2023
1 parent b2fa6da commit ae8f010
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 71 deletions.
6 changes: 2 additions & 4 deletions include/freerdp/settings.h
Expand Up @@ -657,7 +657,6 @@ typedef struct
#define FreeRDP_RedirectionGuid (1234)
#define FreeRDP_RedirectionGuidLength (1235)
#define FreeRDP_RedirectionTargetCertificate (1236)
#define FreeRDP_RedirectionTargetCertificateLength (1237)
#define FreeRDP_Password51 (1280)
#define FreeRDP_Password51Length (1281)
#define FreeRDP_SmartcardLogon (1282)
Expand Down Expand Up @@ -1174,9 +1173,8 @@ struct rdp_settings
ALIGN64 UINT32 RedirectionPreferType; /* 1233 */
ALIGN64 BYTE* RedirectionGuid; /* 1234 */
ALIGN64 UINT32 RedirectionGuidLength; /* 1235 */
ALIGN64 BYTE* RedirectionTargetCertificate; /* 1236 */
ALIGN64 UINT32 RedirectionTargetCertificateLength; /* 1237 */
UINT64 padding1280[1280 - 1238]; /* 1238 */
ALIGN64 rdpCertificate* RedirectionTargetCertificate; /* 1236 */
UINT64 padding1280[1280 - 1237]; /* 1237 */

/**
* Security
Expand Down
17 changes: 15 additions & 2 deletions libfreerdp/common/settings.c
Expand Up @@ -1341,8 +1341,21 @@ BOOL freerdp_settings_set_pointer_len(rdpSettings* settings, size_t id, const vo
return freerdp_settings_set_pointer_len_(settings, id, FreeRDP_RedirectionTsvUrlLength,
data, len, sizeof(char));
case FreeRDP_RedirectionTargetCertificate:
return freerdp_settings_set_pointer_len_(
settings, id, FreeRDP_RedirectionTargetCertificateLength, data, len, sizeof(BYTE));
freerdp_certificate_free(settings->RedirectionTargetCertificate);

if (len > 1)
{
WLog_ERR(TAG, "FreeRDP_RedirectionTargetCertificate::len must be 0 or 1");
return FALSE;
}
settings->RedirectionTargetCertificate = cnv.v;
if (!settings->RedirectionTargetCertificate && (len > 0))
{
settings->RedirectionTargetCertificate = freerdp_certificate_new();
if (!settings->RedirectionTargetCertificate)
return FALSE;
}
return TRUE;
case FreeRDP_RedirectionGuid:
return freerdp_settings_set_pointer_len_(settings, id, FreeRDP_RedirectionGuidLength,
data, len, sizeof(BYTE));
Expand Down
7 changes: 0 additions & 7 deletions libfreerdp/common/settings_getters.c
Expand Up @@ -1758,9 +1758,6 @@ UINT32 freerdp_settings_get_uint32(const rdpSettings* settings, size_t id)
case FreeRDP_RedirectionPreferType:
return settings->RedirectionPreferType;

case FreeRDP_RedirectionTargetCertificateLength:
return settings->RedirectionTargetCertificateLength;

case FreeRDP_RedirectionTsvUrlLength:
return settings->RedirectionTsvUrlLength;

Expand Down Expand Up @@ -2235,10 +2232,6 @@ BOOL freerdp_settings_set_uint32(rdpSettings* settings, size_t id, UINT32 val)
settings->RedirectionPreferType = cnv.c;
break;

case FreeRDP_RedirectionTargetCertificateLength:
settings->RedirectionTargetCertificateLength = cnv.c;
break;

case FreeRDP_RedirectionTsvUrlLength:
settings->RedirectionTsvUrlLength = cnv.c;
break;
Expand Down
2 changes: 0 additions & 2 deletions libfreerdp/common/settings_str.c
Expand Up @@ -368,8 +368,6 @@ static const struct settings_str_entry settings_map[] = {
"FreeRDP_RedirectionPasswordLength" },
{ FreeRDP_RedirectionPreferType, FREERDP_SETTINGS_TYPE_UINT32,
"FreeRDP_RedirectionPreferType" },
{ FreeRDP_RedirectionTargetCertificateLength, FREERDP_SETTINGS_TYPE_UINT32,
"FreeRDP_RedirectionTargetCertificateLength" },
{ FreeRDP_RedirectionTsvUrlLength, FREERDP_SETTINGS_TYPE_UINT32,
"FreeRDP_RedirectionTsvUrlLength" },
{ FreeRDP_RemoteAppNumIconCacheEntries, FREERDP_SETTINGS_TYPE_UINT32,
Expand Down

0 comments on commit ae8f010

Please sign in to comment.