diff options
| author | Vijay Anusuri <vanusuri@mvista.com> | 2024-09-20 15:45:31 +0530 |
|---|---|---|
| committer | Armin Kuster <akuster808@gmail.com> | 2024-10-13 11:13:42 -0400 |
| commit | 86878f61d1c1d61119035c7e06efc2757f519474 (patch) | |
| tree | d00a6277a3af7531f993981c10746e91dc5b549b | |
| parent | 4d0efedaa6bf85367738e6ca97a71f132a3d0ec5 (diff) | |
| download | meta-openembedded-86878f61d1c1d61119035c7e06efc2757f519474.tar.gz | |
tgt: Security fix for CVE-2024-45751
Upstream-Status: Backport from https://github.com/fujita/tgt/commit/abd8e0d987ab56013d360077202bf2aca20a42dd
Reference: https://ubuntu.com/security/CVE-2024-45751
Signed-off-by: Vijay Anusuri <vanusuri@mvista.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
| -rw-r--r-- | meta-networking/recipes-extended/tgt/files/CVE-2024-45751.patch | 68 | ||||
| -rw-r--r-- | meta-networking/recipes-extended/tgt/tgt_git.bb | 1 |
2 files changed, 69 insertions, 0 deletions
diff --git a/meta-networking/recipes-extended/tgt/files/CVE-2024-45751.patch b/meta-networking/recipes-extended/tgt/files/CVE-2024-45751.patch new file mode 100644 index 0000000000..e7f09c7e92 --- /dev/null +++ b/meta-networking/recipes-extended/tgt/files/CVE-2024-45751.patch | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | From abd8e0d987ab56013d360077202bf2aca20a42dd Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Richard Weinberger <richard@nod.at> | ||
| 3 | Date: Tue, 3 Sep 2024 16:14:58 +0200 | ||
| 4 | Subject: [PATCH] chap: Use proper entropy source | ||
| 5 | |||
| 6 | The challenge sent to the initiator is based on a poor | ||
| 7 | source of randomness, it uses rand() without seeding it by srand(). | ||
| 8 | So the glibc PRNG is always seeded with 1 and as a consequence the | ||
| 9 | sequence of challenges is always the same. | ||
| 10 | |||
| 11 | An attacker which is able to monitor network traffic can apply a replay | ||
| 12 | attack to bypass the CHAP authentication. All the attacker has to do | ||
| 13 | is waiting for the server or the service to restart and replay with a | ||
| 14 | previously record CHAP session which fits into the sequence. | ||
| 15 | |||
| 16 | To overcome the issue, use getrandom() to query the kernel random | ||
| 17 | number generator. | ||
| 18 | Also always send a challenge of length CHAP_CHALLENGE_MAX, there is no | ||
| 19 | benefit in sending a variable length challenge. | ||
| 20 | |||
| 21 | Signed-off-by: Richard Weinberger <richard@nod.at> | ||
| 22 | |||
| 23 | Upstream-Status: Backport [https://github.com/fujita/tgt/commit/abd8e0d987ab56013d360077202bf2aca20a42dd] | ||
| 24 | CVE: CVE-2024-45751 | ||
| 25 | Signed-off-by: Vijay Anusuri <vanusuri@mvista.com> | ||
| 26 | --- | ||
| 27 | usr/iscsi/chap.c | 12 +++++------- | ||
| 28 | 1 file changed, 5 insertions(+), 7 deletions(-) | ||
| 29 | |||
| 30 | diff --git a/usr/iscsi/chap.c b/usr/iscsi/chap.c | ||
| 31 | index aa0fc671..b89ecabd 100644 | ||
| 32 | --- a/usr/iscsi/chap.c | ||
| 33 | +++ b/usr/iscsi/chap.c | ||
| 34 | @@ -28,6 +28,7 @@ | ||
| 35 | #include <stdio.h> | ||
| 36 | #include <stdlib.h> | ||
| 37 | #include <string.h> | ||
| 38 | +#include <sys/random.h> | ||
| 39 | |||
| 40 | #include "iscsid.h" | ||
| 41 | #include "tgtd.h" | ||
| 42 | @@ -359,22 +360,19 @@ static int chap_initiator_auth_create_challenge(struct iscsi_connection *conn) | ||
| 43 | sprintf(text, "%u", (unsigned char)conn->auth.chap.id); | ||
| 44 | text_key_add(conn, "CHAP_I", text); | ||
| 45 | |||
| 46 | - /* | ||
| 47 | - * FIXME: does a random challenge length provide any benefits security- | ||
| 48 | - * wise, or should we rather always use the max. allowed length of | ||
| 49 | - * 1024 for the (unencoded) challenge? | ||
| 50 | - */ | ||
| 51 | - conn->auth.chap.challenge_size = (rand() % (CHAP_CHALLENGE_MAX / 2)) + CHAP_CHALLENGE_MAX / 2; | ||
| 52 | + conn->auth.chap.challenge_size = CHAP_CHALLENGE_MAX; | ||
| 53 | |||
| 54 | conn->auth.chap.challenge = malloc(conn->auth.chap.challenge_size); | ||
| 55 | if (!conn->auth.chap.challenge) | ||
| 56 | return CHAP_TARGET_ERROR; | ||
| 57 | |||
| 58 | + if (getrandom(conn->auth.chap.challenge, conn->auth.chap.challenge_size, 0) != conn->auth.chap.challenge_size) | ||
| 59 | + return CHAP_TARGET_ERROR; | ||
| 60 | + | ||
| 61 | p = text; | ||
| 62 | strcpy(p, "0x"); | ||
| 63 | p += 2; | ||
| 64 | for (i = 0; i < conn->auth.chap.challenge_size; i++) { | ||
| 65 | - conn->auth.chap.challenge[i] = rand(); | ||
| 66 | sprintf(p, "%.2hhx", conn->auth.chap.challenge[i]); | ||
| 67 | p += 2; | ||
| 68 | } | ||
diff --git a/meta-networking/recipes-extended/tgt/tgt_git.bb b/meta-networking/recipes-extended/tgt/tgt_git.bb index 42141cb72d..28ea44893b 100644 --- a/meta-networking/recipes-extended/tgt/tgt_git.bb +++ b/meta-networking/recipes-extended/tgt/tgt_git.bb | |||
| @@ -11,6 +11,7 @@ SRC_URI = "git://github.com/fujita/tgt.git;branch=master;protocol=https \ | |||
| 11 | file://0001-Correct-the-path-of-header-files-check-in-Yocto-buil.patch \ | 11 | file://0001-Correct-the-path-of-header-files-check-in-Yocto-buil.patch \ |
| 12 | file://0001-usr-Makefile-WARNING-fix.patch \ | 12 | file://0001-usr-Makefile-WARNING-fix.patch \ |
| 13 | file://usr-Makefile-apply-LDFLAGS-to-all-executables.patch \ | 13 | file://usr-Makefile-apply-LDFLAGS-to-all-executables.patch \ |
| 14 | file://CVE-2024-45751.patch \ | ||
| 14 | " | 15 | " |
| 15 | SRC_URI += "file://tgtd.init \ | 16 | SRC_URI += "file://tgtd.init \ |
| 16 | file://tgtd.service \ | 17 | file://tgtd.service \ |
