News for hackers. Stuff that matters.
Re:Bear Does Analytics with CSS by alkonaut on Wednesday November 01, 2023 @08:24AM (#38097302)
Hashes should be salted. If you salt, you are fine, if you don't you aren't.

Whether the salt can be kept indefinitely, or is rotated regularly etc is just an implementation detail, but the key with salting hashes for analytics is that the salt never leaves the client.

As explained in the article there seems to be no salt (or rather, the current date seems to be used as a salt, but that's not a random salt and can easily be guessed for anyone who wants to say "did IP x.y.z.w visit on date yy-mm-dd?".

It's pretty easy to reason about these things if you look from the perspective of an attacker. How would you do to figure out anything about a specific person given the data? If you can't, then the data is probably OK to store.

Re:Bear Does Analytics with CSS by piaste on Wednesday November 01, 2023 @08:48AM (#38097497)
> Hashes should be salted. If you salt, you are fine, if you don't you aren't.

> Whether the salt can be kept indefinitely, or is rotated regularly etc is just an implementation detail, but the key with salting hashes for analytics is that the salt never leaves the client.

I think I'm missing something.

If the salt is known to the server, then it's useless for this scenario. Because given a known salt, you can generate the hashes for every IP address + that salt very quickly. (Salting passwords works because the space for passwords is big, so rainbow tables are expensive to generate.)

If the salt is unknown to the server, i.e. generated by the client and 'never leaves the client'... then why bother with hashes? Just have the client generate a UUID directly instead of a salt.

Re:Bear Does Analytics with CSS by rkangel on Wednesday November 01, 2023 @09:05AM (#38097656)
Without a salt, you can generate the hash for every IP address once, and then permanantly have a hash->IP lookup (effectively a Rainbow table). If you have a salt, then you need to do it for each database entry, which does make it computationally more expensive.
Re:Bear Does Analytics with CSS by tptacek on Wednesday November 01, 2023 @09:53AM (#38098188)
People are obsessed with this attack from the 1970s, but in practice password cracking rigs just brute force the hashes, and that has been the practice since my career started in the 1990s and people used `crack`, into the 2000s and `jtr`, and today with `hashcat` or whatever it is the cool kids use now. "Rainbow tables" don't matter. If you're discussing the expense of attacking your scheme with or without rainbow tables, you've already lost.
Re:Bear Does Analytics with CSS by jonahx on Wednesday November 01, 2023 @03:05PM (#38103291)
> If you're discussing the expense of attacking your scheme with or without rainbow tables, you've already lost.

Can you elaborate on this or link to some info elaborating what you mean? I'd like to learn about it.

Re:Bear Does Analytics with CSS by alkonaut on Wednesday November 01, 2023 @10:32AM (#38098690)
> > the salt never leaves the client

> I think I'm missing something.

...

> If the salt is known to the server,

That's what you were missing yes

Re:Bear Does Analytics with CSS by SamBam on Wednesday November 01, 2023 @11:09AM (#38099254)
Did you miss the second half where GP asked why the client doesn't just send up a UUID, instead of generating their own salt and hash?
Re:Bear Does Analytics with CSS by arp242 on Wednesday November 01, 2023 @01:42PM (#38101908)
> why bother with hashes? Just have the client generate a UUID directly instead of a salt.

The reason for all this bonanza is that the ePrivacy directive requires a cookie banner, "making exceptions only for data that is "strictly necessary in order to provide a [..] service explicitly requested by the subscriber or user"*.

In the end, you only have "pinky promise" that someone isn't doing more processing on the server end, so in reality it doesn't matter much especially if the cookie lifetime is short (hours or even minutes). Actually, a cookie or other (short-lived!) client-side ID is probably better for everyone if it wasn't for the cookie banners.

Re:Bear Does Analytics with CSS by TylerE on Wednesday November 01, 2023 @03:23PM (#38103529)
ALL of the faff around cookies is the biggest security theater of the past 40 years. I remember hearing the fear-mongering in the very early 2000's about cookies in the mainstream media - it was self-evidentally a farce then, and a farce now.
Re:Bear Does Analytics with CSS by throwaway290 on Wednesday November 01, 2023 @06:04PM (#38105967)
Isn't in this case data is part of "strictly necessary" data (IP address)? That's all that gets collected by that magic CSS + server, no?
Re:Bear Does Analytics with CSS by arp242 on Wednesday November 01, 2023 @06:58PM (#38106575)
ePrivacy directive only applies to information stored on the client side (such as cookies).
Re:Bear Does Analytics with CSS by darken on Wednesday November 01, 2023 @08:54AM (#38097560)
Salts are generally stored with the hash, and are only really intended to prevent "rainbow table" attacks. (I.e. use of precomputed hash tables.) Though a predictable and matching salt per entry does mean you can attack all the hashes for a timestamp per hash attempt.

That being said, the previous responder's point still stands that you can brute force the salted IPs at about a second per IP with the colocated salt. Using multiple hash iterations (e.g. 1000x; i.e. "stretching") is how you'd meaningfully increase computational complexity, but still not in a way that makes use of the general "can't be practically reversed" hash guarantees.

Re:Bear Does Analytics with CSS by alkonaut on Wednesday November 01, 2023 @10:44AM (#38098857)
As I said the key for hashing PII for telemetry is that the client does the hashing on the client side and the client never transmits the salt. This isn't a login system or similar. There is no "validation" of the hash. All the hash is is a unique marker for a user that doesn't contain any PII.
Re:Bear Does Analytics with CSS by sysop073 on Wednesday November 01, 2023 @11:12AM (#38099295)
What's the point in hashing the IP + salt then, just let each client generate a random nonce and use that as the key
Re:Bear Does Analytics with CSS by SamBam on Wednesday November 01, 2023 @11:10AM (#38099275)
How does the client generate the same salt every time they visit the page, without using cookies?
Re:Bear Does Analytics with CSS by donkeyd on Wednesday November 01, 2023 @11:42AM (#38099807)
Use localstorage!

Kidding, of course. I don't think there's a way to track users across sessions, without storing something and requiring a 'cookie notification'. Which is kind of the point of all these laws.

Re:Bear Does Analytics with CSS by alkonaut on Wednesday November 01, 2023 @12:00PM (#38100160)
Storing a salt with 24h expiry would be the same thing as the solution in the article. It would be better from a privacy perspective because the IP would then not be transmitted in a reversible way.

If I hadn't asked for permission to send hash(ip + date) then I'd sure not ask permission if I instead stored a random salt for each new 24h and sent the hash(ip + todays_salt).

This is effectively a cookie and it's not strictly necessary if it's stats only. So I think on the server side I'd just invent some reason why it's necessary for the product itself too, and make the telemetry just an added bonus.

Re:Bear Does Analytics with CSS by alkonaut on Wednesday November 01, 2023 @11:50AM (#38099940)
If you can use JS it's easy. For example localStorage.setItem("salt", Math.random()). Without JS it's hard I think. I don't know why this author wants to use JS, perhaps out of respect for his visitors, but then I think it's worse to send PII over the wire (And an IP hashed in the way he describes is PII).
Re:Bear Does Analytics with CSS by SamBam on Wednesday November 01, 2023 @12:00PM (#38100145)
EU's consent requirements don't distinguish between cookies and localStorage, as far as I understand. And a salt that is only used for analytics would not count as “strictly necessary” data, so I think you'd have to put up a consent popup. Which is precisely the kind of thing a solution of that is trying to avoid.
Re:Bear Does Analytics with CSS by alkonaut on Wednesday November 01, 2023 @12:09PM (#38100325)
Indeed, but as I wrote in another reply: it doesn't matter. It's even worse to send PII over the wire. Using the date as the salt (as he does) just means it's reversible PII - a.k.a. PII!.

Presumable these are stored on the server side to identify returning visitors - so instead of storing a random number for 24 hours on the client, you now have PII stored on the server. So basically there is no way to do this that doesn't require consent.

The only way to do it is to make the information required for some necessary function, and then let the analytics piggyback on it

Re:Bear Does Analytics with CSS by SamBam on Wednesday November 01, 2023 @12:36PM (#38100811)
I think I agree with you there. But again, the idea of a "salt" is then overcomplicating things. It's exactly the same to have the client generate a GUUID and just send that up, no salting or hashing required.
Re:Bear Does Analytics with CSS by alkonaut on Wednesday November 01, 2023 @12:56PM (#38101158)
Yup for only identifying a system that’s easier. If this is all the telemetry is ever planned to do then that’s all you need. The benefit of having a local hash function is when you want to transmit multiple ids for data. E.g in a word processor you might transmit hash(salt+username) on start and hash(salt+filename) when opening a document and so on. That way you can send identifiers for things that are sensitive or private like file names in a standardized way and you don’t need to keep track of N generated guids for N use cases.

On the telemetry server you get e.g

Function “print” used by user 123 document 345. Using that you can do things like answering how many times an average document is printed or how many times per year an average user uses the print function.

Re:Bear Does Analytics with CSS by robertlagrant on Wednesday November 01, 2023 @06:29PM (#38106268)
IP address is "non-sensitive PII"[0]. It's pretty hard to identify someone from an IP address. Hashing and then deleting every day is very reasonable.

[0] https://www.ibm.com/topics/pii

Re:Bear Does Analytics with CSS by remram on Wednesday November 01, 2023 @09:06PM (#38107635)
What you're describing is called "pepper". What's called "salt" is not varied between rows and therefore not stored with the hash (and best stored far away from the hash).
Re:Bear Does Analytics with CSS by BeefWellington on Thursday November 02, 2023 @09:48AM (#38113463)
You have this exactly backwards.
Re:Bear Does Analytics with CSS by remram on Thursday November 02, 2023 @01:15PM (#38116833)
You're right of course, that's what I get by posting late at night. Can't edit or delete anymore.
Re:Bear Does Analytics with CSS by tptacek on Wednesday November 01, 2023 @09:51AM (#38098159)
Salting a standard cryptographic hash (like SHA2) doesn't do anything meaningful to slow a brute force attack. This problem is the reason we have password KDFs like scrypt.

(I don't care about this Bear analytics thing at all, and just clicked the comment thread to see if it was the Bear I thought it was; I do care about people's misconceptions about hashing.)

Re:Bear Does Analytics with CSS by alkonaut on Wednesday November 01, 2023 @10:41AM (#38098821)
What do you mean by "brute force" in the context of reversing PII that has been obscured by a one way hash? My IP number passed through SHA1 with a hash (which I generated and stored safely on my machine) is 6FF6BA399B75F5698CEEDB2B1716C46D12C28DF5

The only thing you can brute force from that is some IP and some salt such that SHA1(IP+Salt) = 6FF6BA399B75F5698CEEDB2B1716C46D12C28DF5 But you'll find millions of such IPs. It's not revealing my IP even if you manage to find a match?

Re:Bear Does Analytics with CSS by infinityio on Wednesday November 01, 2023 @11:02AM (#38099134)
If you also explicitly mentioned the salt used (as bear appear to have done?), this just becomes a matter of testing 4 billion options and seeing which matches
Re:Bear Does Analytics with CSS by alkonaut on Wednesday November 01, 2023 @11:07AM (#38099234)
I think it's just unsalted in the example code. Or you could argue that the date is kind of used as a salt. But the point was that salting + hashing is fine for PII in telemetry if and only if the salt stays on the client. It might be difficult to do without JS though.
Re:Bear Does Analytics with CSS by remram on Wednesday November 01, 2023 @09:04PM (#38107615)
What does "stay on the client" mean? It has to be consistent across visits and you don't want to use cookies (otherwise you don't need to mess with addresses at all). You have no option except sending every client the same salt.
Re:Bear Does Analytics with CSS by alkonaut on Thursday November 02, 2023 @04:03AM (#38110301)
In this context it means exactly that: staying on the client. And yes that means using cookies (or rather, local storage probably). So this is requiring consent no matter how you do it. But note that the system in the article also requires consent since it sends PII (the IP) over the wire and saves it on the server. It's reversible and not anonymous - so it's even worse than using a cookie without consent I'd say.

Yes if all you ever want to send is a unique visitor ID then there is no point in having a local hash, because you can just generate a random ID and use that to identify the user.

What I mean is that if you want to send multiple pieces of PII (such as an IP, a filename, a username,...) then the only way to do that safely is to send hash(salt+filename) for example, where the salt is not known to the server receiving the hash. The IP in the suggestion to use a locally stored hash here just represented "PII that should be sent anonymously" and not "A good way of identifying a unique system".

Re:Bear Does Analytics with CSS by michaelmior on Wednesday November 01, 2023 @11:06AM (#38099202)
> Salting a standard cryptographic hash (like SHA2) doesn't do anything meaningful to slow a brute force attack.

Sure, but it does at least prevent the use of rainbow tables. Arguably not relevant in this scenario, but it doesn't mean that salting does nothing. Rainbow tables can speed up attacks by many orders of magnitude. Salting may not prevent each individual password from being brute forced, but for most attackers, it probably will prevent your entire database from being compromised due to the amount of computation required.

Re:Bear Does Analytics with CSS by tptacek on Wednesday November 01, 2023 @01:43PM (#38101926)
Rainbow tables don't matter. If you're discussing the strength of your scheme with or without rainbow tables, you have already lost.

https://news.ycombinator.com/item?id=38098188

Re:Bear Does Analytics with CSS by robertlagrant on Wednesday November 01, 2023 @06:32PM (#38106292)
That's just a link where you claim the same thing. What's your actual rationale? Do you think salting is pointless?
Re:Bear Does Analytics with CSS by tptacek on Thursday November 02, 2023 @09:30PM (#38123185)
I think it's meaningless. Every password KDF is randomized. But randomization isn't what makes them difficult to brute-force; non-password-KDF "salted" hashes are extremely easy to brute force, which is the whole reason we have password KDFs.

"Salted hashes" are one of the more treacherous security cargo cults, because they create the impression that the big problem you have to solve hashing a password is somehow mixing in a salt. No: just doing that by itself doesn't accomplish anything meaningful at all.

Re:Bear Does Analytics with CSS by robertlagrant on Friday November 03, 2023 @05:39AM (#38126397)
Understood, but I think this is just people using "hash" and "KDF" interchangeably. Agree that a KDF is the way to go, but salting it is also a good idea to explode the search space.
Re:Bear Does Analytics with CSS by michaelmior on Thursday November 02, 2023 @01:04PM (#38116644)
I don't follow your point. Yes, you can brute force. But if I have 50,000 unsalted password hashes, I can crack those using rainbow tables much faster than brute forcing all 50,000. For a single password hash, I agree it probably doesn't really matter.
Re:Bear Does Analytics with CSS by juliusdavies on Thursday November 02, 2023 @05:05PM (#38120127)
I don't understand why anyone would ever have 50,000 or even 1 unsalted password hash.