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

CVE-2021-3121: Processes may panic upon receipt of malicious protobuf messages #101435

Closed
joelsmith opened this issue Apr 23, 2021 · 5 comments
Closed
Labels
area/security kind/bug Categorizes issue or PR as related to a bug. official-cve-feed Issues or PRs related to CVEs officially announced by Security Response Committee (SRC) sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/security Categorizes an issue or PR as relevant to SIG Security. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@joelsmith
Copy link
Contributor

Issue Details

A security issue was discovered in code generated by the gogo protobuf compiler used by Kubernetes. The gogo protobuf compiler issue has been assigned CVE-2021-3121 and is also known as the “skippy peanut butter bug”.

A program which uses affected code to handle a malicious protobuf message could panic.
The Kubernetes Product Security Committee has tested the API server using a malicious message, and we believe that there is no security impact to Kubernetes. When an authenticated user sent the malicious message to the API server, a panic occurred. However, the panic handler recovered and the API server continued without interruption (except to the malicious requestor, who received no response).

Generated protobuf files are part of several Kubernetes repositories, and any downstream projects which vendor in these repos should evaluate whether there is any security impact to their project.

Affected Components and Configurations

Any golang components which use handler code created by the gogo protbuf compiler, which accept protobuf messages and do not gracefully handle panics in the unmarshalling codepath may be affected.

The following Linux command can be used to detect affected generated code within a codebase:

find . -name '*.pb.go' | \
xargs -r grep -l 'if skippy < 0' | \
xargs -r awk -e '/if skippy < 0/ {a=4} /if \(iNdEx \+ skippy\) > postIndex/ &&' \
  	  -e 'a>0 {print FILENAME " " FNR ": " $0 " // vulnerable to CVE-2021-3121"} {a--}'

Although we do not believe there is any security impact to Kubernetes, we have updated all generated protobufs out of an abundance of caution and as a courtesy to any downstream consumers who may be affected. The following PRs addressed this issue in Kubernetes:

Master branch: #98477, #101306
1.21 branch: #98477 (in 1.21.0), #101325 (in 1.21.1)
1.20 branch: #100501 (in 1.20.6), #101326 (in 1.20.7)
1.19 branch: #100515 (in 1.19.10), #101327 (in 1.19.11)
1.18 branch: #100514 (in 1.18.18), #101335 (in 1.18.19)

For other generated protobuf go handlers, the issue can be remediated by upgrading the gogo protobuf compiler to a fixed version (v1.3.2 or later), then regenerating affected protobuf code with the updated protobuf compiler.

Mitigations

Disabling support for protobuf messages may be one possible mitigation for any affected product.

Also, graceful panic handling in message handlers mitigates the bug.

Detection

If you use generated protobuf code in a product and you observe a process exiting with messages similar to the following, a malicious user may be exploiting this defect:

panic: runtime error: index out of range [-9223372036854775804]
 
goroutine 1 [running]:
v1.(*MessageName).Unmarshal(0xc000057ef8, 0xc0000161a0, 0xa, 0x10, 0xc000057ec8, 0x1)
        .../protofile.pb.go:250 +0xb86

References

@joelsmith joelsmith added the kind/bug Categorizes issue or PR as related to a bug. label Apr 23, 2021
@k8s-ci-robot k8s-ci-robot added needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 23, 2021
@joelsmith
Copy link
Contributor Author

/area security
/close

@k8s-ci-robot
Copy link
Contributor

@joelsmith: Closing this issue.

In response to this:

/area security
/close

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.

@joelsmith
Copy link
Contributor Author

/sig security
/sig api-machinery

@k8s-ci-robot k8s-ci-robot added sig/security Categorizes an issue or PR as relevant to SIG Security. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 23, 2021
@fedebongio
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 20, 2021
@PushkarJ
Copy link
Member

/label official-cve-feed

(Related to kubernetes/sig-security#1)

@k8s-ci-robot k8s-ci-robot added the official-cve-feed Issues or PRs related to CVEs officially announced by Security Response Committee (SRC) label Oct 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security kind/bug Categorizes issue or PR as related to a bug. official-cve-feed Issues or PRs related to CVEs officially announced by Security Response Committee (SRC) sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/security Categorizes an issue or PR as relevant to SIG Security. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

No branches or pull requests

4 participants