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

enforce certificate correctness in TBSCertificate.SignWith #1266

Merged
merged 6 commits into from
Jan 9, 2025

Conversation

JackDoanRivian
Copy link
Contributor

No description provided.

cert/sign.go Outdated Show resolved Hide resolved
cert/sign.go Outdated
if n.Addr().Zone() != "" {
return fmt.Errorf("unsafe_networks may not contain zones: %s", n)
}
//todo are unsafe networks that overlap networks allowed?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, you might have 10.0.0.0/8 point to one host but 10.0.0.0/16 to another, it makes less sense to have overlapping in a CA certificate but that's also fine.

cert/sign.go Outdated
@@ -76,15 +76,89 @@ func (t *TBSCertificate) Sign(signer Certificate, curve Curve, key []byte) (Cert
}
}

// readyToSign checks all signing requirements that don't require us to cross-reference with a CA
func (t *TBSCertificate) readyToSign() error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I had started on this validation in cert_v1.go and cert_v2.go specifically that way we don't accidentally leak rules from one version to the other that shouldn't apply. We also need to do these things at unmarshal (or at a minimum at handshake and cert loading time) to ensure we are working with a valid certificate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yeah nice catch, I'll move this

cert/sign.go Outdated
if t.Version == Version1 {
return fmt.Errorf("certificate v1 may not contain IPv6 unsafe networks: %v", t.Networks)
}
if !hasV6Networks && !t.IsCA {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't disagree but I am curious if this will haunt us in the future

cert/sign.go Outdated
return fmt.Errorf("IPv6 unsafe networks require an IPv6 address assignment")
}
} else if n.Addr().Is4() {
if !hasV4Networks && !t.IsCA {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't disagree but I am curious if this will haunt us in the future

@nbrownus nbrownus merged commit 8704047 into slackhq:cert-v2 Jan 9, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants