-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GPG intermittent self-test failure #3543
Comments
The ticket contains two unrelated issues. If the leak is on purpose, just close the ticket. |
Leak fixed now. What about the self-test fail? |
It is intermittent. Happens once in a while. |
Then let's check this out |
These failures have been plaguing the GPG format for a long time it seems. I was never able to get to the bottom of the issue earlier. Earlier, I was looking for the problem in the It now seems that the problem exists within the base CPU code itself? This makes sense to me and would explain those weird |
I bet something in OpenSSL is not thread safe. Have we ever seen problems with a non-omp build? |
I cannot reproduce the GPG format failures with the following command,
I am running Ubuntu 18.04.1 64-bit here. |
@claudioandre-br what version of OpenSSL was that? |
|
@claudioandre-br How do I reproduce this problem locally? Are you able to reproduce the problem on Ubuntu 18.0.1 LTS or something similar? |
Try |
I am running
I see no failures at all. I tried @claudioandre-br Can you please give some pointers on how to reproduce this bug? |
Looks like this (or similar) is still an issue, |
On the above system, I am unable to trigger the issue with The failure is usually on |
I could also get it to fail in an
|
This hack didn't catch anything: +++ b/src/gpg_common_plug.c
@@ -1220,6 +1220,10 @@ int gpg_common_check(unsigned char *keydata, int ks)
// other things (like mpz integer creation) are needed, we know that
// our sizes will not overflow.
out = mem_alloc((gpg_common_cur_salt->datalen) + 0x10000);
+ unsigned char *out_last = &out[gpg_common_cur_salt->datalen + 0x10000 - 1];
+ *out_last = 'c';
+#undef MEM_FREE
+#define MEM_FREE(out) { assert(*out_last == 'c'); free(out); out = NULL; }
// Quick Hack
if (!gpg_common_cur_salt->symmetric_mode)
memcpy(ivec, gpg_common_cur_salt->iv, gpg_common_blockSize(gpg_common_cur_salt->cipher_algorithm)); |
In fact, even this works: +++ b/src/gpg_common_plug.c
@@ -1220,6 +1220,10 @@ int gpg_common_check(unsigned char *keydata, int ks)
// other things (like mpz integer creation) are needed, we know that
// our sizes will not overflow.
out = mem_alloc((gpg_common_cur_salt->datalen) + 0x10000);
+ unsigned char *out_last = &out[gpg_common_cur_salt->datalen];
+ *out_last = 'c';
+#undef MEM_FREE
+#define MEM_FREE(out) { assert(*out_last == 'c'); free(out); out = NULL; } So the extra 0x10000 looks unneeded (and in general it was a bad idea to be allocating/freeing memory during cracking). |
This and many other over-allocations were added by JimF in 7147798 in 2016, with commit title "gpg: bugs found in -test-full=0 using ASAN". |
This triggers the same for Edit: perhaps I am wrong - I actually don't know if |
So I went to patch the test vectors in the source. With only the symmetric tests left (last 7 test vectors), the testing is really quick and it didn't fail for me. With the opposite change (removing these symmetric tests), after a while I got:
which is the second time I see this format fail on |
The two |
OK, this over-allocation was in fact needed - we have major over-reads (being reads, they were not caught by my canary). About the smallest that works is 0x2700 extra bytes. I wondered if these over-read of uninitialized memory could result in the |
I didn't look into this further yet, but just to write down my understanding from earlier today: when trying usually wrong passwords, we end up decrypting what isn't a valid key. Yet it has embedded length fields in it. Those may end up indicating bignums of up to 64 kbit each. This is why the over-reads. Then we pass those unusually huge bignums into OpenSSL routines, thereby torturing them (and wasting lots of CPU cycles, too, which I guess we'd rather avoid by detecting the over-reads instead). We also ask |
I reviewed current OpenSSL code - looks correct even for such inputs. Our issue appears to be different. We have larger I wonder why ASan does not trigger. The struct ends in Anyway, patching the code to skip this field without writing it to |
Importantly, such copying frequently overflowed the d[] array with a value that we skip anyway. Fixes openwall#3543
Importantly, such copying frequently overflowed the d[] array with a value that we skip anyway. Fixes openwall#3543
That's not how ASan works, so was probably a wrong guess. Another probably wrong guess is the overwrite is somehow contained to the struct (which is valid behavior in C), but results in us making incorrect calls into OpenSSL later (because of the overwritten salt data, which maybe wouldn't have passed our |
Intermitent
. Inside my Circle
The following issue is not GPG related. It is related to batch mode.
. GPG random test
. Or, you can also use
../run/john alltests.in --max-run=30 --format=sha512crypt
The text was updated successfully, but these errors were encountered: