Improve reporting of malformed RRSIG signatures - #299
Open
marc-vanderwal wants to merge 1 commit into
Open
Conversation
When verifying an RRset signed with algorithm 13, e.g. with
ldns_verify_time(), if the corresponding RRSIG’s signature is malformed,
the verification fails (as it should) but the status code being returned
is LDNS_STATUS_MEM_ERR (“General memory error”). Which may lead someone
to wrongly believe that there is a serious problem with LDNS.
For DNSSEC signatures made with cipher suites based on DSA and ECDSA,
LDNS converts the signature from its DNS wire format to ASN.1 for
compatibility with OpenSSL (see ldns_convert_dsa_rrsig_rdf2asn1() and
ldns_convert_ecdsa_rrsig_rdf2asn1()). This conversion can fail, either
because of memory allocation failures or because of bad input.
However, the caller (ldns_rrsig2rawsig_buffer()) wrongly assumed that if
the conversion failed, it is necessary a “general memory error”, hence
turning an error caused by bad input (i.e. a malformed signature in an
RRSIG) into a misleading error.
With this commit, errors raised by
ldns_convert_{dsa,ecdsa}_rrsig_rdf2asn1() are properly propagated back
up the caller chain. That way, if verifying a signature fails because
the RRSIG’s signature is malformed, the ldns_status is
LDNS_STATUS_SYNTAX_RDATA_ERR instead of LDNS_STATUS_MEM_ERR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When verifying an RRset signed with algorithm 13, e.g. with
ldns_verify_time(), if the corresponding RRSIG’s signature is malformed, the verification fails (as it should) but the status code being returned isLDNS_STATUS_MEM_ERR(“General memory error”). Which may lead someone to wrongly believe that there is a serious problem with LDNS.For DNSSEC signatures made with cipher suites based on DSA and ECDSA, LDNS converts the signature from its DNS wire format to ASN.1 for compatibility with OpenSSL (see
ldns_convert_dsa_rrsig_rdf2asn1()andldns_convert_ecdsa_rrsig_rdf2asn1()). This conversion can fail, either because of memory allocation failures or because of bad input.However, the caller (
ldns_rrsig2rawsig_buffer()) wrongly assumed that if the conversion failed, it is necessary a “general memory error”, hence turning an error caused by bad input (i.e. a malformed signature in an RRSIG) into a misleading error.With this commit, errors raised by
ldns_convert_{dsa,ecdsa}_rrsig_rdf2asn1()are properly propagated back up the caller chain. That way, if verifying a signature fails because the RRSIG’s signature is malformed, the ldns_status isLDNS_STATUS_SYNTAX_RDATA_ERRinstead ofLDNS_STATUS_MEM_ERR.(See also: zonemaster/zonemaster-engine#1512 for an example of how the problem addressed by this PR made diagnosis harder).