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

OCPBUGS-28928: Prevent upgrades for SHA1 default cert and SHA1 route certs #1014

Open
wants to merge 3 commits into
base: release-4.15
Choose a base branch
from

Conversation

gcs278
Copy link
Contributor

@gcs278 gcs278 commented Jan 8, 2024

This PR handles SHA1 certificate upgradeable scenarios for 4.15. With OpenSSL3.0 provided by RHEL9 in 4.16, the router will fail to start if any cert provided is SHA1.

First, if the default certificate on the Ingress Controller object is using SHA1, then set Upgradeable to be False.

Secondly, add a new control loop, route deprecated, that determines upgradeablity by searching for the UnservableInFutureVersions condition in the routes. The UnservableInFutureVersions will be added to the route by openshift/router#555 when a SHA1 certificate exists on the route. It creates an admin-gate if a UnservableInFutureVersions condition is found. This logic assumes any UnservableInFutureVersions route status condition is an upgrade blocker.

This implementation targets 4.15 to 4.16 updates specifically, so it is only targeting the release-4.15 branch and we will be merged in the backport of https://issues.redhat.com/browse/OCPBUGS-26498. The code should not be merged into 4.16.

@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. labels Jan 8, 2024
@openshift-ci-robot
Copy link
Contributor

@gcs278: This pull request references Jira Issue OCPBUGS-26498, which is invalid:

  • expected the bug to target the "4.16.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

If the default certificate is using SHA1, then set Upgradeable to be False. With OpenSSL3.0 provided by RHEL9, the router will fail to start if any cert provided is SHA1.

This commit also removes the logic for setting Upgradeable to be False if the default cert has no SAN. This logic is unnecessary as of OCP 4.10.

pkg/operator/controller/ingress/status.go: Refactor checkDefaultCertificate to check for SHA1-based certs.
pkg/operator/controller/ingress/status_test.go: Add test coverage to Test_computeIngressUpgradeableCondition for SHA1-based certs.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Jan 8, 2024
@gcs278 gcs278 changed the title OCPBUGS-26498: Set Upgradeable=False if default cert uses SHA1 [WIP] OCPBUGS-26498: Set Upgradeable=False if default cert uses SHA1 Jan 8, 2024
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 8, 2024
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 18, 2024
@openshift-ci-robot openshift-ci-robot added the jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. label Jan 26, 2024
@openshift-ci-robot
Copy link
Contributor

