News for hackers. Stuff that matters.
Re:"YOLO" is not a valid hash construction by theamk on Saturday August 24, 2024 @05:50PM (#41341907)
It's interesting that using JSON encoding for all messages eliminates many of the problems.

ambiguous encoding? Nothing ambiguous about JSON, you don't even need any separator. Or merge them into json array.

length-extension attacks? appending non-whitespace to json makes it invalid (for sane decoders at least)

Re:"YOLO" is not a valid hash construction by skybrian on Saturday August 24, 2024 @06:35PM (#41342311)
Yes, but there are lots of ways to get different encodings (and therefore hashes) for the same data: whitespace, JSON object key order, and the different ways of escaping characters.

If you want a unique hash (like, for a hash table lookup) then you'll need to sort the keys of every object and use a particular implementation of JSON.stringify.

(Also, what do you mean by "you don't even need any separator?")

Re:"YOLO" is not a valid hash construction by magicalhippo on Saturday August 24, 2024 @06:50PM (#41342462)
XML has a complex solution for this, canonicalization[1], to enable signed XMLs[2]. Seems some folks are trying the same with JSON[3].

[1]: https://en.wikipedia.org/wiki/Canonical_XML

[2]: https://en.wikipedia.org/wiki/XML_Signature

[3]: https://www.rfc-editor.org/rfc/rfc8785

Re:"YOLO" is not a valid hash construction by justincormack on Sunday August 25, 2024 @07:39AM (#41346536)
There are a few canonical json specs but they are different and in my experience the implementations are not correct.