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 P12 parsing for certificates with "Basic constraints" #122056

Merged
merged 3 commits into from
Jan 4, 2022

Conversation

jportner
Copy link
Contributor

Resolves #122054.

See that issue for a detailed description.

To test, use the P12 file provided in that issue's "Steps to reproduce" section, and verify that Kibana starts without any errors.

@jportner jportner added v8.0.0 auto-backport Deprecated - use backport:version if exact versions are needed v8.1.0 v7.17.0 labels Dec 27, 2021
This fixes the root cause of the bug. I had to use a yarn dependency
resolution to force-upgrade this, as it's a transitive dependency of the
@elastic/request-crypto package. I'll open a separate issue in that repo
to get it fixed there, too; when that's fixed and upgraded in the Kibana
repo we can remove this resolution.
@jportner jportner marked this pull request as ready for review December 28, 2021 00:28
Copy link
Contributor Author

@jportner jportner left a comment

Choose a reason for hiding this comment

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

I'd prefer to change the P12 parser to log a warning when a cert bag is empty. However, we don't have access to a logger when this is being used (while we are reading/validating the config).

Another idea I had is to debug log the fingerprints of each certificate that is loaded when they are consumed (for example, in the Elasticsearch client). That would at least make it easier to diagnose that a certificate is missing when a user is having TLS issues. However, that doesn't cover all of our bases (certificates are also used for the HTTP server).

So, I think this fix is sufficient for now.

package.json Outdated
@@ -86,6 +86,7 @@
"**/istanbul-lib-coverage": "^3.2.0",
"**/json-schema": "^0.4.0",
"**/minimist": "^1.2.5",
"**/node-jose": "^1.1.4",
Copy link
Contributor Author

@jportner jportner Dec 28, 2021

Choose a reason for hiding this comment

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

As mentioned in ad696ff, I had to use a yarn dependency resolution to upgrade this transitive dependency.

We depend on node-jose via @elastic/request-crypto, so I submitted another PR there to upgrade that dependency: elastic/request-crypto#11

Once that is merged and a new version is deployed to the npm registry, I can remove this dependency resolution. I wasn't sure how long that would take but it looks like that might be done tomorrow, so I might be able to upgrade that instead and remove this dependency resolution before merging this PR.

Copy link
Member

Choose a reason for hiding this comment

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

Both options sounds good to me 👍

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 @elastic/request-crypto 2.0.0 and node-jose 2.0.0, and removed the dependency resolutions, in fa4eecc.

@azasypkin
Copy link
Member

ACK: reviewing...

Copy link
Member

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

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

LGTM, tested locally and everything worked as expected. Thanks a lot for the thorough investigation and the fix(es)!

package.json Outdated
@@ -86,6 +86,7 @@
"**/istanbul-lib-coverage": "^3.2.0",
"**/json-schema": "^0.4.0",
"**/minimist": "^1.2.5",
"**/node-jose": "^1.1.4",
Copy link
Member

Choose a reason for hiding this comment

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

Both options sounds good to me 👍

Joe Portner added 2 commits January 4, 2022 08:17
Also updates node-jose to 2.0.0. The reason for the major version change
is that it drops support for Node 8.

By doing this we were able to remove two dependency resolutions in the
package.json file.
@jportner jportner enabled auto-merge (squash) January 4, 2022 13:27
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@jportner jportner merged commit 75ea37b into elastic:main Jan 4, 2022
@jportner jportner deleted the issue-122054-fix-p12-parsing branch January 4, 2022 14:46
@kibanamachine
Copy link
Contributor

💔 Backport failed

Status Branch Result
8.0 Commit could not be cherrypicked due to conflicts
7.17 Commit could not be cherrypicked due to conflicts

To backport manually run:
node scripts/backport --pr 122056

jportner added a commit to jportner/kibana that referenced this pull request Jan 4, 2022
jportner added a commit to jportner/kibana that referenced this pull request Jan 4, 2022
jportner added a commit that referenced this pull request Jan 4, 2022
jportner added a commit that referenced this pull request Jan 4, 2022
@jportner jportner added v7.16.3 auto-backport Deprecated - use backport:version if exact versions are needed and removed auto-backport Deprecated - use backport:version if exact versions are needed labels Jan 5, 2022
@kibanamachine
Copy link
Contributor

💔 Backport failed

Status Branch Result
7.16 Commit could not be cherrypicked due to conflicts

To backport manually run:
node scripts/backport --pr 122056

jportner added a commit to jportner/kibana that referenced this pull request Jan 5, 2022
jportner added a commit that referenced this pull request Jan 5, 2022
@KOTungseth KOTungseth added the Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! label Jan 5, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

gbamparop pushed a commit to gbamparop/kibana that referenced this pull request Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:fix Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v7.16.3 v7.17.0 v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

P12 certificates with "Basic constraints" extension and "PathLen" constraint are ignored
6 participants