zmap / zlint

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

Inconsistency in `IsOnionV2Address` util function #683

Open mathewhodson opened 2 years ago

mathewhodson commented 2 years ago

The IsOnionV2Address function comments say, "The second-to-the-right most label is a 16 character long, base32." The code actually seems to check the left-most label.

Based on similar code in IsOnionV3Address, the code in IsOnionV2Address should be updated to this:

address := labels[len(labels)-2]
if len(address) != 16 {
    return false
}
_, err := onionBase32Encoding.DecodeString(address)

_Originally posted by @mathewhodson in https://github.com/zmap/zlint/pull/677#discussion_r894899072_