Better HN
topnewbestaskshowjobs
Log inSign up

staticassertion

13,486 karma · joined Jun 1, 2016 (10y ago) · 4,896 submissions

@insanitybit
Submissions

comment 4y ago · link · parent

There are like a dozen other posts where I answer this question so I'd recommend just going to my comment history.

comment 4y ago · link · parent

> The attacker I describe has MITM access. The attacker can read and modify page contents, but nothing on the server side. This can only be achieved by malware on the client side or tomfoolery with certificates, so it's not a common attack for sure. But, breaking basic passwords sent over a secure channel aren't a common attack in general.

I don't think that attacker is worth dealing with. At that point you're outside of the security responsibilities of a website and it's the operating systems job to provide security.

> But, breaking basic passwords sent over a secure channel aren't a common attack in general.

Isn't it? Lots of passwords are sent over TLS but SQL injection is still a top 10 vulnerability.

> a hacker can break HTTPS secrecy without also being able to modify the contents of traffic over the wire.

I'm not implying that they can. I'm implying they can read the hashed values after being transmitted to the server.

So attacker in the following positions, at least: 1. Owns your auth endpoint (but not your CDN)

2. Owns your proxy

3. Has read access to your logs and the password is in those logs

4. Has a SQL injection or timing attack against your password auth/ db

> A CSRF vulnerability won't let you send the password to a random host, unless you have full arbitrary code execution

Yeah true, I was thinking about the auth token, not the password.

> I'm not sure why an attacker would be able to guess the hash from a timing attack, if they can do that then the hashing implementation is very flawed,

Timing attacks aren't a property of the hash but of the operations on that hash.

> The database already contains hashes for normal password auth, so I'm not sure why your system would be any better.

Do you mean that the database would be doing server side hashing regardless? That's true (I sure hope). But the attacker will have to brute force a much larger space to recover the plaintext password and the point of doing the client side hashing is to protect other sites if a user reuses their password on those sites.

> Your custom salt/hashing system solves password reuse I suppose

To be clear, that's the point, and I don't think that's small. It's about reducing harm to your users - even if within the scope of your website your user is still vulnerable you are protecting them within the scope of other websites.

I haven't made this argument yet, but I believe it also adds security elsewhere by distributing the cost of your hashing to clients. Your server has to handle N clients, and maybe needs to response in 5ms to each client - so it can spend, say, 3ms on hashing. To keep your tail latencies down you might try to do 1ms of hashing.

But you don't have to worry about your compute if you push it to the client. You can have the client perform, say, 1M rounds of PBKDF2.

So the attacker has two choices.

1. Brute force the client hash, which is 32bytes and really not feasible. That is to say that in a naive brute force they start with 32bytes 0'd out and start counting until they reach your hash - not fun.

2. Brute force the client password, which has a huge number of rounds that you could never get away with on your server. 1M rounds of pbkdf2 is not something you'd want to do on your server but distributed across your clients it's no problem at all - a few hundred milliseconds perhaps. But that's devastating to an attacker trying to recover the plaintext - of course, with some caveats (a relatively weak salt).

I haven't put enough thought into this benefit to claim it, but I may as well throw it out there.

> but it doesn't add any protections to your website while adding complexity at your cost.

It's very little complexity at very little cost. It's a few lines of code that execute at the edge - you pay nothing for those cycles.

> at the cost of needing Javascript execution.

I don't consider this a cost. I think it's totally ridiculous to say that JS execution as a requirement is a "cost" - the vast majority of websites require JS, and there are plenty of good reasons for it (like telling your user their password is too short). If you care so much about JS as a cost, ok, don't do client side hashing.

> In my opinion, your login page would be a lot more secure with a CSP that disallows all scripting, just in case, and uses a simple system that's easy to spot mistakes in, like HTTPS POST or Basic auth.

I disagree. A CSP would be an excellent thing to implement, and everyone should do so. But I don't think that completely denying script execution is a good idea - your users are far more vulnerable to using weak and/or reused passwords than XSS on a site with the minimal scripting necessary to implement this code (no 3rd party packages are required for the code I mentioned).

comment 4y ago · link · parent

I think the question of how experiences compound is totally interesting and worth asking (which is why I did :P). It's something I think is worth considering when thinking through how you prioritize your life and your goals.

Doing things that make you a happier, healthier (mentally and physically) person at age 25 my seriously pay off vs doing those things at age 45. In fact I strongly suspect they do.

comment 4y ago · link · parent

I guess my point is that your hypotheticals are very leading and lack important context like probability. People generally don't plan to die at 57 because most people don't die at 57 (or 40). Planning your life like that isn't really sensible.

comment 4y ago · link · parent

> a minor release would suffice

Does the Go compiler have LTS releases? Like if I'm on 1.0, but 1.5 is out, are they going to release a 1.0.1 for a vuln that impacts 1.0+ ?

It seems unlikely but I'd be curious to know.

Libraries release patches more frequently, and it's also generally easier to apply a patch yourself if you need to.

Otherwise a point release may still imply a major release.

comment 4y ago · link · parent

You are correct. I (and I think most people?) consider that to be the most common attacker scenario.

comment 4y ago · link · parent

If the attacker only has access to the hash that hash is only usable for your website. If the user uses the same password for another site an attacker can not log into that other site using the hash.

That's really the main benefit of this approach - it reduces the impact of password reuse.

comment 4y ago · link · parent

I don't think that really addresses my point, it just shows that they did the work for one sanitizer already.

comment 4y ago · link · parent

I don't know why people are assuming the attacker:

A) Controls the code running the auth API

B) Controls the javascript

As if that's the common attack.

The common attack is that the attacker has a read on the hash, either through injection vulnerabilities or other leaks.

Your attacker, as described, has remote code execution on a server that hosts the auth API and the Javascript in one place. That is a very specific, powerful attacker!

> but I just can't think of a threat model where this makes sense

1. An attacker has CSRF and can trick your code into sending the hash to them. This significantly reduces the harm of that attack.

2. An attacker has an injection vulnerability giving them read access to hashes ie: sql injection, perhaps the most significant and relevant attack to discuss with passwords.

3. An attacker takes advantage of a timing attack, bruteforcing the server and measuring response times to leak its value. They can now only leak the hashed value, which is going to take way longer to leak and doesn't expose their password.

And more!

This defense tackles what are very very arguably the major threats to consider with regards to password security (they're the big ones in OWASP top 10).

> It can make stealing passwords more difficult for criminals if every website uses their own bespoke password processing script, but that'll also add a huge attack surface to your code and it'll be a burden to maintain.

You can significantly reduce harm and attack surface with all of 3 lines in your frontend code.

    salt = hash(username + static_salt)
    password_hash = pbkdf2(plaintext_password, salt)
it's trivial to implement this.

I'll grant you that PAKEs may be more complex to implement today, but even if we talk about a very basic implementation of client side hashing I think there's obvious value.

comment 4y ago · link · parent

Plenty of very simple web apps terminate TLS at the edge ie: at something like API Gateway. So if you then turn on request logging... voila. Hardly a complex scenario, happens all the time. Or at the application layer:

    @path("/login")
    def login(request):
        print("I have a bug, I'll just log the whole request real quick to see wtf is up!", request)
It's actually very hard to ensure that the password doesn't get logged. It requires constant discipline and maintenance. Any bug or change could expose it.

> I would hope that you would use a single-sign-on system with a centralized login page rather than exposing passwords to every web app within it

Implementing SSO is a great idea. Not everyone wants to use SSO though. If I were hosting a porn site I wouldn't expect my users to happily "sign in with Facebook". It's also much more work than a basic client hash.

> This is what I meant by clean logs - anywhere the password is used, ensure there is no record. How much code and how many layers does a password need to go through?

You underestimate the places logs can be generated or passwords can be accidentally persisted.

1. Your proxy

2. Crashes, stack traces, segfaults, core dumps, thread dumps, VM snapshots, free'd memory

3. Firewalls, both network and host

4. Audit logs for security, such as via ebpf or other auditing frameworks

5. The application, at any layer. In Python, did you know I can get a reference to the calling function? I've done this for logging purposes before, in fact. So even if your caller is super careful not to pass the password in, saving me from accidentally logging it, I can crawl back up the stack and get it anyway.

6. Your database logs

7. Services/ RPCs that sit between your auth API and your database

And as your business grows and your code changes you'll have to track all of that.

Orrrrrrrrr, you can just hash your password on the client side and significantly reduce the damage of a leak. Or put the extra work in to implement OPAQUE. Or use webauthn, that's cool too.

comment 4y ago · link · parent

Implementing opaque isn't overly hard. You can find pseudocode, implementations, state machine diagrams, etc, online. Here's a good post that links to implemented code: https://blog.cloudflare.com/opaque-oblivious-passwords/

I know nothing of framework support, I don't use frameworks. I'm likely going to contribute some open source code in the near future from my company to simplify things though.

But you could also just have your client do:

    salt = sha256("your company name goes here" + username)
    password_hash = pbkdf2(plaintext_password, salt)
and get some nice benefits.

> How would I ensure that my code for PAKE could not be overwritten if a hacker took over part of my server?

Depends on the server and the level of control. But it'll help in a number of cases. You're assuming the attacker has full control over the web-page's contents (among other things - even if an attacker had the web page's contents CORS means they couldn't send http only cookies to an attacker controlled server), which is a very specific, powerful position to be in.

comment 4y ago · link · parent

Tests with generated input. Call it what you like.

comment 4y ago · link · parent

Yikes, sounds pretty toxic on their part, but good on you for taking a strong approach to software stability.

Also, writing fuzzers is super fun.

comment 4y ago · link · parent

Not sure what you mean.

1. There is, of course, a way to implement it in your web app. I don't know what you mean by "no secure way" ?

> I am arguing more in general against client-side hashing methods that are currently usable, mainly JavaScript-based ones.

Even a trivially implemented client side hashing approach protects against a number of attacks.

comment 4y ago · link · parent

Sorry, but the idea that implementing "clean logs" is:

a) Tractable

b) Simple or straightforward

compared to client side hashing is absurd.

Client side hashing is a one time solution forever that exists in one place, requiring no 'cooperation' from other code to be safe. "Cleaning logs", which you still haven't defined at all, is going to be a constant maintenance burden that can break in any place where you log ie: absolutely fucking everywhere by absolutely fucking everyone.

comment 4y ago · link · parent

> What does it matter? If a criminal gains the hash, they can log in and be malicious anyway.

To that one site. But users reuse passwords and if a criminal only has a hash they can't reuse it across sites.

comment 4y ago · link · parent

A trivial fix here is to:

a) Add a static value to the salt ie: your company's name

b) Add the user's email address to the salt

The "right" way would be a zero knowledge proof.

comment 4y ago · link · parent

PAKE isn't theoretical at all and the post you're responding to didn't say client side hashing it said zero knowledge proofs.

comment 4y ago · link · parent

> Accidental logging?

Yes, it happens all the time that passwords get logged.

> I mean, I guess, but then just set up your logs correctly instead of breaking login for anyone without JavaScript.

I have no idea what "set up your logs correctly" is supposed to mean but clearly no one's doing it. What is a "clean log" ?

> If I was a hacker, I can add JavaScript to send plaintext somewhere. If I was a hacker, I could change the login form to stop hashing them client-side and instead send them over to the server for hashing and inspection.

This assumes you have full control over the client page. But that's not necessarily (or often? most people don't serve JS from the same code that serves their auth API) the case.

1. The JS could be loaded from a CDN, not the same service that has access to the password. You may have absolutely no control over the JS on the page.

2. Every point between the browser and the password DB is a point where the password is in cleartext. So a compromise of any of those, including any logging paths, is a compromise of the password.

3. I don't think anyone cares about breaking login for users who don't use JS, nor should they.

What's more, ZKP means that if your password database is owned the impact is far less. If you're doing things right for password storage on top of ZKP you can practically make your password db public.

Even if we're talking about a basic client side hashing approach you're significantly improving security, but to be clear, the parent poster is talking about ZKPs, which involve more than that.

comment 4y ago · link · parent

> This is indeed a chore in other languages. In Go, the compiler is trivially installed. Typically this just means bumping the version in your Dockerfile and “gvm use $newVersion —default”.

The issue isn't with installing the new compiler, that's trivial in our use case as well (for Rust at least, Python's a disaster, but I accept that). The issue is ensuring compatibility, ensuring no new bugs are introduced, etc. It's just a much heavier change to your produced binary vs changing a package.

> This is supported out of the box by Go’s tooling. `go mod graph` is what you’re looking for.

Cool, thanks.

comment 4y ago · link · parent

I don't know that I'd hate it if I were a go dev, it would just be a bit annoying for a number of reasons.

For one thing I update libraries all the time so it's a very fast, simple, well worn operation. Updating the compiler is a bit more of a chore and I'm going to worry a bit more about the impact (since it's global to all code vs local to one package).

For another, I would want to make sure I had tooling that could tell me "is this library in use by service X". I don't know Go's story there, but I would hope it's trivial to do so for a library but I suspect if it's part of the standard library that may be trickier. If not, nbd.

It's a bad smell to me, but if I were a Go developer it wouldn't break me.

Perhaps ironically, until this native fuzzing package, upgrading the compiler if you had fuzz tests would be one case where things would likely break.

comment 4y ago · link · parent

> The Go toolchain actually supports emitting instrumentation for LLVM's libFuzzer with -gcflags=all=-d=libfuzzer.

Sweet, that's a smart approach.

> Okay, and so? If this ends up making fuzzing more popular and easy-to-use, I frankly don't care if it was added as a library or deeply integrated into the toolchain.

I don't care either because I don't write Go, so just the fact that it's supported is nice for me since it encourages this in languages I do care about.

But if I were a go developer I might care a lot about how my language evolves, what's built in, what's a library, what the capabilities are, what tools I can integrate with, etc.

It sounds like they've done a pretty good job with regards to this implementation though, happy to see it.

comment 4y ago · link · parent

Just taking what would normally be a unit test and having the input values be generated. Some examples:

1. I have a test for encryption/decryption functions. The data that's provided for the plaintext, additional data, and key, is generated. The assertions are:

assert_ne!(plaintext, encrypted_data);

assert_eq!(plaintext, decrypted_data);

assert_eq!(aad, decrypted_aad);

etc

2. I have some generated integration tests. For example, in our product, there are certain properties that should always hold for a given database entry. I generate a new entry on every test and have the fields for that entry provided by quickcheck, then I perform the operation, query the database, and assert that properties on those values hold.

So to answer your question, yes. Sometimes you want to check a concrete output (ie: "this base64 encoded string should always equal this other value) for sanity, but in general property tests give me more confidence.

I find it works particularly well with a 'given, when, then' approach, personally.

edit: I'll also note that for the base64 case I'd suggest:

a) A hardcoded suite of values.

b) Generate property tests.

assert_eq!(value, base64decode(base64encode(value));

As well as things like "contains only these characters" and "ends with [=a-zA-Z]" etc.

c) Oracle tests against a "known good" implementation.

comment 4y ago · link · parent

My point is that between Go's custom compiler backend and inexpressive typing there's much more need to build things like this in directly vs what other languages can do by just using llvm/gcc. Like if Go developers want sanitizers equivalent to what llvm packages they'll have to build that themselves, although that won't have the same issue with inexpressive types.

comment 4y ago · link · parent

Great to see fuzzing becoming more mainstream. Ultimately we have absurd program states, with even a trivial program's state vastly exceeding the number of particles in the universe. We need to start finding order-of-magnitude-better approaches for testing.

I almost always write generated tests at this point with unit tests being a fallback for slow code or niche cases. What I dont generally write though is fuzz tests, which would really be a 'next step'. In Rust it's not very hard to do so, but it hasn't quite hit the "trivial" mark yet for me, whereas quickcheck is virtually the same amount of work to use as to not use.

Languages like Go adopting and mainstreaming these practices will be a benefit to everyone.

I'm curious if there's documentation on:

a) The coverage approach taken

b) The mutation approach taken

Can you configure these? Plugin different fuzzing backends?

comment 4y ago · link · parent

This is just a work around for:

a) A lack of strong typing

b) A custom compiler toolchain

llvm already has instrumentation/ coverage support and generics make it easy to work with higher level constructs than bytes, although you generally do want to just work with bytes when fuzzing imo.

The language is weak, therefor the language has to add more and more batteries-included because extending it is purposefully difficult.

comment 4y ago · link · parent

The fact that requests has "languished" (not sure how tbh) doesn't really change the fact that the Python stdlib is a bit of a hilarious disaster from afar. Tons of cases of "that shouldn't be in std" where libraries have quirky, locked in behaviors, or an entire major breaking release with decades of work to migrate has to be made to clean up the mistakes.

Python should be a case study in the many ways not to build a language.

> By contrast Go ships with a high quality standard HTTP library that has lasted a decade and no “requests” equivalent has risen up to challenge it.

Yeah this also means that you need to update your compiler when there's a vulnerability instead of just a single point release in a library. This happens with some frequency.

The parent poster is right, in my opinion.

comment 4y ago · link · parent

Yeah I mean I'm not advocating for some sort of monk-like isolation where you have No Fun and work 24/7. Just as I'm sure people aren't suggesting living a wild life where no consequences or future is considered.

I'm just saying that tipping the balance for a few years can be a really good tradeoff, and to counter the "deathbed" anecdote above.

comment 4y ago · link · parent

I don't think your sentence is particularly well formed so it's not clear what you're getting at.

comment 4y ago · link · parent

I agree. There's also a difference between happiness, fulfillment, and "a good life" for many people.

I can be happy playing video games and relaxing, but maybe not fulfilled. I can work hard on interesting problems and feel fulfilled, but if that's all there is in my life I wouldn't say I lived well.

Confronted with death we look to our past for comfort. We're about to experience a total loss of everything and so, naturally, we search for meaning - "it can't have all been for nothing".

That's why the "death bed" thought experiment is interesting but also probably not the right way to frame things. It forces you to question life's intrinsic meaning and value but you should also think about how you feel right now, regardless of death or meaning or value.

1
676869
164