Better HN
topnewbestaskshowjobs
Log inSign up

sdevlin

1,326 karma · joined Jul 6, 2009 (17y ago) · 248 submissions

Submissions

comment 13y ago · link · parent

Your point is well taken, but I think it has value. Compile-time error checking is useful because it gives you flexibility to make changes in a big program. It's kind of like a big suite of automatic tests that make sure all the parts of your program talk to each other correctly.

Does it catch everything? Can you stop thinking critically? No, but it's still nice to have.

This sort of goes hand in hand with IDE tools (e.g. "change method name" sorts of things), so I don't think we necessarily disagree.

> I've never seen a bug in production that could have been prevented with static analysis.

That seems unlikely to me.

I do application penetration testing for a living, and I'll often use static analysis tools in my work. (Both robust, established tools and ad hoc scripts.) For example, check out Brakeman for Rails apps. These tools find actual bugs in actual production software.

Do they find everything? No, you can't rely on them completely. But they're still nice to have.

comment 13y ago · link · parent

I sometimes find myself torn between dynamic typing (great for rapid prototyping) and static typing (great for tooling and compile-time error checks).

I'm a big fan of TypeScript's approach, which gives you the best of both worlds. Start with fully dynamic code to explore the problem space, then add more static guarantees as you firm up your design.

I haven't had occasion to write a big web app recently, but I'm itching to find one so I can put TypeScript through its paces.

comment 13y ago · link · parent

Changing the CSRF token with each request would work, but you also risk frustrating your users this way. If you have more than one tab open on the same web application, you could only submit a form successfully from the "freshest" of these.

comment 13y ago · link · parent

> Is there any general way of preventing this kind of attacks?

Disabling compression is a 100%-effective countermeasure for compression oracle attacks.

> Also, why does the site http://breachattack.com/ says that "Randomizing secrets per request" is less effective than disabling compression?

Putting random data in the server response will only slow down the attack. With enough requests, the noise from that random data will wash out.

Disabling compression will stop the attack cold. The whole thing is predicated on analyzing the size of the compressed text. No compression, no compression oracle.

comment 13y ago · link · parent

He's citing this as a potential cross-authorization vulnerability, not SQL injection.

The form he's demonstrating is a common misstep in Rails. Instead of writing something like:

  current_user.apartments.destroy(params[:id])
The programmer wrote:

  Apartment.destroy(params[:id])
Meaning that the apartment lookup is not being done within the context of the current user, it's global. This means an attacker can delete other users' apartments with crafted URLs.

When I'm testing Rails applications, I always grep the source for something like:

  /[A-Z][A-Za-z0-9_]\.(find|destroy|...)/
To find vulnerabilities of exactly this kind.

comment 13y ago · link · parent

Other people have answered this for me, but I mean the overhead of another moving part in the tool chain. Sometimes this is worth it (i.e. your example of C v. assembly down thread), but I don't think it's the case here.

I don't mean to suggest CoffeeScript is without value. I just don't think it has hit the requisite "escape velocity" to make me want to integrate it to my tool chain.

comment 13y ago · link · parent

> The explanation for most people’s dislike of CoffeeScript is probably our natural resistance to new things and our comfort in what we know.

This is a mildly insulting, as is the invocation of Blub.

CoffeeScript doesn't have a ton of exotic features. String interpolation, list comprehensions, and class definitions (!) are all familiar to programmers from other languages.

I'm guessing that a lot of people have weighed CoffeeScript's feature set against its overhead and decided the trade just isn't worth it.

comment 13y ago · link · parent

Typically CSRF tokens are only required for state-changing requests - POSTs, PUTs, DELETEs.

They're broadening that recommendation also to include pages that reflect input. Think GET requests that take query string parameters. So e.g. https://google.com/search?q=pajamas would become https://google.com/search?q=pajamas&csrf=etcetc.

It seems like a pretty impractical mitigation to me. For one thing, it would make it very difficult to share links; a link containing my CSRF token wouldn't work for you. It would also make it much easier to give up your CSRF token. We would need to retrain people to think of the URLs they're viewing as personal and secret.

comment 13y ago · link · parent

> The alternative is auditing every single endpoint to ensure that it won't leak attacker data into the response,

I think you're underestimating how common this is.

For example, view source on https://www.google.com/search?q=pajamas and look at how many times "pajamas" appears on the page.

This is a simple example, but query string parameters (and other attacker-controlled data) get reflected in server responses all the time. Eliminating this behavior is not a realistic goal.

comment 13y ago · link · parent

In many web application frameworks, CSRF tokens are session scoped. So an attack might look like this:

  1. User logs in to target web app (e.g. hapless.com).
  2. User visits your malicious content (e.g. evil.com).
  3. Your page does a BREACH attack, issuing tons of HTTPS GET requests (by creating images in JavaScript, maybe) to hapless.com with query string parameters that manipulate the response.
  4. You observe the responses and recover the CSRF token.
  5. You attack the user with a standard CSRF attack on evil.com or elsewhere.
Note that this attack requires the user to interact with attacker-controlled content via a MITM'd connection.

> I imagine tons of applications do this, but it's nowhere near as far reaching as CRIME.

This is very common in web applications. Echoing query string parameters in the server response is the basis for reflected cross-site scripting, for example. And in a complex web application, tons of pages will have CSRF tokens embedded somewhere.

I do agree that CRIME is a much more dangerous attack.

comment 13y ago · link · parent

I think the idea is to find e.g. a query string parameter that gets reflected back in the response's HTML along with a target secret. The attacker can then spawn requests and monitor the size of the response.

comment 13y ago · link · parent

> Ah, so in fact the naive concatenating solution I gave, in addition to being just as easy because the attacker only has to break half of it, is actually even easier because the attacker has two targets to collide with.

I wouldn't say it's easier. Remember that we need to find a single message that generates a collision under both hash functions. So our strategy is to generate a massive number of collisions for the shorter function and hope that there's one pair of messages in there that collide under the longer function.

> What about non-concatenative methods?

I think this will again boil down to finding a single message that generates a collision under both hash functions. It won't matter too much whether you XOR the hashes or concatenate them.

comment 13y ago · link · parent

This is actually a pretty interesting question. The answer, at least for Merkle-Damgard hash functions (MD5, SHA-1, SHA-2, etc) is that concatenating (or "cascading") hash functions doesn't really improve the strength of the resulting construction.

Merkle-Damgard hash functions look like this:

  function MD(M, H, C):
    for M[i] in pad(M):
      H := C(M[i], H)
    return H
For message M, initial state H, and compression function C. In other words, pad the message, break it into blocks, and use the compression function to "mix" each block into the hash function's state. The final state is the result.

Antoine Joux showed that for any MD hash function, generating many collisions is not much more difficult than generating one. Here's how:

  1. Take the initial state H[0].
  2. Find two single-block messages that collide under C with H[0] as the input state. Call the result H[1].
  3. Now find another pair of single-block messages that collide under C with H[1] as the input state. Call the result H[2].
  4. Iterate as needed.
Here's the trick: each single-block collision you find is actually doubling your set of colliding messages. This is because for each block of the message, you can select either of two candidate blocks. So if the effort required to find a collision in a b-bit hash function is 2^(b/2), the effort to find 2^n such collisions is only n * 2^(b/2).

What does this mean for cascaded hash functions? Well, consider a hypothetical construction that simply concatenates a 128-bit hash function with a 160-bit function. A plan of attack might look like this:

  1. Find 2^80 colliding messages under the 128-bit function. This should take roughly 80 * 2^64 ~= 2^70.3 units of "effort".
  2. Evaluate each message under the 160-bit function. There's probably a collision in there somewhere. This will take around 2^80 work, dwarfing what we did in the first step.
The effort to find a collision under both functions is thus only about what it takes to find a collision under the stronger of the two.

Shameless plug: we will have a few problems exploring the consequences of Joux collisions in set seven of the Matasano crypto challenges.

comment 13y ago · link · parent

Apologies on this, and thanks for your patience. This is something we work on in our spare time, and we've got a bit of a backlog at the moment. I'm going to try to find time to power through most of this over the weekend.

As you say: persistence is key. We get a lot of emails. If you feel like you've slipped through the cracks, don't hesitate to ping us again!

195.

Applied Cryptography Engineering(sockpuppet.org ↗)

118 points · by sdevlin · 13y ago · 30 comments

comment 13y ago · link · parent

The format of a document is relevant to the recipient. Not every text editor will open a Word document.

Also, you probably wouldn't look at someone funny for requesting a kleenex. All the things you mentioned have pretty strong brand-name recognition, such that e.g. even non-PowerPoint slide decks are called PowerPoints.

comment 13y ago · link · parent

> once you learn how to exploit the flaw in RC4 he's talking about

Quick version: RC4 has biases in the key stream it generates. This means that for a given offset, certain bytes are more likely to appear than others. How do you exploit this? Collect a large sample of the same plaintext encrypted under different key streams. Examine the biases apparent in your samples and compare them to the actual key stream biases. You should be able to infer the actual plaintext byte.

comment 13y ago · link · parent

RC4 is a stream cipher. This means you have a stream of key bytes and a stream of plaintext bytes. You pair these up and XOR each pair together to get a stream of ciphertext bytes.

The key stream is generated independently of the plaintext, so the attacker really only cares that the bytes he's interested in (i.e. session cookies) stay at the same offset in the stream.

comment 13y ago · link · parent

Typically the secret data you're interested in is specific to a particular user. Session cookies, for example. (Not saying this is universally true, this is just the scenario I think is on most people's minds.)

If the traffic is common to everyone, the NSA could just browse to the site.

comment 13y ago · link · parent

Unfortunately, I don't think so.

It's pretty easy to eyeball your ciphertext and think it's sufficiently garbage-looking, but it's difficult to predict what an attacker can do with access to your running system. Seemingly innocuous flaws can lead to complete plaintext recovery or the ability to forge arbitrary ciphertext. (Here's a fun way to get a taste: http://www.matasano.com/articles/crypto-challenges/)

@cperciva is right that cryptographic security is something that needs to be proven. Since I'm not smart enough to do that, I avoid designing my own crypto systems, and I recommend clients do the same. Lots of risk, little or no reward.

comment 13y ago · link · parent

I don't think this is good advice for the developer population at large.

> Sure, it's complex and you have to get all the details right

What's really dangerous about cryptography (someone on HN pointed this out a few weeks ago) is that you get very little feedback on this. It's very easy to take reliable primitives and build a broken system. When I say "broken" I don't mean "theoretically vulnerable" - I mean "game over".

I get paid to look for these bugs, and they are legion.

> so for developers, I recommend a more modern approach to cryptography — which means studying the theory and designing systems which you can prove are secure.

The average application developer does not have the time or the need to learn the theory at a deep level. And as before, it's very difficult to say with confidence "this design has no bugs".

The best advice I can give developers is to play very conservatively. Our default recommendation is PGP for data at rest and TLS/SSL for data in transit. Or some high-level library like KeyCzar, NaCl, etc.

comment 13y ago · link · parent

16% of web vulnerabilities found by a scanner are still XSS.

comment 13y ago · link · parent

I wouldn't say we use lisp. We do test lisp apps every so often.

comment 13y ago · link · parent

Matasano - New York City, Chicago, San Francisco Bay Area

We break into banks. And hospitals. And financial firms. And social media startups. And any other business that puts an open port between itself and the big bad world.

Matasano is looking for appsec consultants, now and forever. What does that mean?

We dig deep. Our consultants spend their days sliding up and down the ladder of abstraction, rapidly assimilating unfamiliar systems (and then breaking them). One week you're pulling apart macros in a Lisp app; the next, you're on your hands and knees crawling through x86 disassembly.

We move fast. Our projects run on tight deadlines: one or two weeks is typical. Recently we wrote a bespoke proxy to rip apart a custom encrypted protocol, tamper with messages, and cobble it back together again. That could be a two-week job in itself. At Matasano, that's just Tuesday.

We find bugs. Not just in applications, but in the tools they're built with. That includes some of the biggest open-source and proprietary software stacks in the world.

This is the Mission: Impossible of software gigs, and we need the best people to get the job done. NO PRIOR APPSEC EXPERIENCE REQUIRED. We need great software developers and fast learners, for we intend to go in harm's way. If this sounds interesting to you, we should absolutely talk.

Who knows what evil lurks in the hearts of software applications?

Matasano knows.

Full benefits. Free books. Really smart coworkers. For more information, visit http://www.matasano.com/careers.

Looking for a taste of what we do? Shoot an email to cryptopals@matasano.com. We'll get you started with 48 problems (and counting) of real-world cryptography problems. This is the best answer you will ever get to the question: "Why shouldn't I roll my own crypto?"

comment 13y ago · link · parent

Einstein did his best stuff while he was working as a patent clerk.

comment 13y ago · link · parent

Surely questions of readability should be decided with an eye towards experienced users of the language and not those who "don't know the first thing about F#".

I agree with the GP that x::xs is more appropriate.

comment 13y ago · link · parent

> Also, I don't know any F#, but is he correct when he says that the order of declarations in a file matters, and that the order of files in a project matters?

He is correct. (At least, this was true a couple years ago. I haven't used F# since then, but I doubt this has changed.)

I don't have enough F# experience to speak to any potential benefits of this restriction.

comment 13y ago · link · parent

Since you're only going to store the hashed value, there's no practical reason to limit the maximum length of the password.

comment 13y ago · link · parent

If this were true, there would be no reason to hash passwords.

There are hashing algorithms (bcrypt, scrypt, PBKDF2) that are specifically designed to be slow to prevent these attacks.

comment 13y ago · link · parent

This is not accurate. If it were, what would be the point of hashing at all?

Password hashes like scrypt, bcrypt, and PBKDF2 are specifically designed to be slow, such that breaking them takes not weeks but many years.

1
56789