fix: sanitize error before gRPC return to prevent credential leak in pod events#12801
Conversation
…pod events PR containerd#12491 fixed credential leaks in containerd logs but the gRPC error returned to kubelet still contained sensitive information. This was visible in Kubernetes pod events via `kubectl describe pod`. The issue was that SanitizeError was called inside the defer block, but errgrpc.ToGRPC(err) was evaluated before the defer ran, so the gRPC message contained the original unsanitized error. Move SanitizeError before the return statement so both the logged error and the gRPC error are sanitized. Ref: containerd#5453 Signed-off-by: Aadhar Agarwal <[email protected]>
AkihiroSuda
left a comment
There was a problem hiding this comment.
Thanks, but next time please follow https://github.com/containerd/containerd/security
Ah, thank you for pointing this out - Sounds good! |
|
/cherry-pick release/2.2 |
|
@AkihiroSuda: #12801 failed to apply on top of branch "release/1.7": DetailsIn response to this:
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. |
|
@AkihiroSuda: new pull request created: #12803 DetailsIn response to this:
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. |
|
@AkihiroSuda: new pull request created: #12804 DetailsIn response to this:
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. |
|
/cherry-pick release/2.0 |
|
@chrishenzie: new pull request created: #13180 DetailsIn response to this:
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. |
PR #12491 fixed credential leaks in containerd logs but the gRPC error returned to kubelet still contains sensitive information (e.g., SAS tokens). This is visible in Kubernetes pod events via
kubectl describe pod.Issue:
The
SanitizeErrorcall was placed inside the defer block:Go evaluates
errgrpc.ToGRPC(err)before the defer runs, so the gRPC message contains the original unsanitized error with credentials.Fix:
Move
SantiizeErrorbefore the return statement:This ensures both the logged error and the gRPC error use the sanitized error.
Testing:
When describing pod:

containerd log: