Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make TsigVerify check time after signature per rfc2845bis #1135

Merged
merged 3 commits into from Jul 18, 2020

Conversation

jinmeiib
Copy link
Contributor

The current implementation of TsigVerify is compliant to RFC2845 in that it first checks 'time signed' and then verifies the signature. But this logic is known to have a security vulnerability as reported in CVE-2017-3142/3143.

The protocol is being revised as draft-ietf-dnsop-rfc2845bis, reversing the order of these checks. This PR implements the new behavior in a straightforward way. While the new protocol spec is still an internet draft, it's already in the RFC editor queue, so I believe it's mature enough.

(Added test covers this specific case with some other error conditions from TsigVerify)

@codecov-commenter
Copy link

codecov-commenter commented Jul 16, 2020

Codecov Report

Merging #1135 into master will increase coverage by 0.10%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1135      +/-   ##
==========================================
+ Coverage   55.32%   55.43%   +0.10%     
==========================================
  Files          41       41              
  Lines       10109    10110       +1     
==========================================
+ Hits         5593     5604      +11     
+ Misses       3488     3482       -6     
+ Partials     1028     1024       -4     
Impacted Files Coverage Δ
tsig.go 54.67% <100.00%> (+6.78%) ⬆️
msg.go 76.53% <0.00%> (-0.69%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50b4756...e4c64dd. Read the comment docs.

tsig_test.go Outdated
// tweak the algorithm name in the wire data, resulting in the "unknown algorithm" error.
msgData := buildMsgData(timeSigned)
garbage := []byte("bogus")
copy(msgData[67:67+len(garbage)], garbage)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just be: copy(msgData[67:], "bogus").

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, updated it as suggested.

tsig_test.go Outdated
return msgData
}

checkError := func(expected, actual error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditch this because it doesn’t match the rest of the tests and just include only the if actual != expected check directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean instead of

checkError(ErrTime, tsigVerify(buildMsgData(timeSigned), testSecret, "", false, timeSigned+301))

do something like this?

	if err := tsigVerify(buildMsgData(timeSigned), testSecret, "", false, timeSigned+301); err != ErrTime {
		t.Fatalf("expected an error '%v' but got '%v'", ErrTime, err)
	}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jinmeiib Exactly that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmthrgd okay, updated as such.

Copy link
Collaborator

@tmthrgd tmthrgd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@miekg
Copy link
Owner

miekg commented Jul 18, 2020 via email

@cbot cbot bot merged commit 9093928 into miekg:master Jul 18, 2020
aanm pushed a commit to cilium/dns that referenced this pull request Jul 29, 2022
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.

None yet

4 participants