Skip to content

fix: prevent nil-deref panic on invalid pem block (#7053) - #7054

Open
oindrilakha12-ui wants to merge 1 commit into
pipe-cd:masterfrom
oindrilakha12-ui:fix/issue-7053
Open

fix: prevent nil-deref panic on invalid pem block (#7053)#7054
oindrilakha12-ui wants to merge 1 commit into
pipe-cd:masterfrom
oindrilakha12-ui:fix/issue-7053

Conversation

@oindrilakha12-ui

Copy link
Copy Markdown
Contributor

What this PR does:
Adds a nil check for the decoded PEM block in ParseRSAPublicKeyFromPem and ParseRSAPrivateKeyFromPem (inside pkg/crypto/key.go) to safely return an error instead of crashing.

Why we need it:
When pem.Decode receives invalid or non-PEM data, it returns a nil block. Accessing block.Bytes without checking causes a process crash. This fixes a potential Denial of Service (DoS) vulnerability.

Which issue(s) this PR fixes:

Fixes #7053

Does this PR introduce a user-facing change?:
No.

  • How are users affected by this change: N/A
  • Is this breaking change: No
  • How to migrate (if breaking change): N/A

Signed-off-by: Oindrila Khan <oindrilakha12@gmail.com>
@oindrilakha12-ui

Copy link
Copy Markdown
Contributor Author

@Warashi , @rahulshendre please review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unchecked pem.Decode in pkg/crypto/key.go causes nil-deref panic (Potential DoS)

1 participant