Re: A proposal to modify `None` so that it hashes to a constant

Chris Angelico <[email protected]> Tue, 29 Nov 2022 13:20:30 +1100
Newsgroups gmane.comp.python.devel
Message-ID <CAPTjJmohowN8Cwh-DZchXD54gU-gHJxmZDfio3ubmxD6QuNtNw@mail.gmail.com>
On Tue, 29 Nov 2022 at 13:12, Oscar Benjamin <[email protected]> wrote:
> As for point 2. the fact that sets are currently non-deterministic is
> actually a relatively new thing in Python. Before hash-randomisation
> set and dict order *was* deterministic but with an arbitrary order.
> That was only changed because of a supposed security issue with hash
> collisions. Prior to that it was well understood that determinism was
> beneficial (honestly I don't understand why I have to state this point
> explicitly: determinism is almost always best in our context).

To clarify: The hash collision attack is a very real one, but specific
to dictionaries of string keys, since there are quite a few ways for
an attacker to send a string that gets automatically parsed into such
a dictionary (eg web app frameworks where the request parameters are
made available as a dictionary). But since that attack surface is *so*
specific, randomization of non-string hashes is unimportant.

ChrisA