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

sha: fix use-after-free issue #81

Merged
merged 1 commit into from
Jun 16, 2023
Merged

Conversation

qmuntal
Copy link
Collaborator

@qmuntal qmuntal commented Jun 15, 2023

There is a possible use-after-free issue in evpHash.WriteString and in evpHash.WriteByte. They both pass h.ctx to EVP_DigestUpdate without making sure h is still alive until the cgo call ends, i.e. using runtime.KeepAlive(h).

If the garbage collector chimes in at the right time, it will collect h, calling it's finalizer, that free's h.ctx, likely producing an invalid access exception.

Ported from microsoft/go-crypto-openssl#55.

@qmuntal qmuntal merged commit e986226 into wip/combined-codebase-staging Jun 16, 2023
8 checks passed
@qmuntal qmuntal deleted the wip/fixsha branch June 16, 2023 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants