CC: | shmulik.bibi [...] gmail.com |
Subject: | Net-DNS-SEC bug in sub 'verify' of keyset module |
Date: | Mon, 21 Nov 2011 17:16:14 +0200 |
To: | bug-Net-DNS-SEC [...] rt.cpan.org |
From: | שמוליק ביבי <shmulik.bibi [...] gmail.com> |
Hello,
First of all i wanted to say thank you for contributing to the open source
community.
I appreciate your effort and time.
I've seem to have found a bug in the "Net::DNS::Keyset" module, in the
"verify" subroutine.
The bug is related to having 2 keys with an identical keytag and name (it
is legitimate according to RFC).
I saw it when creating a new "Net::DNS::Keyset" object from packet, but i
guess it's related to any scenario in which the RRSIG is validated.
I'll try to describe the bug and the suggested fix, hopefully it will be
clear enough (English is not my native language, sorry).
*Module version:* 0.16 (latest ATM).
*Keyset revision:* 728
*OS:* WIndows XP (not related to the bug though).
*Perl version:* 5.10.1 (not related to the bug though).
The simplified flow of "verify" (only the part relevant to the bug) is:
- Foreach Key:
- Foreach RRSIG:
- Check if this RRSIG keytag and signame matches the current key's
keytag and name.
- If yes - verify the signature, and return an error if it
failed. <------
Here is the bug
...
The problem is that it's possible that there will be 2 keys with the same
keytag and name on the DNSKEY packet.
As a result this code can find the first matching RRSIG, that was signed by
the second key, and fail (instead of continuing to the correct RRSIG).
One possible fix is to continue to loop on all RRSIG until a *verified*
match is found, and return an error only if none of the RRSIG matched.
I attached the fix I wrote and tested for this function, however note that
I'm no expert, so don't expect a perfect code :) I added it just in case it
will help somehow.
Also note that I changed the code a bit regardless, since I needed to print
more info on errors.
the basic flow I used is:
- Foreach Key:
- Foreach RRSIG:
- Check if this RRSIG keytag and signame matches the current key's
keytag and name.
- If yes - verify the signature.
- If it verifies raise the flag that says we've found a
match, and stop looping on RRSIGs.
- If it fails save the error aside and continue to the
next RRSIG.
- If no RRSIG found (flag is zero) set an error and return 0.
...
Please note that I'm reporting this bug as a gratitude to your work, and in
order to save other people the time debugging this. I'm not in need for a
fix so please don't rush yourself because of me.
If you need any more info please don't hesitate to contact me.
Thank you for your kind work,
Shmulik
Message body is not shown because sender requested not to inline it.