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

Sanitize certificates from routes in the router #13897

Merged
merged 1 commit into from
May 12, 2017

Conversation

smarterclayton
Copy link
Contributor

Ensure that no invalid PEM data is left in the route after extended
validation passes.

@liggitt

@smarterclayton
Copy link
Contributor Author

@Miciah

@smarterclayton
Copy link
Contributor Author

[test]

@smarterclayton smarterclayton force-pushed the sanitize_pem branch 2 times, most recently from 5df4170 to 8942e80 Compare April 27, 2017 21:07
@smarterclayton
Copy link
Contributor Author

smarterclayton commented Apr 28, 2017 via email

@smarterclayton
Copy link
Contributor Author

any comments? [test]

@deads2k
Copy link
Contributor

deads2k commented May 1, 2017

I'm not familiar with the area, but I think @liggitt. Let's give him today.

return buf.Bytes()
}
// ignores blocks that can't be serialized
_ = pem.Encode(buf, block)
Copy link
Contributor

Choose a reason for hiding this comment

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

Open questions:

should we whitelist the PEM block types we allow ("CERTIFICATE", "PRIVATE KEY", "RSA PRIVATE KEY", etc)

When we're validating, are we making sure the data matches the PEM block types? Go's parsing sometimes ignores exact PEM block type matches and will parse any private key from any block type ending in "PRIVATE KEY"

which types does haproxy support?

Is haproxy forgiving about mismatched block type and block content?

@liggitt
Copy link
Contributor

liggitt commented May 1, 2017

Sanitization is a strict improvement, but the questions about haproxy type support and type/content mismatch are important to find out before we open up certs

@smarterclayton
Copy link
Contributor Author

smarterclayton commented May 1, 2017 via email

@smarterclayton
Copy link
Contributor Author

Updated

@@ -111,8 +115,94 @@ func ValidateRouteStatusUpdate(route *routeapi.Route, older *routeapi.Route) fie
return allErrs
}

type blockVerifierFunc func(block *pem.Block) error

func publicKeyBlockVerifier(block *pem.Block) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

modifying in-place is a little unexpected... I'd expect a new block returned. there are other bits (block headers, etc) that this isn't clearing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should it clear them?

Copy link
Contributor

Choose a reason for hiding this comment

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

ummm... not sure? the uses I've seen for PEM headers in these types of blocks are for encrypted private keys, which we don't support

if block == nil {
return buf.Bytes(), nil
}
fn, ok := knownBlockDecoders[block.Type]
Copy link
Contributor

Choose a reason for hiding this comment

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

some ec private keys will include an EC PARAMETERS block that should be dropped

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we should just drop unrecognized block types and continue (as long as we got at least one recognized block)

@liggitt
Copy link
Contributor

liggitt commented May 10, 2017

tests are a little light, a few nits, lgtm otherwise

Ensure that no invalid PEM data is left in the route after extended
validation passes.
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 17abab0

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/1329/) (Base Commit: 2d26eae)

@smarterclayton
Copy link
Contributor Author

more tests added.

@smarterclayton
Copy link
Contributor Author

nits addressed

@liggitt
Copy link
Contributor

liggitt commented May 11, 2017

LGTM

@smarterclayton
Copy link
Contributor Author

[merge]

1 similar comment
@smarterclayton
Copy link
Contributor Author

smarterclayton commented May 12, 2017 via email

@smarterclayton
Copy link
Contributor Author

smarterclayton commented May 12, 2017 via email

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 17abab0

@openshift-bot
Copy link
Contributor

openshift-bot commented May 12, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/621/) (Base Commit: 4f2b9d7) (Image: devenv-rhel7_6225)

@openshift-bot openshift-bot merged commit 39283a6 into openshift:master May 12, 2017
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