ELF API - #282
Conversation
…vements to the general API
… of GNU Note Properties needed for runtime mitigation parsing
…cognition of runtime mitigations when binary is running
|
I don't know why my PRs are always enormous, but I think I finally finished. Mitigation parsing of ARM took a long time. This PR is finally ready for review. |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a comprehensive ELF API for inspecting traced process binaries and their libraries. The implementation provides access to build IDs, sections, dynamic sections, symbols, program headers, GNU properties, and runtime security mitigations.
Key changes:
- New ELF inspection API with Python objects for ELF structures
- Nanobind implementation for parsing ELF objects
- Support for parsing libraries (both at load and dlopen time)
- Runtime security mitigations analysis
- Comprehensive test suite across amd64, i386, and aarch64 architectures
Reviewed Changes
Copilot reviewed 34 out of 66 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/utils/binary_utils.py | Added RESOLVE_EXE_CROSS utility for cross-platform binary resolution |
| test/srcs/sections_test.c | Comprehensive C test file exercising various ELF sections and features |
| test/srcs/mitigations.c | Test binary for security mitigation detection across platforms |
| test/srcs/dynamic_lib_load.c | Test case for dynamic library loading via dlopen |
| test/scripts/elf_api_test.py | Extensive test suite validating ELF API functionality |
| test/scripts/init.py | Added ElfApiTest to test exports |
| test/run_suite.py | Integrated ElfApiTest into test suite |
| test/binaries/* | Pre-compiled test binaries for multiple platforms |
| pyproject.toml | Moved 'rich' from optional to core dependencies |
| mkdocs.yml | Reorganized QoL documentation with new ELF API section |
| libdebug/utils/pprint_primitives.py | Added pprint_mitigations function for pretty printing security mitigations |
| libdebug/native/utils/binary_utils.{h,cpp} | Binary utility functions for ELF parsing (byte swapping, file I/O) |
Comments suppressed due to low confidence (1)
test/srcs/mitigations.c:1
- The build command on line 22 outputs to '../binaries/amd64/mitigationsv1' but is documented as building for AMD64 with 32-bit flag '-m32', which is contradictory. The correct output path should likely be '../binaries/i386/mitigationsv1' or the '-m32' flag should be removed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
One test that I should actually add is for the dynamic parsing of libraries when the binary calls EDIT: done |
MrIndeciso
left a comment
There was a problem hiding this comment.
Just a few small comments for consistency, everything else looks good
…ensure uniform handling of them between the different functions
Those only work on M Thumb devices, which we don't support, and use a different instruction encoding style, so those patterns wouldn't even match there
This draft PR introduces an API to inspect ELF files associated with the traced process — both the main binary and its libraries.
Libraries are parsed when loaded by the OS interpreter at process start, as well as when dynamically loaded at runtime via dlopen.
The new ELF inspection API provides access to detailed information such as:
Current Status
✅ Python objects for relevant ELF structures
✅ Nanobind implementation for parsing ELF objects
✅ Parsing of libraries
✅ Parsing of security mitigations
✅ Reorganization into a single nanobind module (excluding symbols, which are to be kept separate)
✅ Documentation
✅ Test suite
Notes
This PR is still in draft form — many features and improvements are ongoing.
This pr addresses #188 and #287.