david wong

Hey! I'm David, a security consultant at Cryptography Services, the crypto team of NCC Group . This is my blog about cryptography and security and other related topics that I find interesting.

Timing and Lattice Attacks on a Remote ECDSA OpenSSL Server: How Practical Are They Really?

posted August 2015

Alright! My master thesis is done. Here's a download link

It's a timing attack on an vulnerable version of OpenSSL. In particular its ECDSA signature with binary curves.

There was an optimization right before the constant-time scalar multiplication of the nonce with the public point. That leads to a timing attack that leaks the length of the ephemeral keys of an Openssl server's signatures.

In this paper I explain how to setup such an attack, how to use lattices to recover the private key out of just knowing the lengths of the nonces of a bunch of signatures taken during an ephemeral handshake.

If this doesn't make sense to you just read the paper :D

Also everything is on this github repo. You can reproduce my setup for a vulnerable server and an attacker. Patch and tools are there. If you end up getting better results than the ones in the paper, well tell me!

Also here's a demo:

EDIT: it's on the ePrint archive as well now.

11 comments

Key Ceremony

posted August 2015

There was a DNSSEC KSK (Key Signing Key) Ceremony. I guess it most not be too far away from what is a Key Ceremony

In public-key cryptography and computer security, a root key ceremony is a procedure where a unique pair of public and private root keys is generated. Depending on the certificate policy, the generation of the root Keys may require notarization, legal representation, witnesses and ‘key holders’ to be present, as the information on the system is a responsibility of the parties. The 'best practice' is to follow the SAS 70 standard for root key ceremonies.

The actual Root Key-Pair generation is normally conducted in a secure vault that has no communication or contact with the outside world other than a single telephone line or intercom. Once the vault is secured, all personnel present must prove their identity using at least two legally recognized forms of identification. Every person present, every transaction and every event is logged by the lawyer in a Root Key Ceremony Log Book and each page is notarized by the notary. From the moment the vault door is closed until it is re-opened, everything is also video recorded. The lawyer and the organization’s two signatories must sign the recording and it too is then notarized.

Finally, as part of the above process, the Root Key is broken into as many as twenty-one parts and each individual part is secured in its own safe for which there is a key and a numerical lock. The keys are distributed to as many as twenty-one people and the numerical code is distributed to another twenty-one people.

It's not that interesting, but I was just curious so I watched the footage of what it is here: http://data.iana.org/ksk-ceremony/21/KSK21-CAM1.mp4

It's boring.

But if you have nothing better to do, or you are curious like me, well here you go

comment on this story

I got a job!

posted August 2015

Hey you! So mmm, I don't know if you've been reading my blog for long, but it all started when I got accepted at the University of Bordeaux' Cryptography Master. At first it was just a place where I would talk about my (then) new life in Bordeaux and what I was doing in class.

2 years and 287 blog posts later, here I am, still blogging and still in school. But not for long! Well not in school for long, I'm still gonna blog don't worry.

So yeah, the big news is, I'll be starting full time as a security consultant for the Cryptography Services team of NCC Group in November!

woop woop

Woop woop!

Pardon? You are here for the crypto? ah umm, wait, I have this:

ephemeral

It's from this paper: Practical realisation and elimination of an ECC-related software bug attack by B.B.Brumley, Barbosa, Page and Vercauteren.

2 comments

Need helpz for my Master Thesis

posted August 2015

I have two weeks left to turn in my Master thesis.

It is about a timing attack on OpenSSL that was found in this paper: Billy Bob Brumley and Nicola Tuveri - Remote Timing Attacks are Still Practical

I tried to replicate the results. But to make it interesting I explained in more details how to mount this attack. There are lattice involved. It should be pedagogical.

Well... it should be.

Can I ask for your help? If you have time to spare, read a tiny part of this whitepaper and tell me if something seems odd, wrong, or badly explained.

I'll credit you here, you will have my eternal love and I will buy you a beer at one point.

The draft is here.

2 comments

Vegas - Part 3: Defcon 23

posted August 2015

Another world

I bought my Defcon badge through Blackhat to avoid having to move out of the Mandalay and miss some of the talks. Avoiding the long-and-early-in-the-morning lines of Defcon and still getting a "real" badge is also part of the benefits. So after lining up for 30 seconds at a small stand between two talks, I received a plastic bag with a program printed as a newspaper and several CDs containing music (I assume, but who owns a CD player nowadays?). The Defcon badge was an old and white record, apparently every other year the badge is non-electronic.

