Fix security issue when reading username and password
PATCH 1/1 Fix security issue when reading username and password
From: Hector Marco-Gisbert <[email protected]>
This patch fixes two integer underflows at:
* grub-core/lib/crypto.c
* grub-core/normal/auth.c
Resolves: CVE-2015-8370
---
grub-core/lib/crypto.c | 2 +- grub-core/normal/auth.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
grub-core/lib/crypto.c +1 -1
@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size)break ; } -if (key =='\b' ) +if (key =='\b' && cur_len) {if (cur_len) cur_len--;
grub-core/normal/auth.c +1 -1
@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size)break ; } -if (key ==GRUB_TERM_BACKSPACE ) +if (key ==GRUB_TERM_BACKSPACE && cur_len) {if (cur_len) {
Signature · 1 line
2.21.0
Quoted 35 lines · Javier Martinez Canillas
From: Hector Marco-Gisbert <[email protected]>
This patch fixes two integer underflows at:
*grub-core/lib/crypto.c
*grub-core/normal/auth.cResolves: CVE-2015-8370
Signed-off-by Hector Marco-Gisbert <[email protected]>Signed-off-by Ismael Ripoll-Ripoll <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/lib/crypto.c | 2 +- grub-core/normal/auth.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)grub-core/lib/crypto.c +1
-1@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size)break ; } -if (key =='\b' ) +if (key =='\b' && cur_len) {if (cur_len) cur_len--;grub-core/normal/auth.c +0
-0
grub-core/normal/auth.c grub_username_get (char buf[], unsigned buf_size) · line 178
Quoted 8 lines
grub-core/normal/auth.c +1
-1@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size)break ; } -if (key ==GRUB_TERM_BACKSPACE ) +if (key ==GRUB_TERM_BACKSPACE && cur_len) {if (cur_len) {
TBH, I do not understand how this patch helps. It only delays continue execution to the next "if (!grub_isprint (key))" if cur_len == 0.
Daniel
Hello Daniel,
The patch prevents that "cur_len" underflows. No negative values for "cur_len" so way to underflow the "cur_len" variable and therefore
I hope this helps,
Hector.
Quoted 50 lines · Daniel Kiper
Quoted 35 lines · Javier Martinez Canillas
From: Hector Marco-Gisbert <[email protected]>
This patch fixes two integer underflows at:
*grub-core/lib/crypto.c
*grub-core/normal/auth.cResolves: CVE-2015-8370
Signed-off-by Hector Marco-Gisbert <[email protected]>Signed-off-by Ismael Ripoll-Ripoll <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/lib/crypto.c | 2 +- grub-core/normal/auth.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)grub-core/lib/crypto.c +1
-1@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size)break ; } -if (key =='\b' ) +if (key =='\b' && cur_len) {if (cur_len) cur_len--;grub-core/normal/auth.c +0
-0grub-core/normal/auth.c grub_username_get (char buf[], unsigned buf_size) · line 178
Quoted 8 lines
grub-core/normal/auth.c +1
-1@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size)break ; } -if (key ==GRUB_TERM_BACKSPACE ) +if (key ==GRUB_TERM_BACKSPACE && cur_len) {if (cur_len) {TBH, I do not understand how this patch helps. It only delays continue execution to the next "if (!grub_isprint (key))" if
cur_len== 0.Daniel
Hello Daniel,
Something went wrong in my last email, what I wanted to say is:
The patch prevents that "cur_len" underflows. No negative values for "cur_len" so no way to underflow the "cur_len" variable and therefore no vulnerability.
Hector.
Quoted 63 lines · Hector Marco
Hello Daniel,
The patch prevents that "
cur_len" underflows. No negative values for "cur_len" so way to underflow the "cur_len" variable and thereforeI hope this helps,
Hector.
Quoted 50 lines · Daniel Kiper
Quoted 35 lines · Javier Martinez Canillas
From: Hector Marco-Gisbert <[email protected]>
This patch fixes two integer underflows at:
*grub-core/lib/crypto.c
*grub-core/normal/auth.cResolves: CVE-2015-8370
Signed-off-by Hector Marco-Gisbert <[email protected]>Signed-off-by Ismael Ripoll-Ripoll <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/lib/crypto.c | 2 +- grub-core/normal/auth.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)grub-core/lib/crypto.c +1
-1@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size)break ; } -if (key =='\b' ) +if (key =='\b' && cur_len) {if (cur_len) cur_len--;grub-core/normal/auth.c +0
-0grub-core/normal/auth.c grub_username_get (char buf[], unsigned buf_size) · line 178
Quoted 8 lines
grub-core/normal/auth.c +1
-1@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size)break ; } -if (key ==GRUB_TERM_BACKSPACE ) +if (key ==GRUB_TERM_BACKSPACE && cur_len) {if (cur_len) {TBH, I do not understand how this patch helps. It only delays continue execution to the next "if (!grub_isprint (key))" if
cur_len== 0.Daniel
Hi Hector,
Quoted 7 lines · Hector Marco
Hello Daniel,
Something went wrong in my last email, what I wanted to say is:
The patch prevents that "
cur_len" underflows. No negative values for "cur_len" so no way to underflow the "cur_len" variable and therefore no vulnerability.
First of all cur_len is unsigned. So, it does not get negative values at all. Though even it was signed I cannot see where in the code it can get negative value. Am I missing something?
Daniel
Quoted 65 lines
Hector.
Quoted 61 lines · Hector Marco
Hello Daniel,
The patch prevents that "
cur_len" underflows. No negative values for "cur_len" so way to underflow the "cur_len" variable and thereforeI hope this helps,
Hector.
Quoted 49 lines · Daniel Kiper
Quoted 35 lines · Javier Martinez Canillas
From: Hector Marco-Gisbert <[email protected]>
This patch fixes two integer underflows at:
*grub-core/lib/crypto.c
*grub-core/normal/auth.cResolves: CVE-2015-8370
Signed-off-by Hector Marco-Gisbert <[email protected]>Signed-off-by Ismael Ripoll-Ripoll <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/lib/crypto.c | 2 +- grub-core/normal/auth.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)grub-core/lib/crypto.c +1
-1@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size)break ; } -if (key =='\b' ) +if (key =='\b' && cur_len) {if (cur_len) cur_len--;grub-core/normal/auth.c +0
-0grub-core/normal/auth.c grub_username_get (char buf[], unsigned buf_size) · line 178
Quoted 8 lines
grub-core/normal/auth.c +1
-1@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size)break ; } -if (key ==GRUB_TERM_BACKSPACE ) +if (key ==GRUB_TERM_BACKSPACE && cur_len) {if (cur_len) {TBH, I do not understand how this patch helps. It only delays continue execution to the next "if (!grub_isprint (key))" if
cur_len== 0.Daniel
Quoted 7 lines · On Thu, 24 Oct 2019, 18:11 Daniel Kiper, <[email protected]> wrote:
Hi Hector,
Quoted 4 lines · Hector Marco
Hello Daniel,
Something went wrong in my last email, what I wanted to say is:
Quoted 8 lines
Quoted 3 lines
The patch prevents that "
cur_len" underflows. No negative values for "cur_len" so no way to underflow the "cur_len" variable and therefore no vulnerability.First of all
cur_lenis unsigned. So, it does not get negative values at all. Though even it was signed I cannot see where in the code it can get negative value. Am I missing something?
It's an old bug that is already fixed. "Signedness" in C is irrelevant. It got negative/very large previously and overwrote some stack. But it's long since fixed
Quoted 75 lines
Daniel
Quoted 17 lines
Hector.
Quoted 13 lines · Hector Marco
Hello Daniel,
The patch prevents that "
cur_len" underflows. No negative values for "cur_len" so way to underflow the "cur_len" variable and thereforeI hope this helps,
Hector.
Quoted 1 line · Daniel Kiper
On Fri, Oct 18, 2019 at 02:39:01PM +0200, Javier Martinez Canillas
Quoted 47 lines · wrote:
Quoted 47 lines
Quoted 47 lines
Quoted 35 lines
From: Hector Marco-Gisbert <[email protected]>
This patch fixes two integer underflows at:
*grub-core/lib/crypto.c
*grub-core/normal/auth.cResolves: CVE-2015-8370
Signed-off-by Hector Marco-Gisbert <[email protected]>Signed-off-by Ismael Ripoll-Ripoll <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/lib/crypto.c | 2 +- grub-core/normal/auth.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)grub-core/lib/crypto.c +1
-1@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size)break ; } -if (key =='\b' ) +if (key =='\b' && cur_len) {if (cur_len) cur_len--;grub-core/normal/auth.c +0
-0grub-core/normal/auth.c grub_username_get (char buf[], unsigned buf_size) · line 178
Quoted 8 lines
grub-core/normal/auth.c +1
-1@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size)break ; } -if (key ==GRUB_TERM_BACKSPACE ) +if (key ==GRUB_TERM_BACKSPACE && cur_len) {if (cur_len) {TBH, I do not understand how this patch helps. It only delays continue execution to the next "if (!grub_isprint (key))" if
cur_len== 0.Quoted 1 line
Quoted 1 line
Quoted 1 line
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Hi Daniel,
We wrote a blog entry explaining the problem and how it can be exploited:
http://hmarco.org/bugs/CVE-2015-8370-Grub2-authentication-bypass.html
The underflow (although it is unsigned) takes effect in the function grub_memset.
The exploitation is extremely hard to do but possible, as shown in the blog.
Regards,
Ismael.
Quoted 82 lines · Daniel Kiper
Hi Hector,
Quoted 7 lines · Hector Marco
Hello Daniel,
Something went wrong in my last email, what I wanted to say is:
The patch prevents that "
cur_len" underflows. No negative values for "cur_len" so no way to underflow the "cur_len" variable and therefore no vulnerability.First of all
cur_lenis unsigned. So, it does not get negative values at all. Though even it was signed I cannot see where in the code it can get negative value. Am I missing something?Daniel
Quoted 65 lines
Hector.
Quoted 61 lines · Hector Marco
Hello Daniel,
The patch prevents that "
cur_len" underflows. No negative values for "cur_len" so way to underflow the "cur_len" variable and thereforeI hope this helps,
Hector.
Quoted 49 lines · Daniel Kiper
Quoted 35 lines · Javier Martinez Canillas
From: Hector Marco-Gisbert <[email protected]>
This patch fixes two integer underflows at:
*grub-core/lib/crypto.c
*grub-core/normal/auth.cResolves: CVE-2015-8370
Signed-off-by Hector Marco-Gisbert <[email protected]>Signed-off-by Ismael Ripoll-Ripoll <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/lib/crypto.c | 2 +- grub-core/normal/auth.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)grub-core/lib/crypto.c +1
-1@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size)break ; } -if (key =='\b' ) +if (key =='\b' && cur_len) {if (cur_len) cur_len--;grub-core/normal/auth.c +0
-0grub-core/normal/auth.c grub_username_get (char buf[], unsigned buf_size) · line 178
Quoted 8 lines
grub-core/normal/auth.c +1
-1@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size)break ; } -if (key ==GRUB_TERM_BACKSPACE ) +if (key ==GRUB_TERM_BACKSPACE && cur_len) {if (cur_len) {TBH, I do not understand how this patch helps. It only delays continue execution to the next "if (!grub_isprint (key))" if
cur_len== 0.Daniel
Hi Daniel,
Sorry I didn't pay to much attention to this. Yes, it is unsigned but the underflow is still there.
Maybe what you are missing is that this underflowed value (cur_len) is later used in grub_memset( buf + cur_len, 0, buf_size - cur_len); which results in a buffer overflow (not underflow this time).
As Ismael say, please read the entry we wrote in 2015
http://hmarco.org/bugs/CVE-2015-8370-Grub2-authentication-bypass.html
Best regards,
Hector.
Quoted 82 lines · Daniel Kiper
Hi Hector,
Quoted 7 lines · Hector Marco
Hello Daniel,
Something went wrong in my last email, what I wanted to say is:
The patch prevents that "
cur_len" underflows. No negative values for "cur_len" so no way to underflow the "cur_len" variable and therefore no vulnerability.First of all
cur_lenis unsigned. So, it does not get negative values at all. Though even it was signed I cannot see where in the code it can get negative value. Am I missing something?Daniel
Quoted 65 lines
Hector.
Quoted 61 lines · Hector Marco
Hello Daniel,
The patch prevents that "
cur_len" underflows. No negative values for "cur_len" so way to underflow the "cur_len" variable and thereforeI hope this helps,
Hector.
Quoted 49 lines · Daniel Kiper
Quoted 35 lines · Javier Martinez Canillas
From: Hector Marco-Gisbert <[email protected]>
This patch fixes two integer underflows at:
*grub-core/lib/crypto.c
*grub-core/normal/auth.cResolves: CVE-2015-8370
Signed-off-by Hector Marco-Gisbert <[email protected]>Signed-off-by Ismael Ripoll-Ripoll <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/lib/crypto.c | 2 +- grub-core/normal/auth.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)grub-core/lib/crypto.c +1
-1@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size)break ; } -if (key =='\b' ) +if (key =='\b' && cur_len) {if (cur_len) cur_len--;grub-core/normal/auth.c +0
-0grub-core/normal/auth.c grub_username_get (char buf[], unsigned buf_size) · line 178
Quoted 8 lines
grub-core/normal/auth.c +1
-1@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size)break ; } -if (key ==GRUB_TERM_BACKSPACE ) +if (key ==GRUB_TERM_BACKSPACE && cur_len) {if (cur_len) {TBH, I do not understand how this patch helps. It only delays continue execution to the next "if (!grub_isprint (key))" if
cur_len== 0.Daniel
This has been committed years ago:
https://git.savannah.gnu.org/cgit/grub.git/commit/grub-core/lib/crypto.c?id=451d80e52d851432e109771bb8febafca7a5f1f2
Please contact whoever you got your GRUB from
Quoted 52 lines · Javier Martinez Canillas
From: Hector Marco-Gisbert <[email protected]>
This patch fixes two integer underflows at:
*grub-core/lib/crypto.c
*grub-core/normal/auth.cResolves: CVE-2015-8370
Signed-off-by Hector Marco-Gisbert <[email protected]>Signed-off-by Ismael Ripoll-Ripoll <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>---
grub-core/lib/crypto.c | 2 +- grub-core/normal/auth.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)grub-core/lib/crypto.c +1
-1@@ -468,7 +468,7 @@ grub_password_get (char buf[], unsigned buf_size)break ; } -if (key =='\b' ) +if (key =='\b' && cur_len) {if (cur_len) cur_len--;grub-core/normal/auth.c +1
-2@@ -172,7 +172,7 @@ grub_username_get (char buf[], unsigned buf_size)break ; } -if (key ==GRUB_TERM_BACKSPACE ) +if (key ==GRUB_TERM_BACKSPACE && cur_len) {if (cur_len) { --2.21.0
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko
Hello Vladimir,
Quoted 4 lines · Vladimir 'phcoder' Serbinenko
This has been committed years ago:
https://git.savannah.gnu.org/cgit/grub.git/commit/grub-core/lib/crypto.c?id=451d80e52d851432e109771bb8febafca7a5f1f2
Please contact whoever you got your GRUB from
Oh I see. Since is not the same patch than the one mentioned in their post [0], I didn't realize that the fix has already landed. Thanks for pointing it out.
I'll just drop this patch then.
[0]: http://hmarco.org/bugs/patches/0001-Fix-CVE-2015-8370-Grub2-user-pass-vulnerability.patch
Best regards,
Signature · 3 lines
Javier Martinez Canillas Software Engineer - Desktop Hardware Enablement Red Hat