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

Use golang.org/x/[email protected] to mitigate CVE-2022-32149 #251

Closed
wants to merge 1 commit into from

Conversation

knopt
Copy link

@knopt knopt commented Nov 24, 2022

Signed-off-by: Tomasz Knopik [email protected]

What type of PR is this?
/kind bug

What this PR does / why we need it:
Fixes CVE-2022-32149 which is high severity vulnerability discovered in node-driver-registrar dependencies.

Which issue(s) this PR fixes:

Fixes #249

Special notes for your reviewer:

$  cat go.sum | grep golang.org/x/text
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 24, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: knopt
Once this PR has been reviewed and has the lgtm label, please assign jsafrane for approval by writing /assign @jsafrane in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Welcome @knopt!

It looks like this is your first PR to kubernetes-csi/node-driver-registrar 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-csi/node-driver-registrar has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 24, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @knopt. Thanks for your PR.

I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 24, 2022
@knopt
Copy link
Author

knopt commented Nov 24, 2022

/cc @mauriciopoppe

@mauriciopoppe
Copy link
Member

/ok-to-test
/lgtm
/assign @msau42

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 28, 2022
@@ -48,3 +48,5 @@ require (
k8s.io/component-base v0.25.4 // indirect
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
)

replace golang.org/x/text => golang.org/x/text v0.4.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need the replace?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, it's a transitive dependency that has that requirement. I guess the potential concern is that version combination being untested.

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
Author

Choose a reason for hiding this comment

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

To address the compatibility issues, we could change replace clause from v0.4.0 to v0.3.8. However, according to semantic versioning, which is followed by golang, upgrade of MINOR is backward compatible.

The analysis seems to be correct, but upgrading seems like a more trustworthy approach.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We discussed this at today's csi standup. It looks like go.sum lists all the possible versions that could be used, but that doesn't necessarily mean that the version is being used. So cve scanners that rely on go.sum may produce a lot of false positives.

https://stackoverflow.com/questions/70128040/content-of-go-sum-and-modules-really-used-by-a-go-application
https://stackoverflow.com/questions/69825533/why-does-go-sum-include-so-many-older-packages

Given that this change removed the entries from go.sum, but didn't actually change anything in the vendor directory (which reflects what's actually being used) confirms this.

What scanner are you using? It looks like trivy no longer relies on go.sum when the go version in go.mod is >= 1.17: aquasecurity/trivy#1973. But dependabot still does not: dependabot/dependabot-core#4740

Copy link
Author

Choose a reason for hiding this comment

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

I used a commercial security analysis tool to detect vulns. It is a good point that presence of a dependency in go.sum does not necessarily mean that it's actually used. However, the affected version (v0.3.7) is explicitly listed in go.mod of node-driver-registrar (indirect dependency but still a dependency) (it's not go.sum issue that was mentioned).

I agree that it looks like the affected part of the code is not used (even indirectly) by node-driver-registrar. However, afaik security scanners standards are not designed to go into analysis on a function level, they stop at reporting affected package version. Yet, they are still useful tool.

I believe that there is a choice to be made here by maintainers. Every time a new vulnerability is discovered either affected dependency should be updated regardless if the node-driver-registrar is using the affected, or do the vulnerability security audit every time and somehow maintain list of such vulnerabilities which are believed to be not affecting the repo and make all users aware that their scans might produce higher-than-usual number of false-positives.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the go.mod, it looks like only 0.4.0 is listed: https://github.com/kubernetes-csi/node-driver-registrar/pull/251/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6R42

Anyway, I think we should go ahead and merge this because it is a burden to have users manage exceptions in their scanners, but we should also notify the scanning tools of false-positives so that they can be improved.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, you are actually right, I was looking at 2.6.1 and 2.6.2 tags. 0.4.0 is not on master b/c of #243 which I've just noticed.

The above makes this PR redundant, thank you for the discussion though! I think it's important to recognize how vulns should be addressed.

@xing-yang
Copy link
Contributor

@knopt Have you scanned the image after this fix? Do you see the CVE's gone after this?

@knopt
Copy link
Author

knopt commented Dec 1, 2022

@xing-yang Yes, I've run the scan against my branch and the vulnerability is no longer present.

@knopt knopt closed this Dec 2, 2022
jsafrane added a commit to jsafrane/node-driver-registrar that referenced this pull request May 13, 2024
adb3af9d Merge pull request kubernetes-csi#252 from bells17/update-go-version
b82ee388 Merge pull request kubernetes-csi#253 from bells17/fix-typo
c3174562 Fix typo
0a785056 Bump to Go 1.22.3
edd89ad5 Merge pull request kubernetes-csi#251 from jsafrane/add-logcheck
043fd099 Add test-logcheck target
d7535ae0 Merge pull request kubernetes-csi#250 from jsafrane/go-1.22
b52e7ad3 Update go to 1.22.2
14fdb6f6 Merge pull request kubernetes-csi#247 from msau42/prow
9b4352e9 Update release playbook
c7bb972c Fix release notes script to use fixed tags
463a0e9f Add script to update specific go modules

git-subtree-dir: release-tools
git-subtree-split: adb3af9dfa3ed4d1a922cd839bb48e0b73918617
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v2.6.1 is affected by CVE-2022-32149
5 participants