badge

Defcon was taking place in Bally's and Paris this year. The talks were in Paris, the rest was in Bally's. If you wanted to mix them up you had to change casino over and over. The two are connected but it's still a pain.

paris

I missed the first two days of Defcon. Well the first day isn't actually an official one as it takes place outside in a public park. The "toxic barbecue" is a gathering where people bring booze and meat. The second day, the official Defcon first day, is a single track of introductory talks that takes place in their Conference Center.

So I arrived in what I thought was something that already started, but all of blackhat and others that wanted to get the real deal were now rushing to the Defcon's talks, all at the same time. It was packed, the lines were not moving and the staff was screaming. I was starting to miss the organization of Blackhat.

queues

After leaving my first talk, I figured I would never go to another talk again. But they finally moved the 101 track (talks that are more for begginers) and things got better.

And then I went to visit the other side of Defcon, and that's where everything made sense

The Villages

My favorite part of Defcon was the Villages, small sized rooms (compared to the ones hosting the talks) where people of common interests gather and spend their whole Defcon together.

crypto village

The crypto Village was great, apparently Diffie was there. Other renown cryptographers hung out there too and I met a bunch of people I had always wanted to meet :) (although most conversations were short, I guess others were more at ease in this kind of environment than me).

There were a bunch of posters everywhere on the walls. Here's my favorite one from Tony Arcieri:

ecc

You could also find byte descriptions of packets of certain protocols, they are all available here

packet

Every hour, or 30 minutes, there was a talk. I left Defcon thinking that I should get more involved in this crypto village and that I should submit a talk for the next one.

There were maybe a dozen of other Villages. There was a lock picking one, but you had to buy your own gear so I passed (although I really wanted to do it).

chemical

After Defcon, sitting in the plane I read their "newspaper" and realized there was much more. There was a huge number of things that I didn't even know were going on. I could even have went and met some of them somewhere in the desert to shoot range.

I felt like I did nothing. I was a lurker and I took part in none of the cool things. Next time I will come prepared.

The Parties

The parties were definitely better than the Blackhat ones. The Facebook student party was the best I got to do, few people, no loud music and a "bingo" game where you were handed a card with a bunch of "can do X" or "is X at facebook" and you had to find a facebook employee/intern that could sign it for you. If you got a full row plus a column signed you won. This was awesome as it gave you an excuse to go talk to them.

There was also a party in a suite of the hotel were I got to meet a lot of really cool people in the field as well. The funny thing is that everywhere I went, even at these parties, a huge amount of the people present were from my company (NCC Group) which made things super easy to meet people, we also were all wearing the company Tshirt.

The Rest

room

There was a main room full of tables, people hacking, people playing, weird people handing me papers and tokens and telling me cryptic passphrase. Other weird people holding huge antennas and pointing them at everyone obviously looking for something/someone.

There was an OpenCTF space, and a CTF space as well with korean, french, american and chinese teams just sitting there on their computers and cracking stuff. I was not allowed to take a picture there :() Hacking contests are everywhere. The ambiance is nothing like Blackhat (Which is way more corporate). Between weird things happening on my wifi, the femtocell found in between the two casinos and the non-stop protocol downgrades on our phones, we felt like everyone was trying something on you.

hpkp

A stand to cut your hair and make you a mohawk. A spaceX stand giving out posters.

mohawk

A tesla hacking stand, someone on the floor looking at it. I heard they dismantled the whole car at one point.

tesla

and Finally... Hacker Jeopardy

This post makes no sense, but Defcon made no sense. It was awesome.

EDIT: Here's a video of a first timer

comment on this story

Lattices and Tikz

posted August 2015

I'm writing a paper, which temporary (but maybe final) title is Timing and Lattice Attacks on a Remote ECDSA OpenSSL Server: How Practical Are They Really?

(and I already have a github repo for that)

I'm explaining a few things about Lattices, taking some of the old material I already wrote for my last paper Survey: Lattice Reduction Attacks on RSA. But this time I wanted to be more pedagogical, with more graphics and illustrated examples. For reasons that I ignore lattices are seldom well explained on the internet thing. Here's a little preview, I guess you can re-use the images however you want, just don't copyright them against me :|

What are Lattices?

lattice

The Shortest Vector Problem:

svp

The Closest Vector Problem:

cvp

How do we solve (approximate) the SVP? LLL:

lll

and Babai's first procedure that approximates a solution to the CVP:

babai

comment on this story

Vegas - Part 2: Blackhat 2015

