zmap / zlint

X.509 Certificate Linter focused on Web PKI standards and requirements.
https://zmap.io
Apache License 2.0
358 stars 107 forks source link

Zlint incorrectly requires TorServiceDescriptors if V3 onion and DNS name #677

Closed christopher-henderson closed 2 years ago

christopher-henderson commented 2 years ago

This patch addresses #676 wherein the presence of a normal DNS entry would trigger a false return on IsOnionV3, resulting in the Onion V3 cert being checked as though it were V2.

I believe that the solution here is to change this from checking whether-or-not all names are V3 into checking whether-or-not at least one name is V2.

@mimi89999

mimi89999 commented 2 years ago

Hmmm. I think that it might be better to write IsOnionV2 and IsOnionV3 that would check .onion names. They could be reused in another lint that would check if .onion names are valid.

mimi89999 commented 2 years ago

In https://github.com/zmap/zlint/blob/master/v3/lints/cabf_br/lint_san_dns_name_onion_invalid.go#L133 you only check the address length, but in https://github.com/zmap/zlint/blob/master/v3/util/onion.go#L25-L39 you check the length and the last byte.

christopher-henderson commented 2 years ago

@mimi89999

I think that it might be better to write IsOnionV2 and IsOnionV3 that would check .onion names. They could be reused in another lint that would check if .onion names are valid.

Sure thing! Indeed, with our newfound access to generics in Go, I went ahead and added some utility functions that help fill the gap of Any and All which would help with this.

In https://github.com/zmap/zlint/blob/master/v3/lints/cabf_br/lint_san_dns_name_onion_invalid.go#L133 you only check the address length, but in https://github.com/zmap/zlint/blob/master/v3/util/onion.go#L25-L39 you check the length and the last byte.

Fair enough, although I think the only extra thing I can reasonably do here is check that it is lowercase base32 encoded. That is, V3 has a number of extra semantics to it, however a V2 address is nothing but a b32 encoded hash of length 16.