serge1 / ELFIO

ELFIO - ELF (Executable and Linkable Format) reader and producer implemented as a header only C++ library
http://serge1.github.io/ELFIO
MIT License
706 stars 152 forks source link

Code doesn't check entry size before casting #131

Closed Alan-Jowett closed 6 months ago

Alan-Jowett commented 6 months ago

Here is one example: https://github.com/serge1/ELFIO/blob/9814eaaa7623e05b1e2dd11794eb6404afac9040/elfio/elfio_relocation.hpp#L341C1-L359C1

Code assumes relocation_section->get_entry_size() > sizeof(T), which can be wrong in the case of a malicious ELF file.

See: https://github.com/microsoft/ebpf-for-windows/issues/3114 for how this was caught.