Live data from Hacker News

The Heartbleed Challenge

cloudflarechallenge.com

51–60 of 125 posts

Re: The Heartbleed Challenge

#51

Earlier quoted context omitted.

It seems like a "feature" that you'd want your process to store the private key material as low as possible in the address space so that arbitrary read overruns don't run the risk of hitting it. It seems to just accidentally be this way in nginx, but I wonder if it should just be another (tiny) layer in the overall security design.

Shouldn't they be at the top of the address space then overruns would never hit them as they'd start below or does it not work like that.

Or you can put in a memory area with unmapped sections on both sides if you are paranoid.

Re: The Heartbleed Challenge

#52

Earlier quoted context omitted.

It seems like a "feature" that you'd want your process to store the private key material as low as possible in the address space so that arbitrary read overruns don't run the risk of hitting it. It seems to just accidentally be this way in nginx, but I wonder if it should just be another (tiny) layer in the overall security design.

Shouldn't they be at the top of the address space then overruns would never hit them as they'd start below or does it not work like that.

The bug is reading 64k from x -> x+64k. You'd want the key as low as possible in memory so the chance of the heap implementation allocating a request below it (thus allowing the +64k to overlap into the key) is next to nil.

Re: The Heartbleed Challenge

#53

Earlier quoted context omitted.

Shouldn't they be at the top of the address space then overruns would never hit them as they'd start below or does it not work like that.

Or you can put in a memory area with unmapped sections on both sides if you are paranoid.

True.. I wonder if any specs/certifications actually require something like that. Typically I mostly use tricks like that to track down bugs, but there's nothing wrong with using it in production for something like a single key/cert alloc. It becomes a bit unwieldy if you have lots of things to protect. (Especially on machines with 64k pages :))

Re: The Heartbleed Challenge

#54
Note that by visiting, your IP and referer become accessible by anyone running an heartbleed exploit:

  93.142.x.x - - [11/Apr/2014:10:44:36 -0400] "GET /heartbleed HTTP/1.1" 200 1148 "https://news.ycombinator.com/" "Mozilla/5.0 (Windows NT 6.1; WOW64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36"

Re: The Heartbleed Challenge

#55
post #9

For the command to match the description, shouldn't that be "echo -n"? Otherwise the signed string would include a trailing newline. I do not expect this will make a material difference to the challenge - presumably you used the quoted commands to generate the answer.

Maybe they changed the description in the meantime, it now includes the newline, saying: "Proof I have your key\n"

Re: The Heartbleed Challenge

#56
so i assume any intermediate values from the RSA computations will end up in the heap and may be accessible by an attacker. is it possible to reconstruct the key from these values?

i could be missing something but it looks like signing does m mod p and m mod q and part of these operations involves doing a left shift on the divisor (p, q) and this is allocated to a temporary buffer. if these buffers are allocated near the heartbeat buffers then they could be leaked.

i'm looking at crypto/rsa/rsa_eay.c and it is possible that this code is not the code that is being used to do the signing in ssl.

    /* signing */
    static int RSA_eay_private_encrypt(int flen, const unsigned char *from,
             unsigned char *to, RSA *rsa, int padding)
        {

    ..
    ..

            if ( (rsa->flags & RSA_FLAG_EXT_PKEY) ||
                ((rsa->p != NULL) &&
                (rsa->q != NULL) &&
                (rsa->dmp1 != NULL) &&
                (rsa->dmq1 != NULL) &&
                (rsa->iqmp != NULL)) )
                {
                if (!rsa->meth->rsa_mod_exp(ret, f, rsa, ctx)) goto err;


  static int RSA_eay_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
        {

  ..
  ..


          /* compute I mod q */
        if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME))
                {
                c = &local_c;
                BN_with_flags(c, I, BN_FLG_CONSTTIME);
                if (!BN_mod(r1,c,rsa->q,ctx)) goto err;
                }
        else
                {
                if (!BN_mod(r1,I,rsa->q,ctx)) goto err;
                }


  ..
  ..


          /* compute I mod p */
        if (!(rsa->flags & RSA_FLAG_NO_CONSTTIME))
                {
                c = &local_c;
                BN_with_flags(c, I, BN_FLG_CONSTTIME);
                if (!BN_mod(r1,c,rsa->p,ctx)) goto err;
                }
        else
                {
                if (!BN_mod(r1,I,rsa->p,ctx)) goto err;
                }

  #define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx))


  int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
           BN_CTX *ctx)

  ..
    sdiv=BN_CTX_get(ctx);
  ..
    if (!(BN_lshift(sdiv,divisor,norm_shift))) goto err;


  BN_lshift() shifts a left by n bits and places the result in r (r=a*2^n).
EDIT: obviously if you leak p and q you can trivially reconstruct the private key :) but it is possible other intermediate values might be leaked as well that allow for key reconstruction.

though, considering left shifted p and q look a lot like normal p and q i'm surprised no-one has found this by just searching through the leaked data. so maybe this is not leaked or it requires a read at the correct time because these buffers might be trashed by another computation.

Re: The Heartbleed Challenge

#57

Earlier quoted context omitted.

I'm disgusted they chose to share it with you early and not the major Linux distros...

There's no way to share such a bug with the major Linux distros and let them deploy a fix to users without making it public at the same time. Even assuming that the distros commit to handle the fix submission and silently repackage openssl (which they don't always do, depending on their policy), the word would get out minutes after it's pushed to the update servers. So telling major Linux distros == telling the publi…

Not so; companies like RHEL understand the importance of disclosure timelines and won't leak it early.

The importance of telling large distros doesn't lie in them immediately releasing a fix; it lies in them being able to prepare a package with the fix before the announcement, and then exactly when the announcement happens, they can publish the package (and possibly do something to make it propagate faster to their distribution servers)

As is, when Heartbleed was announced, many distros took an hour or significantly more to offer a fixed package. Proof-of-concept exploits were also made in that time. That was a dangerous situation.

I fully expect critical vulnerabilities that are "responsibly disclosed" to be reported to major distros so that packages can be prepared, but not released, in advance; furthermore, it allows people to be ready when it's announced at an agreed-upon date so that the packages can be pushed to live.

I'd actually be okay with a system where smaller distros which use similar packaging formats to larger ones are alerted with "There is an exploit. We will publish a fixed package that will likely be compatible with your distro on DATE. Be awake then to make sure these changes go live quickly, not when one key dude wakes up in 5 hours".

Sorry for the long-winded comment. What I really wanted to do is just explain "no way to share ... deploy a fix ... without making it public" is not the reason for sharing. The reason for sharing is so that the fix can be deployed more quickly when it is deployed.

Re: The Heartbleed Challenge

#58
post #44

Found this among the returned data: http://cl.ly/image/2o391V1T2R46 Who would request that much lorem ipsum nonsense and for what purpose?

perhaps to push the memory allocation for url out a bit wider, to get a segment of memory in a different place?

Re: The Heartbleed Challenge

#59
post #32
post #13

Earlier quoted context omitted.

I would be shocked if Neel was wrong about private key exposure AND it is a nation state that highlights his misunderstanding.

Cloudfare isn't making the same claim - they're just saying it doesn't seem to happen on their (modified) Nginx setup.

I do not understand what you are trying to convey in your message. I never mentioned Cloudflare and neither did the comment I was responding to. What part of my comment led you to believe I was presenting/responding-to a claim made by cloudflare?

Re: The Heartbleed Challenge

#60

Earlier quoted context omitted.

Shouldn't they be at the top of the address space then overruns would never hit them as they'd start below or does it not work like that.

The bug is reading 64k from x -> x+64k. You'd want the key as low as possible in memory so the chance of the heap implementation allocating a request below it (thus allowing the +64k to overlap into the key) is next to nil.

So if your key was at an address less than x the bug would never read it, was my point. So I guess that means you'd have to force the UDP datagram payload to be stored high as that dictates what x is?
Post reply on HN