@gcs278: This pull request references Jira Issue OCPBUGS-26498, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.16.0) matches configured target version for branch (4.16.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @ShudiLi

In response to this:

If the default certificate is using SHA1, then set Upgradeable to be False. With OpenSSL3.0 provided by RHEL9, the router will fail to start if any cert provided is SHA1.

This commit also removes the logic for setting Upgradeable to be False if the default cert has no SAN. This logic is unnecessary as of OCP 4.10.

pkg/operator/controller/ingress/status.go: Refactor checkDefaultCertificate to check for SHA1-based certs.
pkg/operator/controller/ingress/status_test.go: Add test coverage to Test_computeIngressUpgradeableCondition for SHA1-based certs.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot removed the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Jan 26, 2024
@openshift-ci openshift-ci bot requested a review from ShudiLi January 26, 2024 21:53
@gcs278 gcs278 force-pushed the OCPBUGS-26498 branch 2 times, most recently from 4ea39b1 to a565640 Compare January 30, 2024 16:46
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 30, 2024
@gcs278 gcs278 changed the title [WIP] OCPBUGS-26498: Set Upgradeable=False if default cert uses SHA1 [WIP] OCPBUGS-26498: Prevent upgrades for SHA1 default cert and SHA1 route certs Jan 30, 2024
@openshift-ci-robot
Copy link
Contributor

@gcs278: This pull request references Jira Issue OCPBUGS-26498, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.16.0) matches configured target version for branch (4.16.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @ShudiLi

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

This PR handles SHA1 certificate upgradeable scenarios for 4.15. With OpenSSL3.0 provided by RHEL9 in 4.16, the router will fail to start if any cert provided is SHA1.

First, if the default certificate on the Ingress Controller object is using SHA1, then set Upgradeable to be False. Also remove the logic for setting Upgradeable to be False if the default cert has no SAN. This logic is unnecessary as of OCP 4.10.

Secondly, add a new control loop, route deprecated, that determines upgradeablity by searching for the Deprecated condition in the routes. The Deprecated will be added to the route by openshift/router#555 when a SHA1 certificate exists on the route. It creates an admin-gate if a Deprecated condition is found. This logic assumes any Deprecated route status condition is an upgrade blocker.

This implementation targets 4.15 to 4.16 updates specifically, so will need to be backported to 4.15 to be useful. It can later be removed in 4.16+ as it will be no longer needed.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 30, 2024
@gcs278 gcs278 changed the base branch from master to release-4.15 January 30, 2024 21:45
@openshift-ci-robot openshift-ci-robot added jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. and removed jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels Jan 30, 2024
@openshift-ci-robot
Copy link
Contributor

@gcs278: This pull request references Jira Issue OCPBUGS-26498, which is invalid:

  • expected the bug to target either version "4.15." or "openshift-4.15.", but it targets "4.16.0" instead
  • expected Jira Issue OCPBUGS-26498 to depend on a bug targeting a version in 4.16.0 and in one of the following states: MODIFIED, ON_QA, VERIFIED, but no dependents were found

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

This PR handles SHA1 certificate upgradeable scenarios for 4.15. With OpenSSL3.0 provided by RHEL9 in 4.16, the router will fail to start if any cert provided is SHA1.

First, if the default certificate on the Ingress Controller object is using SHA1, then set Upgradeable to be False. Also remove the logic for setting Upgradeable to be False if the default cert has no SAN. This logic is unnecessary as of OCP 4.10.

Secondly, add a new control loop, route deprecated, that determines upgradeablity by searching for the Deprecated condition in the routes. The Deprecated will be added to the route by openshift/router#555 when a SHA1 certificate exists on the route. It creates an admin-gate if a Deprecated condition is found. This logic assumes any Deprecated route status condition is an upgrade blocker.

This implementation targets 4.15 to 4.16 updates specifically, so will need to be backported to 4.15 to be useful. It can later be removed in 4.16+ as it will be no longer needed.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@gcs278 gcs278 changed the title [WIP] OCPBUGS-26498: Prevent upgrades for SHA1 default cert and SHA1 route certs [WIP] OCPBUGS-TBD: Prevent upgrades for SHA1 default cert and SHA1 route certs Jan 30, 2024
if cert.Subject.CommonName == domain && !foundSAN {
return fmt.Errorf("certificate in secret %s/%s has legacy Common Name (CN) but has no Subject Alternative Name (SAN) for domain: %s", secret.Namespace, secret.Name, domain)
if cert.SignatureAlgorithm == x509.SHA1WithRSA || cert.SignatureAlgorithm == x509.ECDSAWithSHA1 {
return fmt.Errorf("certificate in secret %s/%s has weak SHA1 signature algorithm: %s", secret.Namespace, secret.Name, domain)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Worth a link out to https://docs.openshift.com/container-platform/4.16/release_notes/ocp-4-16-release-notes.html#ocp-4-16-networking ?

Sure, added.

And possibly extending that section to fix "HaProxy" -> "HAProxy" and link https://docs.openshift.com/container-platform/4.16/networking/routes/secured-routes.html ?

Yea seems like a reasonable update, let me follow up with docs to see if they are interested.

@gcs278
Copy link
Contributor Author

gcs278 commented May 3, 2024

/retest-required

@ShudiLi
Copy link
Member

ShudiLi commented May 15, 2024

/jira refresh

@openshift-ci-robot
Copy link
Contributor

@ShudiLi: This pull request references Jira Issue OCPBUGS-28928, which is invalid:

  • release note text must be set and not match the template OR release note type must be set to "Release Note Not Required"
  • expected dependent Jira Issue OCPBUGS-26498 to be in one of the following states: VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA), but it is ON_QA instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

foundSAN = true
}
}
if cert.Subject.CommonName == domain && !foundSAN {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing this SAN upgrade logic seems problematic as we are backporting this in 4.15, so then 4.15 will not have this logic, but 4.16+ will have it.

I think the logic needs to be removed in the master branch instead of removed in a backport like this. The 4.16 bug https://issues.redhat.com/browse/OCPBUGS-26498 is already ON_QA and we've branched to 4.17, so it's probably too late to merge this in master and try to backport it.

I think I should just handle this later when appropriate, keep this backport as "additive" only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to not remove the SAN logic.

If the default certificate is using SHA1, then set Upgradeable to be
False. With OpenSSL3.0 provided by RHEL9, the router will fail to start
if any cert provided is SHA1.
@openshift-ci-robot
Copy link
Contributor

@gcs278: This pull request references Jira Issue OCPBUGS-28928, which is invalid:

  • expected dependent Jira Issue OCPBUGS-26498 to be in one of the following states: VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA), but it is ON_QA instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

This PR handles SHA1 certificate upgradeable scenarios for 4.15. With OpenSSL3.0 provided by RHEL9 in 4.16, the router will fail to start if any cert provided is SHA1.

First, if the default certificate on the Ingress Controller object is using SHA1, then set Upgradeable to be False.

Secondly, add a new control loop, route deprecated, that determines upgradeablity by searching for the UnservableInFutureVersions condition in the routes. The UnservableInFutureVersions will be added to the route by openshift/router#555 when a SHA1 certificate exists on the route. It creates an admin-gate if a UnservableInFutureVersions condition is found. This logic assumes any UnservableInFutureVersions route status condition is an upgrade blocker.

This implementation targets 4.15 to 4.16 updates specifically, so it is only targeting the release-4.15 branch and we will be merged in the backport of https://issues.redhat.com/browse/OCPBUGS-26498. The code should not be merged into 4.16.

WIP because the API change (openshift/api#1722) needs to get merged and backported to 4.15.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Bump openshift/api to get new route UnservableInFutureVersions
status condition type.

  go mod edit -replace=github.com/openshift/api=github.com/openshift/api@93d6bda14341f1d18319774367829c3278c171e7
  go mod tidy
  go mod vendor
The route upgradeable control loop determines upgradeablity by searching
for the UnservableInFutureVersions condition in the routes. It creates an
admin-gate if the condition is found. This implemenentation targets 4.15
upgrades to 4.16 specifically and assumes any UnservableInFutureVersions
route status is an upgrade blocker.

Add E2E test to validate the functionality of the admin-gate as well as
validating that the router adds the UnservableInFutureVersions condition
for routes with SHA1 certificates.
@gcs278 gcs278 changed the title [WIP] OCPBUGS-28928: Prevent upgrades for SHA1 default cert and SHA1 route certs OCPBUGS-28928: Prevent upgrades for SHA1 default cert and SHA1 route certs May 22, 2024
@openshift-ci-robot openshift-ci-robot added the jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. label May 22, 2024
@openshift-ci-robot
Copy link
Contributor

@gcs278: This pull request references Jira Issue OCPBUGS-28928, which is valid.

7 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.15.z) matches configured target version for branch (4.15.z)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
  • release note text is set and does not match the template
  • dependent bug Jira Issue OCPBUGS-26498 is in the state Verified, which is one of the valid states (VERIFIED, RELEASE PENDING, CLOSED (ERRATA), CLOSED (CURRENT RELEASE), CLOSED (DONE), CLOSED (DONE-ERRATA))
  • dependent Jira Issue OCPBUGS-26498 targets the "4.16.0" version, which is one of the valid target versions: 4.16.0
  • bug has dependents

Requesting review from QA contact:
/cc @ShudiLi

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

This PR handles SHA1 certificate upgradeable scenarios for 4.15. With OpenSSL3.0 provided by RHEL9 in 4.16, the router will fail to start if any cert provided is SHA1.

First, if the default certificate on the Ingress Controller object is using SHA1, then set Upgradeable to be False.

Secondly, add a new control loop, route deprecated, that determines upgradeablity by searching for the UnservableInFutureVersions condition in the routes. The UnservableInFutureVersions will be added to the route by openshift/router#555 when a SHA1 certificate exists on the route. It creates an admin-gate if a UnservableInFutureVersions condition is found. This logic assumes any UnservableInFutureVersions route status condition is an upgrade blocker.

This implementation targets 4.15 to 4.16 updates specifically, so it is only targeting the release-4.15 branch and we will be merged in the backport of https://issues.redhat.com/browse/OCPBUGS-26498. The code should not be merged into 4.16.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot removed the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label May 22, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 22, 2024
Copy link
Contributor

openshift-ci bot commented May 22, 2024

@gcs278: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-azure-ovn 1b2ff90 link false /test e2e-azure-ovn
ci/prow/e2e-aws-operator 1b2ff90 link true /test e2e-aws-operator
ci/prow/e2e-gcp-ovn 1b2ff90 link false /test e2e-gcp-ovn
ci/prow/e2e-azure-operator 1b2ff90 link true /test e2e-azure-operator
ci/prow/e2e-gcp-operator 1b2ff90 link true /test e2e-gcp-operator
ci/prow/e2e-aws-ovn-serial 1b2ff90 link true /test e2e-aws-ovn-serial

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants