News for hackers. Stuff that matters.
Re:Companies must stop using Google Analytics by bunnyfoofoo on Tuesday July 04, 2023 @07:18AM (#36585147)
You can’t hash an ipv4 address. It’s trivial to brute force all possibilities given the limited problem space.
Re:Companies must stop using Google Analytics by leononame on Tuesday July 04, 2023 @07:24AM (#36585185)
But you could use a salt, right?
Re:Companies must stop using Google Analytics by wyufro on Tuesday July 04, 2023 @07:41AM (#36585346)
Only if the salt is kept secret. There also needs to be a different salt value per ip, obviously. But given those conditions, it works.
Re:Companies must stop using Google Analytics by Qwertious on Tuesday July 04, 2023 @07:38AM (#36585317)
A salt will render rainbow tables useless, but AIUI will not prevent brute-forcing after the fact. IPv4 has ~4 billion addresses, which would be too expensive for data analytics but could be brute-forced if someone really wants this one piece of data in particular.
Re:Companies must stop using Google Analytics by worksonmine on Tuesday July 04, 2023 @07:34AM (#36585277)
That's why you use a salt, which is what I assume is meant by "non-reversibly".
Re:Companies must stop using Google Analytics by sweetjuly on Tuesday July 04, 2023 @08:57AM (#36586045)
Salts provide resistance against bulk bruteforce by making it so that you can't identify which hashes are the same plaintext without actually computing all of them. The issue is still that there are not that many IPv4 addresses and so even with very heavy algorithms it would be trivial to break.
Re:Companies must stop using Google Analytics by worksonmine on Tuesday July 04, 2023 @09:17AM (#36586249)
But there are infinite numbers of salts. Please explain how this could be brute-forced as long as the salt is used correctly? What am I missing?
Re:Companies must stop using Google Analytics by ericpauley on Tuesday July 04, 2023 @09:36AM (#36586458)
No matter what strategy you use to hash IPs, if you can correlate to an IP you can find the original IP by just trying all options. It doesn’t matter what you do because 4B unique possibilities is just too low to prevent brute forcing while maintaining utility.

If you use a random salt, then you need to store it or else the stored value has no utility. However you implement retrieval of that salt it can just be brute forced.

Re:Companies must stop using Google Analytics by worksonmine on Tuesday July 04, 2023 @11:28AM (#36587949)
The salt could be stored as a cookie and you can follow the session but never be able to reverse the hash yourself. Any match you get in the brute-force attempt might as well be a collision.

The entropy can be in the salt, you're all making it sound way too easy. The requirement is "non-reversible". Given infinite time everything can be brute-forced, but this is the mossad/not-mossad problem.

It's good enough for storing passwords, where the salt is plain-text.

Re:Companies must stop using Google Analytics by ericpauley on Thursday July 06, 2023 @10:19AM (#36616208)
That’s just unique identifiers with extra steps.
Re:Companies must stop using Google Analytics by 3np on Tuesday July 04, 2023 @09:45AM (#36586569)
Could you be more precise with what envision by "correctly"? If you use a shared salt for all or a significant portion of rows, then it's a realistic matter of bruteforcing to cover your entire table, given that the attacker has been able to recover the salt.

Even without any cracking at all, shared salt would mean that rows can be correlated if the attacker can identify a single row and correlate that to the target.

Let's say you use up the game and use per-row salts, like here: https://stackoverflow.com/questions/4159827/another-question...

Given an attacker wanting to pull out information about a specific user, and they have on their hands your salted dataset, the salts, and a handful of IP addresses that the target is known to be associated with from other datasets, it's still trivial to brute-force.

Even increasing it to a set of a few thousand IP addresses (say, a handful of /24s) it should be perfectly realistic, assuming you don't use enough rounds that your infrastructure is spending a majority of its CPU-time only performing psuedoanonymizing hashing.

Oh, and if you use per-row salts, is any of that data still usable in the first place?

The above is besides the point of the IPv4 address space being small enough to exhaust and shows why this is an issue for IPv6 addresses as well.

Re:Companies must stop using Google Analytics by jameshart on Tuesday July 04, 2023 @11:12AM (#36587737)
If it's shared, it's not a salt.

The term of art in that case is 'pepper'.

Re:Companies must stop using Google Analytics by 3np on Tuesday July 04, 2023 @01:09PM (#36589536)
First time I hear this interpretation. A shared salt is still a (very poor) salt. A pepper would not be stored alongside the ciphertexts, if at all.
Re:Companies must stop using Google Analytics by antod on Tuesday July 04, 2023 @06:33PM (#36593367)
Isn't it the other way around? Most salted hash implementations share the salt by embedding it in the hash. It's pepper that isn't shared.

After rereading, I suspect by 'shared' you meant 'non unique' rather than 'public'?

Re:Companies must stop using Google Analytics by jameshart on Thursday July 06, 2023 @09:03AM (#36615120)
Why would ‘shared’ mean ‘public’? And in most password hashing contexts the salt and hash are not ‘public’ either.
Re:Companies must stop using Google Analytics by michaelcampbell on Wednesday July 05, 2023 @08:57AM (#36599780)
That's backwards.

> In cryptography, a pepper is a secret added to an input such as a password during hashing with a cryptographic hash function. This value differs from a salt in that it is not stored alongside a password hash, but rather the pepper is kept separate in some other medium, such as a Hardware Security Module.

https://en.wikipedia.org/wiki/Pepper_(cryptography)

Re:Companies must stop using Google Analytics by jameshart on Wednesday July 05, 2023 @05:21PM (#36607330)
Apparently we understand words differently.

A salt is a unique random value added to each value when hashing. Obviously, such a salt needs to be stored alongside each value because it’s random and unique. If you don’t store it how could you possibly ever figure out what it is?

A pepper is a shared value added to lots of different things before they are hashed. It isn’t unique to each value, so it doesn’t need to be stored alongside them. Although it still needs to be stored somewhere. But hey, you could also store it alongside every value you store. This is a thing sometimes done when you do ‘per user’ pepper, where for example the pepper is itself a a username or something - so your pepper is also in the database alongside the passwords - but that doesn’t make it a salt.

If you are using the same piece of data to season multiple things before hashing, you are using ‘pepper’ not ‘salt’.

Re:Companies must stop using Google Analytics by 3np on Wednesday July 05, 2023 @07:44PM (#36608857)
I think you may be alone in understanding the words "pepper" and "salt" this way.
Re:Companies must stop using Google Analytics by jameshart on Thursday July 06, 2023 @09:08AM (#36615174)
Try reading the rest of the Wikipedia article beyond the first paragraph. Particularly the section on ‘shared-secret pepper’ and ‘unique pepper per user’.
Re:Companies must stop using Google Analytics by tjoff on Tuesday July 04, 2023 @10:01AM (#36586804)
You need to protect it from yourself.

If you know the salt then you can trivially brute-force it yourself and now you are not GDPR-compliant.

If you don't know the salt then you'll have to use a new salt for each IP and then all hashed IPs will be unique and you have no way of correlating them so it is all completely worthless.

Re:Companies must stop using Google Analytics by sweetjuly on Tuesday July 04, 2023 @10:52AM (#36587517)
The salt is stored in plaintext alongside the hash and simply concatenated. If your scheme, for example, is h := H(ip, salt) := sha256(ip :: salt), bruteforcing is simply a matter of trying all values of ip:

    for i in 0..<(1<<32):
        if H(i, salt) == h:
            return i
Re:Companies must stop using Google Analytics by worksonmine on Tuesday July 04, 2023 @11:32AM (#36588030)
The salt doesn't have to be plain-text, that's an implementation detail in the common password hashing algorithms for obvious reasons. The requirement was that the hash should be non-reversible. Store the salt in a (http-only) session cookie and concatenate it to the IP before the hashing rounds. Put your entropy in the salt and any brute-force attempt is theoretical. For every session you need to compute the exact combination of IP + salt (which isn't even known to the server).
Re:Companies must stop using Google Analytics by 3np on Tuesday July 04, 2023 @01:13PM (#36589591)
At that point, what value does the salted+hashed IP address give you over a randomly generated number (say, a UUID) per session?
Re:Companies must stop using Google Analytics by worksonmine on Tuesday July 04, 2023 @01:44PM (#36590067)
None, I'm not arguing for the solution. Proxying through a PHP script just to keep using Google Analytics is overkill when private self-hosted solutions exist. I'm simply showing how you can anonymize IPs even from yourself, if the goal is to anonymize from only Google and not the server it could be useful across sessions.

The solution being overkill does not mean my first comment 'That's why you use a salt, which is what I assume is meant by "non-reversibly"' is wrong.

Re:Companies must stop using Google Analytics by jeltz on Tuesday July 04, 2023 @08:42AM (#36585909)
I have not researched it but I wonder if you can even hash IPv6 addresses. The issue I see is that allocations could be too regular so even if the full space is huge most addresses may occupy a small and predictable part of it.
Re:Companies must stop using Google Analytics by pixl97 on Tuesday July 04, 2023 @11:23AM (#36587890)
Depends how you define IP in this sense. Each full individual IPv6, unlikely as most consumer devices are getting a somewhat random internal address on their network.

Now, with IPv6 for most consumers the first 64 bits is generally enough to define the edge network device that would be covered by a single IPv4 these days.

Re:Companies must stop using Google Analytics by marcosdumay on Tuesday July 04, 2023 @01:24PM (#36589777)
> the first 64 bits is generally enough to define the edge network

One complication is that hashing removes this structure. If you use any good algorithm, you will need to test the entire address to recover any part of it.

I am very wary of IPv6 addresses being so heavily biased into 00 or ff segments that the address space doesn't actually add much entropy. So, I'd go with no, it's not safe to hash them. But if you get some random ones, I am really not sure.

Re:Companies must stop using Google Analytics by zyx321 on Tuesday July 04, 2023 @11:32AM (#36588034)
How about this:

Server-wide salt. Randomly generated every 24h or server reboot (whichever is sooner).

The salt is not saved alongside the hashed IP, it is not saved anywhere whatsoever. There is no log of previous salts.

You can still track a user session across multiple page calls, but the hash can not track them across different sites.