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

Prevent panics on client-cert authenticated requests #132

Merged
merged 1 commit into from
Jul 22, 2021

Conversation

stlaz
Copy link
Collaborator

@stlaz stlaz commented Jul 19, 2021

Setting a nil-value typed object in the DelegatingAuthenticatorConfig
will cause the generic logic to still evaluate is as non-nil since
Golang does not consider (*type)(nil) as nil in == nil comparison
unless type == nil, too.

This leads to a setup of an x509 authenticator that attempts to call
VerifyOptions on a nil object.

fixes #131

@@ -42,19 +42,20 @@ func NewDelegatingAuthenticator(client authenticationclient.TokenReviewInterface
p *dynamiccertificates.DynamicFileCAContent
Copy link

Choose a reason for hiding this comment

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

does this still need to be declared up here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's used in the return value

TokenAccessReviewClient: client,
APIAudiences: authenticator.Audiences(authn.Token.Audiences),
}

if len(authn.X509.ClientCAFile) > 0 {
p, err = dynamiccertificates.NewDynamicCAContentFromFile("client-ca", authn.X509.ClientCAFile)
Copy link

Choose a reason for hiding this comment

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

p, err := ?

Copy link

@slaskawi slaskawi left a comment

Choose a reason for hiding this comment

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

/lgtm

@simonpasquier
Copy link
Contributor

LGTM.
@brancz would you able to have a look (Serg is offline for now)? For context, here is an example of the panic when a client uses client TLS authentication but kube-rbac-proxy isn't configured with any CA.

Copy link
Collaborator

@paulfantom paulfantom left a comment

Choose a reason for hiding this comment

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

lgtm on green

@paulfantom
Copy link
Collaborator

paulfantom commented Jul 21, 2021

Fix for CI failure is in #133

@paulfantom
Copy link
Collaborator

@stlaz Could you rebase to include merged #133 so e2e tests can be run in CI?

Setting a nil-value typed object in the `DelegatingAuthenticatorConfig`
will cause the generic logic to still evaluate is as non-nil since
Golang does not consider `(*type)(nil)` as `nil` in `== nil` comparison
unless `type == nil`, too.

This leads to a setup of an x509 authenticator that attempts to call
`VerifyOptions` on a nil object.
@paulfantom
Copy link
Collaborator

I rebased the PR myself as @stlaz is on vacations :)

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.

kube-rbac-proxy segfaults when no client-ca is configured but client-cert auth is attempted
5 participants