posted August 2015

Vendors

vendors

Blackhat is famously known for its vendor's room. A huge space where vendors knock themselves over to hand you their free goodies. There is also a "career fair" with a few tables where people are mostly interrested in hiring you contrarily to the other booths were people try to sell you something.

It was an excellent opportunity for me — coming from France and knowing close to 0 company names — to learn a lot about the field and who was a big actor there. I rapidly started recolting company names. Fireeye, Rapid7, Mandiant, Trustwave, Splunk... no I'm not paid to write that.

I also spent a few hours just recolting swag, just because I have an addictive personality. The number of stands giving away Tshirts was... impressive to say the least.

teeshirt

The RSA booth had an Oculus Rift demo, but it was disapointing and I wasted my time there staring at the emptiness of RSA's soul. I should have taken the clue seeing people taking off their headset making faces. I felt like with a better demo and controllers the execution would have been better, but after having tried the HTC Vive (see my blogpost), the competitor from valve and HTC, it's hard to be impressed by the Rift.

oculus

I saw people wining fitbit smartwatches, 50$ amazon coupon (damn you Jason!) and bluetooth speakers...

swag

The whole thing is just entertainment if you're not trying to buy anything. There are raffles, games, and also after a certain hour... you get free beers (and even hard liquor at the Microsoft bar, but shhhh). And I didn't tell you about the cheese buffet, the baked-in-front-of-you cookies, the cupcakes everywhere, the... oh my!

food

Arsenal

I feel like I should mention Arsenal, although I didn't take part in it at all. From what I understood it's like briefings but for presenting a tool. Some people only swear by that but I felt like I would waste time trying to understand a tool I might have no use for.

Networking and Parties

cocktails

The best thing I did while there was to attend the different parties. It's usualy short, like 2 hours, and you get free booze and sometimes free food. You get to meet a lot of cool people too.

If I had to re-do it I would avoid these loud parties though, they were nice as I got to see what big clubs in Vegas look like. But the music is often too loud and the bars so crowded that you end up doing nothing and talking to no one.

The trainer's party was the nicest I attended (but you need to be a trainer, speaker, etc...), Rapid7's was the most impressive.

Protip: always take the card that is inside your badge with you, you might get bounced if you don't show up with it since they always want to scan your badge.

read part 3 here, it's about Defcon

2 comments

Vegas - Part 1: Blackhat 2015

posted August 2015

inb4 people start complaining that this blogpost is not about crypto. It's not.

tickets

Diving in

That's it, I'm leaving Chicago for the arid desert of Nevada. Las Vegas, we meet again.

First let me say that I love Vegas, and I think anyone should go see what it looks like at least once in their life. Imagine a bunch of billionaire wandering in the desert, high on cocain, lost in their train of thoughts, laughing their ass off and suddenly coming up with the idea of bringing dozens of architects in the same desert and throw loads of money at them with no directions what-so-ever. Just for the lulz.

And that's how Vegas happened.

But I'm not here to eyeball at buildings and visit their guts. This time I'm here to mingle with nerds, geeks and other SAPs (Socially Awkward Penguins). I'm here to learn about the latest security vulnerabilities, the craziest discoveries of the best of the best. I'm here to meet with my tribe. I'm here to attend BlackHat and Defcon, the two biggest hacker conventions. And I'm seldom going to see the natural lights of our sun for a good long week.

But weird things started on the way, in the plane, when one of the hotess handed me a napkin. To me, only me. A white and clean napkin, nothing else. Did I have a booger? Nope. Was it something on my face then? Nein. The United Airline skeequing chairs, crying babies and eye-vessels blowing/nose congesting air conditionner were already killing me when we began to dive toward the unfamous LV.

plane

Training

vegas

A couple of hours after I was in the Mandalay arpenting the corridors of its enormous conference center. Two huge floors filled by multiple rooms of different sizes. Not a living soul. I checked-in to get my badge and got a blackhat bag with a few goodies. The four first days of blackhat are reserved for trainings.

blackhat

I waited in the hallways, enjoying the complimentary coffee & cookies while sitting in these huge sofas that were decorating the place. At 6pm I met with my coworkers and we went to play Craps

craps

The next morning I woke up early, dressed and went to eat the blackhat breakfast in a huge room filled with empty tables, some of them had people sat across each other not saying a word. I ate, drank my coffee and went to the class room.

breakfast

I spent two days as a trainer helping Tom Ritter, Sean Devlin and Alex Balducci giving the course Beyond the BEAST: Deep dives into crypto vulnerabilities. A mix of general culture in crypto, reknown attacks as exercises, cool crypto stuff we are excited about and some hours spent in the mathematics of cryptography. Every break we would go in the hallway, get some of the free pastries and coffee and chat a bit. Then we would go back to the class and teach. It went pretty well and I thought the convention would continue like that. I had no idea of the storm that was going to happen.

Briefings

I woke up and headed to the Conference, passing by the swimming pool that I had still not visited and that I would not visit for the rest of my stay. Attending Blackhat and the Defcon was pretty much staying indoors for a week. It was working, drinking, getting free stuff and meeting people without producing any natural vitamins.

swimming pool

The briefings are the talks. A bunch of people apply for Blackhat CFP (Call For Papers) and if they get accepted by a jury they are allowed to give a talk at the convention. People then have to choose between 8 talks happening at the same time (more or less), and then regroup in these gigantesc rooms to hear someone talking about something.

talks

immense

This is not training time anymore, we don't receive complimentary breakfast and lunch, hallways are now crowded and you can even see camera crews. Thing that you will never see at Defcon.

camera

I started by going mostly to crypto talks or other subject I understood better. Crypto talks were rare. Not that it mattered since I was expecting this but I felt like the quality of most talks were meh and I rarely went out of a room with the feeling that I actually got something from it.

Jeff Jarmoc told me that a good way of taking something out of these was to not look at the schedule and to wander and go sit at random talks. This is an excellent idea that I'll try to apply next time.

Most of the time I felt like it could have been better explained, or I could have read about that/watched a video on youtube and understood it way better. Maybe it's just me and the format of attending a talk is not working in my case, but besides a few talks I left unimpressed most of the time.

One talk stood out from the others, Remote Exploitation of an Unaltered Passenger Vehicle by Charlie Miller & Chris Valasek. First it was entertaining, second it was telling a story. That's what a good talk should do no? Be easy to follow, and by that I don't mean easy, but pedagogical. The "conversation" format where Charlie and Chris talked like they were just talking to one another retelling a story to their friends was just awesome. I left out, read that they were giving the same talk again at Defcon and planned to go see their talk one more time. That's how good it was.

read part 2 here

comment on this story

PBKDF2 Performance Matters

posted August 2015

hmac

Joseph Birr-Pixton gave a talk last week at Passwords15 in Vegas. He talks about it in his blog and there is a video of his presentation. And it's really good! He says "my slides were 100% algebra before someone told me to put diagrams instead". And the diagrams are very well made, really comprehensible. I felt like I learned a bunch of stuff in a few minutes, which I rarely feel after watching a talk. So spare a few minutes will you!

comment on this story

Homomorphic Encryption Vocabulary

posted July 2015

As I'm doing some research on Homomorphic Encryption, and trying to watch everything from Gentry (lots of videos available and he has a soothing voice), and possibly read everything from him (which I didn't do so don't take my word). Here's a vocab list I did for reference:

  • HE: Homomorphic Encryption
  • leveled: no bootstrapping, only compute circuits up to a degree (public key grows with the depth of the circuit for f )
  • LWE: Learning With Error (a problem hard to solve)
  • R-LWE: Ring-Learning With Error
  • Craig Gentry: the one who found the holy grail
  • holy grail: Fully Homomomorphic Encryption
  • FHE: another name for the holy grail
  • SHE/SWHE: somewhat homomorphic encryption
  • BGV: the first Leveled FHE (without bootstraping), from Brakerski, Gentry and Vaikuntanathan
  • GSW: a FHE scheme from Gentry, Sahai and Waters, that takes ideas from BGV and like BGV has its security based on LWE
  • NTRU: N-th degree truncated polynomial ring, the base of a lattice-based cryptosystem
  • modulus switching: (some messy operation that they got rid of in bra12)
  • bootstrapping: to make a bootstrappable somwehat homomorphic encryption scheme into a fully homomorphic encryption scheme (Gentry recommends not to use this, although it was the original way of building FHE)
  • IBE: Identity Based Encryption scheme (introduced by the famous Boneh paper)
  • IBFHE: Identity Based Fully Homomoprhic Encryption scheme (introduced by GSW)
  • SIMD: Single Instruction, Multiple Data

... more to come

comment on this story

How to fairly compare two objects?

posted July 2015

Alex asked me if I knew a way of comparing two sets of data: two players want to compare their guesses on some game, without giving away their guesses. You could think of Zero-Knowledge protocols, but this is usually a one-way proof. This is actually the Socialist Millionaire Problem and it is solved by doing a multi-party computation of a function (a comparison function in our case) on two inputs (the two guesses in our case).

In cryptography, the socialist millionaire problem is one in which two millionaires want to determine if their wealth is equal without disclosing any information about their riches to each other. It is a variant of the Millionaire's Problem whereby two millionaires wish to compare their riches to determine who has the most wealth without disclosing any information about their riches to each other.

But how to make it fair? What if one party stops the protocol at one point, for example when he knows if the guesses are the same or not, so that the other party doesn't learn anything.

This seems like a difficult problem to solve, but an interesting problem that crypto should be able to solve.

Alex found this paper: A fair and efficient solution to the socialist millionaires’ problem, where they explain what they call a "fair" protocol. And the solution is quite elegant! I haven't read the whole thing but the idea is basically to compare bit by bit (I guess under the surface they must use garbled circuits) so that if one party stops the protocol early, he only has one bit of advantage over the other one.

Finally, the fairness of the fair version of our protocol is straightforward. Both Alice and Bob are unable to compute the result of the comparison before the beginning of step 4. Moreover, during the fourth step, Bob's advantage over Alice is at most one bit. So, if Bob decides to abort the protocol and tries to search the remaining bits by exhaustive research, Alice needs no more than twice as much time compared to Bob to compute the same result.

comment on this story

Homomorphic Encryption : Part 1

posted July 2015

I'm reading stuff about HE (Homomorphic Encryption) and so why not share what I find? Hopefuly there will be more than one post on the subject, and they won't be too long, and they will make others learn something new

So what is Homomorphic Encryption?

Well let's start at the beginning shall we? It all began in 1977 when RSA was invented. If you recall, to encrypt with RSA you take your message/number \(m\) and raise it to the power of the public exponent \(e\) modulo a product of primes \(N\) like so:

\[ c = m^e \pmod{N} \]

An incredible property of textbook RSA is the fact that the scheme is malleable. If you have a ciphertext \(c\) but don't know what number \(m\) it's decrypting to, you can modify that ciphertext \(c\) so that it would decrypt to \(3m\) or \(9999m\) or more generally \(x \cdot m\). Just take your number \(x < N \) and encrypt it, then multiply that to your ciphertext like so:

\[ x^e \cdot c \pmod{N} \]

And notice that beneath the encryption, this is equal to

\[ x^e \cdot m^e \pmod{N} \]

That is the same as

\[ (x \cdot m)^e \pmod{N} \]

and will obviously decrypt as \( x \cdot m \). Tell me if I'm going too slow =)

This is called Homomorphic Encryption, which you might not want as a property when using RSA and that's why you should never use RSA without a padding system. The state of the art being OAEP.

This made Rivest and his friends raise the question, a year later in 1978, can this property be extended so that any kind of circuit could be computed on encrypted data? (R. Rivest, L. Adleman, and M. Dertouzos. On data banks and privacy homomorphisms. In Foundations of Secure Computation)

Fully Homomorphic Encryption

The applications thought were mostly "data manipulation" where you would want someone to manage/operate on your data without seeing it. Think banks, search engines, the cloud.

A bunch of other cryptosystem that provided homomorphic properties came to life after that. For example in 1999 the Paillier cryptosystem, which unlike RSA provides additive homomorphic encryption (RSA provides multiplicative homomorphic encryption).

The open problem was still out there. Could you create a cryptosystem that would provide enough homomorphic properties, that combined could compute any kind of circuits. A Fully Homomorphic Cryptosystem.

Any circuit can be simplified to these simple instructions: AND, OR and NOT, which would only need a cryptosystem to have addition, subtraction and multiplication to be able to emulate these instructions.

Modulo 2 would be enough, look, if \( x \in \mathbb{Z}_2 \) (the set of 0 and 1) then:

  • \( \text{AND}(x,y) = xy \)
  • \( \text{OR}(x,y) = 1 - (1-x)(1-y) \)
  • \( \text{NOT}(x) = 1 - x \)

With these properties combined you could then compute any circuit on encrypted data (think of a function, like AES() or select all my data that starts with the letter A, etc...).

So, just a recap so that we're on the same page. With a FHE Alice could send \( c = E(m) \) the encryption of her message \( m \) to Bob, and bob could compute the function \( f \) on the encrypted data so that it would decrypt to a function \(f\) on the plaintext:

\[ D(f(c)) = f(m) \]

Note that in reality, we can't really compute \( f \) on the ciphertext directly, what we do is that typically a Homomorphic Encryption scheme is defined with a function called Eval (for Evaluate) which we would use like that:

\[ D(\text{Eval}(f, c)) = f(m) \]

In 2009, Dan Boneh's doctorate student Craig Gentry finished his thesis, unveilling the first FHE (Fully Homomorphic Encryption):

In a presentation to my fellow Ph.D. admits four years ago, Dan highlighted fully homo- morphic encryption as an interesting open problem and guaranteed an immediate diploma to anyone who solved it. Perhaps I took him too literally.

Craig Gentry, Fully homomorphic encryption using ideal lattices, 2009

His thesis of 200 pages was later resumed in a 10 pages article for STOC 2009: Fully Homomorphic Encryption Using Ideal Lattices.

A bit later Gentry et al simplified that scheme using only hard problems on integers instead of lattices, this was explained as well in another article for CACM here: Computing Arbitrary Functions of Encrypted Data

In the next post we'll see how that FHE works!

2 comments

CVE TOMEK

posted June 2015

My coworker Tomek found a vulnerability in Rack, a Ruby thingy that is used pretty much in every web framework (Rails, Ramaze, Sinatra...) to translate queries (POST and GET) into Ruby objects.

Tomek: David you don't understand anything, go read this: https://www.omniref.com/ruby/gems/railties/4.2.0/symbols/Rails::Application#annotation=4084035&line=161

It all started when he read about how to_sym() used to work in Ruby versions prior to MRI 2.2. This function converts strings into symbols. A symbol is this thing: :symbol, that usually is tied to a value: :symbol => 'something' and that you must have seen written in a really nice way thanks to Ruby's lovely syntax sugar: symbol: 'something'. Developers use the to_sym() method a lot to transform the strings from GET/POST to symbols. Problem: the symbols created by to_sym() were stored in the memory and never freed. No garbage collection. That is a problem if you let user input infinitely use that to_sym() method. For example if you naively transformed the GET variables of a request to symbols through that function, then a malicious user could have queried that page with many ?stuff=something so that your code would have infinitely stocked symbols in memory until no memory was left.

Tomek was looking for the fastest method to fill up a server's memory. To do this, he tested various forms of parameters to see what would be the most effective. This included many small symbol names, large symbol names, and nested parameters. The most efficient way ended up being a lot of concurrent requests with huge symbol names, the server would go down in less than 2 minutes.

And it was through the nested parameter testing that he found CVE-2015-3225

CVE-2015-3225

https://groups.google.com/forum/#!topic/rubyonrails-security/gcUbICUmKMc

Potential Denial of Service Vulnerability in Rack

There is a potential denial of service vulnerability in Rack. This
vulnerability has been assigned the CVE identifier CVE-2015-3225.

Versions Affected:  All.
Not affected:       None.
Fixed Versions:     1.6.2, 1.5.4

Impact 
------ 
Carefully crafted requests can cause a `SystemStackError` and potentially
cause a denial of service attack.

All users running an affected release should either upgrade or use one of the workarounds immediately. 

In Ruby on Rails, one of the nice things you can do is use associative arrays (called hashes in Ruby) in your forms.

For example, in your HTML

<input type="text" name="form[name]" value="david">

would translates to Ruby as

{"form"=>{"name"=>"david"}}

And that is thanks to Rack! But there is a small problem here, Rack parses these nested hashes by recursively calling itself:

def normalize_params(params, name, v = nil)

    ...

    if params_hash_type?(params[k].last) && !params[k].last.key?(child_key)
      normalize_params(params[k].last, child_key, v)
    else
      params[k] << normalize_params(params.class.new, child_key, v)

Here, Ruby seems to push a bunch of info to the stack before calling the new function. A bit like an assembly prolog.

The thing is, after a while the stack gets full and Ruby throws an exception. And then? Rack catch the exception? Tries again? We don't really know, but the program hangs there.

So Tomek found out that when you would send a POST request with a deep enough hash you would cause the program to hang. This is bad because of DoS attacks.

Also, the problem cannot happen in json because json has a nest limit, and doesn't happen in GET requests either for the same reason.

What now?

CVE and Patches are talked about here: http://www.openwall.com/lists/oss-security/2015/06/16/14

Another thread there: https://hackerone.com/reports/42797

He's still trying to find out what is happening exactly, and he just opened a blog. So who knows, he might write something about it soon.

comment on this story