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 the issues in DefaultCertValidator::doVerifyCertChain and ContextImpl::verifyCertChain #16982

Merged
merged 11 commits into from
Jul 15, 2021

Conversation

tyxia
Copy link
Member

@tyxia tyxia commented Jun 15, 2021

  1. In DefaultCertValidator::doVerifyCertChain() function, there is one corner case not handled right now : trusted_ca = false and no hash or SAN matcher . Basically, it means no validation context is provided so no certificate validation is performed. Current code will still return OK for this case. NotValidated seems to be an initial state that needs to be updated to either Failed or Validated eventually. If it stay as NotValidated, it should be treated as Error.
  2. It reveals one bug via sds_dynamic_integration_test's QUIC path(The only failure caused by change above. TCP path of this test works fine).
    Basically, the problem is QUIC client side register and then will invoke the verifyCertificate() callback because its cert_verify_mode is set to SSL_VERIFY_PEER but no validation_context is provided. Thus, it will run into NotValidated case I described in 1 and my change return it as ERROR.

Similar to openSSL logic, the error can be treated as non-fatal if mode is SSL_VERIFY_NONE. The proposed fix is in ContextImpl::verifyCertChain( ) (which is only used by QUIC path): Query the true verify_mode that is initialized in DefaultCertValidator::initializeSslContexts(it will be SSL_VERIFY_NONE for this case because there is no validation_context config provided).
(PS: I discussed with QUIC folk, QUIC test could be investigated as well. But I feel the proposed fix is needed regardless)

Signed-off-by: Tianyu Xia tyxia@google.com

Risk Level: Low
Testing: Local test

tyxia added 2 commits June 15, 2021 03:19
Signed-off-by: Tianyu Xia <tyxia@google.com>
Signed-off-by: Tianyu Xia <tyxia@google.com>
@repokitteh-read-only
Copy link

Hi @tyxia, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #16982 was opened by tyxia.

see: more, trace.

Signed-off-by: Tianyu Xia <tyxia@google.com>
tyxia added 2 commits June 23, 2021 00:18
Signed-off-by: Tianyu Xia <tyxia@google.com>
Signed-off-by: Tianyu Xia <tyxia@google.com>
@alyssawilk
Copy link
Contributor

Just to be aware, we've been making some improvements to Envoy tooling for more prompt reviews, but draft PRs are not included in the tooling. I'm updating the contribution guidelines to make that clear (https://github.com/envoyproxy/envoy/pull/17063/files) , but as this PR predates the repokitteh warning I just want to call out that draft PRs are likely not going to get fast turnaround. Please consider marking this as ready for review if it stalls, and you want the assignee to take a look!

@tyxia
Copy link
Member Author

tyxia commented Jun 23, 2021

Just to be aware, we've been making some improvements to Envoy tooling for more prompt reviews, but draft PRs are not included in the tooling. I'm updating the contribution guidelines to make that clear (https://github.com/envoyproxy/envoy/pull/17063/files) , but as this PR predates the repokitteh warning I just want to call out that draft PRs are likely not going to get fast turnaround. Please consider marking this as ready for review if it stalls, and you want the assignee to take a look!

Thank you very much for information and pointers! I created this draft PR intentionally to trigger the CI run (as the sanity check):). I will mark it as ready-for-review when when it is ready. Please let me know if you have any other instructions. Thanks!

tyxia added 2 commits June 24, 2021 16:33
Signed-off-by: Tianyu Xia <tyxia@google.com>
Signed-off-by: Tianyu Xia <tyxia@google.com>
@tyxia tyxia marked this pull request as ready for review June 25, 2021 15:16
@tyxia tyxia requested review from asraa, ggreenway and lizan as code owners June 25, 2021 15:16
@tyxia
Copy link
Member Author

tyxia commented Jun 25, 2021

Added @rojkov here as we have discussed this issue in details in #16816

@tyxia tyxia changed the title Several fixes Fix the issues in DefaultCertValidator::doVerifyCertChain and ContextImpl::verifyCertChain Jun 25, 2021
tyxia added 3 commits June 25, 2021 17:00
Signed-off-by: Tianyu Xia <tyxia@google.com>
Signed-off-by: Tianyu Xia <tyxia@google.com>
Signed-off-by: Tianyu Xia <tyxia@google.com>
Copy link
Member

@rojkov rojkov left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

@tyxia tyxia requested a review from ggreenway July 8, 2021 14:05
Signed-off-by: Tianyu Xia <tyxia@google.com>
// sure the verification for other validation context configurations doesn't fail (i.e. either
// `NotValidated` or `Validated`). If `trusted_ca` doesn't exist, we will need to make sure other
// configurations are verified and the verification succeed.
int validation_status = verify_trusted_ca_
Copy link
Member

Choose a reason for hiding this comment

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

bool?

Copy link
Member Author

@tyxia tyxia Jul 13, 2021

Choose a reason for hiding this comment

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

Thanks for review! I think either bool or int will work here as bool <-> int implicit conversion will be triggered, and it will be triggered in either way.
The reason I used int here is to align with value 1 in ternary operator in line 226 and the return type of this function (which is int).

Please let me know what do you think.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think int is fine given that the function returns the same error code as X509_verify_cert

@yanavlasov yanavlasov self-assigned this Jul 13, 2021
@yanavlasov
Copy link
Contributor

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #16982 (comment) was created by @yanavlasov.

see: more, trace.

@mattklein123 mattklein123 merged commit 6b575e3 into envoyproxy:main Jul 15, 2021
leyao-daily pushed a commit to leyao-daily/envoy that referenced this pull request Sep 30, 2021
…textImpl::verifyCertChain` (envoyproxy#16982)

Signed-off-by: Tianyu Xia <tyxia@google.com>
@tyxia tyxia deleted the piper branch January 8, 2024 06:56
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.

8 participants