freerdp: patch CVE-2022-24883
PATCH 1/5 freerdp: patch CVE-2022-24883
Details: https://nvd.nist.gov/vuln/detail/CVE-2022-24883
Pick the patch that is mentioned in teh NVD advisory.
--- .../freerdp/freerdp/CVE-2022-24883.patch | 102 ++++++++++++++++++ .../recipes-support/freerdp/freerdp_2.6.1.bb | 9 +- 2 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 meta-oe/recipes-support/freerdp/freerdp/CVE-2022-24883.patch
meta-oe/recipes-support/freerdp/freerdp/CVE-2022-24883.patch new file +102 -0
@@ -0,0 +1,102 @@ +From 3912ccfe5bac0db647b9e1c26b50e75055aee4b9 Mon Sep 17 00:00:00 2001 +From: akallabeth <[email protected]> +Date: Fri, 22 Apr 2022 14:42:11 +0200 +Subject: [PATCH] Cleaned up ntlm_fetch_ntlm_v2_hash + +(cherry picked from commit 4661492e5a617199457c8074bad22f766a116cdc) + +CVE: CVE-2022-24883 +Upstream-Status: Backport [https://github.com/FreeRDP/FreeRDP/commit/6f473b273a4b6f0cb6aca32b95e22fd0de88e144] +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + winpr/libwinpr/sspi/NTLM/ntlm_compute.c | 60 ++++++++++--------------- + 1 file changed, 24 insertions(+), 36 deletions(-) + +diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_compute.c b/winpr/libwinpr/sspi/NTLM/ntlm_compute.c +index dbd7f7fb0..48c07d5c1 100644 +--- a/winpr/libwinpr/sspi/NTLM/ntlm_compute.c ++++ b/winpr/libwinpr/sspi/NTLM/ntlm_compute.c +@@ -206,59 +206,47 @@ void ntlm_generate_timestamp(NTLM_CONTEXT* context) + ntlm_current_time(context->Timestamp); + } + +-static int ntlm_fetch_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash) ++static BOOL ntlm_fetch_ntlm_v2_hash(NTLM_CONTEXT* context, BYTE* hash) + { +- WINPR_SAM* sam; +- WINPR_SAM_ENTRY* entry; ++ BOOL rc = FALSE; ++ WINPR_SAM* sam = NULL; ++ WINPR_SAM_ENTRY* entry = NULL; + SSPI_CREDENTIALS* credentials = context->credentials; + sam = SamOpen(context->SamFile, TRUE); + + if (!sam) +- return -1; ++ goto fail; + + entry = SamLookupUserW( +- sam, (LPWSTR)credentials->identity.User, credentials->identity.UserLength * 2, +- (LPWSTR)credentials->identity.Domain, credentials->identity.DomainLength * 2); ++ sam, (LPWSTR)credentials->identity.User, credentials->identity.UserLength * sizeof(WCHAR), ++ (LPWSTR)credentials->identity.Domain, credentials->identity.DomainLength * sizeof(WCHAR)); + +- if (entry) ++ if (!entry) + { +-#ifdef WITH_DEBUG_NTLM +- WLog_DBG(TAG, "NTLM Hash:"); +- winpr_HexDump(TAG, WLOG_DEBUG, entry->NtHash, 16); +-#endif +- NTOWFv2FromHashW(entry->NtHash, (LPWSTR)credentials->identity.User, +- credentials->identity.UserLength * 2, (LPWSTR)credentials->identity.Domain, +- credentials->identity.DomainLength * 2, (BYTE*)hash); +- SamFreeEntry(sam, entry); +- SamClose(sam); +- return 1; ++ entry = SamLookupUserW(sam, (LPWSTR)credentials->identity.User, ++ credentials->identity.UserLength * sizeof(WCHAR), NULL, 0); + } + +- entry = SamLookupUserW(sam, (LPWSTR)credentials->identity.User, +- credentials->identity.UserLength * 2, NULL, 0); +- +- if (entry) +- { ++ if (!entry) ++ goto fail; + #ifdef WITH_DEBUG_NTLM + WLog_DBG(TAG, "NTLM Hash:"); + winpr_HexDump(TAG, WLOG_DEBUG, entry->NtHash, 16); + #endif +- NTOWFv2FromHashW(entry->NtHash, (LPWSTR)credentials->identity.User, +- credentials->identity.UserLength * 2, (LPWSTR)credentials->identity.Domain, +- credentials->identity.DomainLength * 2, (BYTE*)hash); +- SamFreeEntry(sam, entry); +- SamClose(sam); +- return 1; +- } +- else +- { +- SamClose(sam); +- WLog_ERR(TAG, "Error: Could not find user in SAM database"); +- return 0; +- } ++ NTOWFv2FromHashW(entry->NtHash, (LPWSTR)credentials->identity.User, ++ credentials->identity.UserLength * sizeof(WCHAR), ++ (LPWSTR)credentials->identity.Domain, ++ credentials->identity.DomainLength * sizeof(WCHAR), (BYTE*)hash); ++ ++ rc = TRUE; + ++fail: ++ SamFreeEntry(sam, entry); + SamClose(sam); +- return 1; ++ if (!rc) ++ WLog_ERR(TAG, "Error: Could not find user in SAM database"); ++ ++ return rc; + } + + static int ntlm_convert_password_hash(NTLM_CONTEXT* context, BYTE* hash)
meta-oe/recipes-support/freerdp/freerdp_2.6.1.bb +5 -4
@@ -15,10 +15,11 @@ PKGV = "${GITPKGVTAG}" SRCREV = "658a72980f6e93241d927c46cfa664bf2547b8b1" SRC_URI = "git://github.com/FreeRDP/FreeRDP.git;branch=stable-2.0;protocol=https \ - file://winpr-makecert-Build-with-install-RPATH.patch \ - file://CVE-2022-39316.patch \ - file://CVE-2022-39318-39319.patch \ -" + file://winpr-makecert-Build-with-install-RPATH.patch \ + file://CVE-2022-39316.patch \ + file://CVE-2022-39318-39319.patch \ + file://CVE-2022-24883.patch \ + " S = "${WORKDIR}/git"
PATCH 2/5 freerdp: patch CVE-2022-39282
Details: https://nvd.nist.gov/vuln/detail/CVE-2022-39282
Pick the patch that's description matches the CVE description. (Debian also considers the same patch[1] the fix)
[1]: https://security-tracker.debian.org/tracker/CVE-2022-39282
--- .../freerdp/freerdp/CVE-2022-39282.patch | 38 +++++++++++++++++++ .../recipes-support/freerdp/freerdp_2.6.1.bb | 1 + 2 files changed, 39 insertions(+) create mode 100644 meta-oe/recipes-support/freerdp/freerdp/CVE-2022-39282.patch
meta-oe/recipes-support/freerdp/freerdp/CVE-2022-39282.patch new file +38 -0
@@ -0,0 +1,38 @@ +From 2dc894cc293a2c4b64176ea0d47587444f9ce9e0 Mon Sep 17 00:00:00 2001 +From: akallabeth <[email protected]> +Date: Thu, 6 Oct 2022 09:12:40 +0200 +Subject: [PATCH] Fix length checks in parallel driver + +The length requested was not checked against the length read from +the port. + +(cherry picked from commit 094cc5a4596c299595b732effd59ee149181fd61) + +CVE: CVE-2022-39282 +Upstream-Status: Backport [https://github.com/FreeRDP/FreeRDP/commit/60aac2abf0740dd36b62712fba91498fd6e055fe] +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + channels/parallel/client/parallel_main.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c +index af3e82703..993605a65 100644 +--- a/channels/parallel/client/parallel_main.c ++++ b/channels/parallel/client/parallel_main.c +@@ -159,7 +159,7 @@ static UINT parallel_process_irp_read(PARALLEL_DEVICE* parallel, IRP* irp) + return ERROR_INVALID_DATA; + Stream_Read_UINT32(irp->input, Length); + Stream_Read_UINT64(irp->input, Offset); +- buffer = (BYTE*)malloc(Length); ++ buffer = (BYTE*)calloc(Length, sizeof(BYTE)); + + if (!buffer) + { +@@ -178,6 +178,7 @@ static UINT parallel_process_irp_read(PARALLEL_DEVICE* parallel, IRP* irp) + } + else + { ++ Length = status; + } + + Stream_Write_UINT32(irp->output, Length);
meta-oe/recipes-support/freerdp/freerdp_2.6.1.bb +1 -0
@@ -19,6 +19,7 @@ SRC_URI = "git://github.com/FreeRDP/FreeRDP.git;branch=stable-2.0;protocol=https file://CVE-2022-39316.patch \ file://CVE-2022-39318-39319.patch \ file://CVE-2022-24883.patch \ + file://CVE-2022-39282.patch \ " S = "${WORKDIR}/git"
PATCH 3/5 freerdp: mark CVE-2022-39317 patched
In reply to Gyorgy SarvariDetails: https://nvd.nist.gov/vuln/detail/CVE-2022-39317
Both Ubuntu[1] and Red Hat[2] confirms that this vulenrability is fixed by the same patch as CVE-2022-39316.
Therefore add this CVE ID to the patch's tag also.
[1]: https://ubuntu.com/security/CVE-2022-39317
[2]: https://bugzilla.redhat.com/show_bug.cgi?id=2143643
--- meta-oe/recipes-support/freerdp/freerdp/CVE-2022-39316.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta-oe/recipes-support/freerdp/freerdp/CVE-2022-39316.patch +1 -1
@@ -1,5 +1,5 @@ https://github.com/FreeRDP/FreeRDP/commit/e865c24efc40ebc52e75979c94cdd4ee2c1495b0 -CVE: CVE-2022-39316 +CVE: CVE-2022-39316 CVE-2022-39317 Upstream-Status: Backport Signed-off-by: Lee Chee Yang <[email protected]>
PATCH 4/5 freerdp: patch CVE-2022-39320
In reply to Gyorgy SarvariDetails: https://nvd.nist.gov/vuln/detail/CVE-2022-39320
Take the patch that Debian has determined[1] to solve the issue.
[1]: https://security-tracker.debian.org/tracker/CVE-2022-39320
--- .../freerdp/freerdp/CVE-2022-39320.patch | 33 +++++++++++++++++++ .../recipes-support/freerdp/freerdp_2.6.1.bb | 1 + 2 files changed, 34 insertions(+) create mode 100644 meta-oe/recipes-support/freerdp/freerdp/CVE-2022-39320.patch
meta-oe/recipes-support/freerdp/freerdp/CVE-2022-39320.patch new file +33 -0
@@ -0,0 +1,33 @@ +From e9bbd8de33f8640abbd578fb511180853c4dccba Mon Sep 17 00:00:00 2001 +From: akallabeth <[email protected]> +Date: Thu, 13 Oct 2022 08:36:26 +0200 +Subject: [PATCH] Ensure urb_create_iocompletion uses size_t for calculation + +(cherry picked from commit de7e0f062ee53d00b4a966a43855a716e3478150) + +CVE: CVE-2022-39320 +Upstream-Status: Backport [https://github.com/FreeRDP/FreeRDP/commit/68c6a8c1878b5294aecb04d5e27531a720b3793f] +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + channels/urbdrc/client/data_transfer.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/channels/urbdrc/client/data_transfer.c b/channels/urbdrc/client/data_transfer.c +index 9a44e6e09..82fdc729e 100644 +--- a/channels/urbdrc/client/data_transfer.c ++++ b/channels/urbdrc/client/data_transfer.c +@@ -97,7 +97,13 @@ static wStream* urb_create_iocompletion(UINT32 InterfaceField, UINT32 MessageId, + UINT32 OutputBufferSize) + { + const UINT32 InterfaceId = (STREAM_ID_PROXY << 30) | (InterfaceField & 0x3FFFFFFF); +- wStream* out = Stream_New(NULL, OutputBufferSize + 28); ++ ++#if UINT32_MAX >= SIZE_MAX ++ if (OutputBufferSize > UINT32_MAX - 28ull) ++ return NULL; ++#endif ++ ++ wStream* out = Stream_New(NULL, OutputBufferSize + 28ull); + + if (!out) + return NULL;
meta-oe/recipes-support/freerdp/freerdp_2.6.1.bb +1 -0
@@ -20,6 +20,7 @@ SRC_URI = "git://github.com/FreeRDP/FreeRDP.git;branch=stable-2.0;protocol=https file://CVE-2022-39318-39319.patch \ file://CVE-2022-24883.patch \ file://CVE-2022-39282.patch \ + file://CVE-2022-39320.patch \ " S = "${WORKDIR}/git"
PATCH 5/5 freerdp: patch CVE-2023-39350
In reply to Gyorgy SarvariDetails: https://nvd.nist.gov/vuln/detail/CVE-2023-39350
Pick the patch that's mentioned by the NVD advisory.
--- .../freerdp/freerdp/CVE-2023-39350.patch | 53 +++++++++++++++++++ .../recipes-support/freerdp/freerdp_2.6.1.bb | 1 + 2 files changed, 54 insertions(+) create mode 100644 meta-oe/recipes-support/freerdp/freerdp/CVE-2023-39350.patch
meta-oe/recipes-support/freerdp/freerdp/CVE-2023-39350.patch new file +53 -0
@@ -0,0 +1,53 @@ +From 944994cb41d62ea893bd8bdaf436e97f42965de0 Mon Sep 17 00:00:00 2001 +From: Armin Novak <[email protected]> +Date: Sat, 5 Aug 2023 08:57:28 +0200 +Subject: [PATCH] check indices are within range + +reported by @pwn2carr + +CVE: CVE-2023-39350 +Upstream-Status: Backport [https://github.com/FreeRDP/FreeRDP/commit/e204fc8be5a372626b13f66daf2abafe71dbc2dc] +Signed-off-by: Gyorgy Sarvari <[email protected]> +--- + libfreerdp/codec/rfx.c | 25 ++++++++++++++++++++++++- + 1 file changed, 24 insertions(+), 1 deletion(-) + +diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c +index 8c65e7508..998a7aa56 100644 +--- a/libfreerdp/codec/rfx.c ++++ b/libfreerdp/codec/rfx.c +@@ -932,10 +932,33 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa + rc = FALSE; + break; + } +- + Stream_Read_UINT8(&sub, tile->quantIdxY); /* quantIdxY (1 byte) */ + Stream_Read_UINT8(&sub, tile->quantIdxCb); /* quantIdxCb (1 byte) */ + Stream_Read_UINT8(&sub, tile->quantIdxCr); /* quantIdxCr (1 byte) */ ++ if (tile->quantIdxY >= context->numQuant) ++ { ++ WLog_Print(context->priv->log, WLOG_ERROR, ++ "quantIdxY %" PRIu8 " >= numQuant %" PRIu8, tile->quantIdxY, ++ context->numQuant); ++ rc = FALSE; ++ break; ++ } ++ if (tile->quantIdxCb >= context->numQuant) ++ { ++ WLog_Print(context->priv->log, WLOG_ERROR, ++ "quantIdxCb %" PRIu8 " >= numQuant %" PRIu8, tile->quantIdxCb, ++ context->numQuant); ++ rc = FALSE; ++ break; ++ } ++ if (tile->quantIdxCr >= context->numQuant) ++ { ++ WLog_Print(context->priv->log, WLOG_ERROR, ++ "quantIdxCr %" PRIu8 " >= numQuant %" PRIu8, tile->quantIdxCr, ++ context->numQuant); ++ rc = FALSE; ++ break; ++ } + Stream_Read_UINT16(&sub, tile->xIdx); /* xIdx (2 bytes) */ + Stream_Read_UINT16(&sub, tile->yIdx); /* yIdx (2 bytes) */ + Stream_Read_UINT16(&sub, tile->YLen); /* YLen (2 bytes) */
meta-oe/recipes-support/freerdp/freerdp_2.6.1.bb +1 -0
@@ -21,6 +21,7 @@ SRC_URI = "git://github.com/FreeRDP/FreeRDP.git;branch=stable-2.0;protocol=https file://CVE-2022-24883.patch \ file://CVE-2022-39282.patch \ file://CVE-2022-39320.patch \ + file://CVE-2023-39350.patch \ " S = "${WORKDIR}/git"