Skip to content

Improve reporting of malformed RRSIG signatures - #299

Open
marc-vanderwal wants to merge 1 commit into
NLnetLabs:developfrom
marc-vanderwal:bugfix/malformed-rrsig-error-reporting
Open

Improve reporting of malformed RRSIG signatures#299
marc-vanderwal wants to merge 1 commit into
NLnetLabs:developfrom
marc-vanderwal:bugfix/malformed-rrsig-error-reporting

Conversation

@marc-vanderwal

Copy link
Copy Markdown

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.

(See also: zonemaster/zonemaster-engine#1512 for an example of how the problem addressed by this PR made diagnosis harder).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant