Skip Menu |

This queue is for tickets about the Hash-MD5 CPAN distribution.

Report information
The Basics
Id: 101585
Status: resolved
Priority: 0/
Queue: Hash-MD5

People
Owner: MZIESCHA [...] cpan.org
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 0.03
  • 0.04
Fixed in: 0.05



Subject: Digest collision possible
It's quite easy to construct two different arrays or hashes which have the same fingerprint. For example: $ perl -MHash::MD5=sum_array -MTest::More=no_plan -e 'isnt sum_array([1,2]), sum_array([q{1","2}])' not ok 1 # Failed test at -e line 1. # got: '9539d9b288df67c71407a1701e2b99d6' # expected: anything else 1..1 # Looks like you failed 1 test of 1.
Am Sa 17. Jan 2015, 03:00:31, SREZIC schrieb: Show quoted text
> It's quite easy to construct two different arrays or hashes which have > the same fingerprint. For example: > > $ perl -MHash::MD5=sum_array -MTest::More=no_plan -e 'isnt > sum_array([1,2]), sum_array([q{1","2}])' > not ok 1 > # Failed test at -e line 1. > # got: '9539d9b288df67c71407a1701e2b99d6' > # expected: anything else > 1..1 > # Looks like you failed 1 test of 1.
Thank you for your test. I've just forgot this case. In version 0.04 it's fixed.
- arrayref and hashref got an extra element with the number of counted elements (special thanks to SREZIC)
On 2015-01-17 17:53:16, MZIESCHA wrote: Show quoted text
> - arrayref and hashref got an extra element with the number of counted > elements > (special thanks to SREZIC)
Still with 0.04 it's easily possible to create collisions: $ perl5.18.4 -MHash::MD5=sum_array -MTest::More=no_plan -e 'isnt sum_array([q{1","2}, 3]), sum_array([1,q{2","3}])' not ok 1 # Failed test at -e line 1. # got: 'd74f2382924cbf78eb5e5d0ae2c2060c' # expected: anything else 1..1 # Looks like you failed 1 test of 1. I think it's much easier if you use a perfect canonical serialization here. Something like md5_hex(encode_json($data_structure)) or any other serialization algorithm (Data::Dumper, Storable ...), but make sure that the canonical flag in these modules is set.