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 #55

Merged
merged 1 commit into from
Jun 19, 2023
Merged

sha: fix use-after-free issue #55

merged 1 commit into from
Jun 19, 2023

Conversation

qmuntal
Copy link
Contributor

@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.

evpHash.WriteString and evpHash.WriteByte APIs where introduced during this development cycle, so the issue still haven't hit production systems.

@qmuntal qmuntal merged commit e311e15 into main Jun 19, 2023
33 checks passed
@qmuntal qmuntal deleted the fixsha branch June 19, 2023 08:35
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