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

Fix panic in CertAuthority.Clone because of non-UTC times. #12057

Merged
merged 10 commits into from
Apr 20, 2022

Conversation

espadolini
Copy link
Contributor

@espadolini espadolini commented Apr 19, 2022

As reported by @eric-belhomme on the Teleport Community slack, ever since we've been using the gogoproto Clone for types.CertAuthority, we've been hitting a panic on every code path that does a Clone on a CertAuthority that has a Rotation.LastRotated field stored with a non-zero (non-UTC) offset - for instance, when attempting to begin a CA rotation. This is caused by gogo/protobuf#519.

Other times stored in the CA, as far as I can tell, have always been stored as UTC, and after #9316 we have been also storing LastRotated as UTC (released in v8.1.3, v7.3.13 and v6.2.27).

This affects every cluster that has completed a rotation before #9316, with a non-UTC local time on the auth server. This PR makes it so that times are loaded as UTC after unmarshaling (similarly to #5712), which doesn't otherwise change any behavior, and doesn't require any changes in the backend.

@espadolini espadolini enabled auto-merge (squash) April 19, 2022 15:22
@espadolini espadolini removed the request for review from ravicious April 19, 2022 15:55
require.Zero(t, offset)

// successfully Clone without panic, see https://github.com/gogo/protobuf/issues/519
_ = caUTC.Clone()
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe require.NotPanics()??

@espadolini espadolini merged commit 89e4c39 into master Apr 20, 2022
@espadolini espadolini deleted the espadolini/ca-utc-fix branch April 20, 2022 08:25
espadolini added a commit that referenced this pull request Apr 20, 2022
* improve ca cmp (#10351)

* Fix panic in `CertAuthority.Clone` because of non-UTC times. (#12057)

Co-authored-by: Forrest <30576607+fspmarshall@users.noreply.github.com>
espadolini added a commit that referenced this pull request Apr 20, 2022
* improve ca cmp (#10351)

* Fix panic in `CertAuthority.Clone` because of non-UTC times. (#12057)

Co-authored-by: Forrest <30576607+fspmarshall@users.noreply.github.com>
espadolini added a commit that referenced this pull request Apr 20, 2022
* improve ca cmp (#10351)

* Fix panic in `CertAuthority.Clone` because of non-UTC times. (#12057)

Co-authored-by: Forrest <30576607+fspmarshall@users.noreply.github.com>
@webvictim webvictim mentioned this pull request Jun 8, 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.

4 participants