-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/internal/buildid: buildid invalid read when program alignment is zero #62097
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
Comments
Can you provide more context and/or links on what you mean by "binary 2a2513e8687993ed71cc48b09676abf18bb0e739f15473d36c50627b05036686" and "the buildid code"? Is this related to GOROOT/src/cmd/go/internal/work/buildid.go or something else? |
This code here https://cs.opensource.google/go/go/+/master:src/cmd/internal/buildid/buildid.go;drc=615c7c18a70e0d6638accdb0fcc5f60c57a2118b;l=289 there is a bug in readELF (https://cs.opensource.google/go/go/+/master:src/cmd/internal/buildid/note.go;drc=14a3ffc3d2165ef03c3ffd0037a4fa6dbb776026;l=154) as I commented above. https://www.virustotal.com/gui/file/2a2513e8687993ed71cc48b09676abf18bb0e739f15473d36c50627b05036686 sha256 hashes are commonly used to refer to files on VT. |
It's pretty strange to have a PT_NOTE segment with a p_align field of 0, but I guess we should handle it. I'll send a CL. |
I agree, I had to lookup if alignment of 0 was even valid. Apparently it is. |
Change https://go.dev/cl/520597 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
Using binary 2a2513e8687993ed71cc48b09676abf18bb0e739f15473d36c50627b05036686 (on VT) running the buildid code over the sample fails to correctly read the notes section. This is not a Go binary, however this does excersize a failure case in the build id code here:
The alignedOff is aligned to zero while the offset is positive leading to an underflow when the notesz is calculated. This later leads to an invalid array access at
note = note[notesz:]
To fix, the code should ignore alignment when it's zero:
The text was updated successfully, but these errors were encountered: