Open issuefiler opened 1 year ago
oooh i was mentioned, yup, i have no clue what i'm looking at
Since Buffer.from("\uD800").equals(Buffer.from("\uDFFF"))
, node-bencode
can produce multiple dictionary entries with the same key, which is invalid.
Bug
node-bencode
can produce dictionary entries with duplicate keys.node-bencode
assumes that binary string keys made out of unique Javascript string keys are unique as well, which is false.https://github.com/webtorrent/node-bencode/blob/ee70f267c8d34b9a94820ca8c42cd67d1274fc89/lib/encode.js#L53-L55 https://github.com/ThaUnknown/uint8-util/blob/149c44c010b3ad17a7904c4266545bbca1fd4403/_node.js#L13
Proof-of-concept
For example, let
node-bencode
try encoding{"\uD800": 1, "\uDFFF": 2}
. It’ll produce dictionary entries with the duplicate key,"3:\xEF\xBF\xBD"
.