mandiant / mandiant/capa

SegmentationViolation while analyzing an ELF file

Open
#2,457 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug viv-bug
Dominant language
Python
Stars
6.2k
Forks
726
Avg merge
11d 11h
Merged PRs (30d)
7

Description

Dear Developers,

Good afternoon. The description of the issue follows below:

### Description

SegmentationViolation while analyzing an ELF file (on Windows and Linux -- versions 7.4.0, 7.3.0 and 7.2.0 ).

### Steps to Reproduce

**capa test.bin
capa -v test.bin**

(binary hash: **06abc46d5dbd012b170c97d142c6b679183159197e9d3f6a76ba5e5abf999725**)

**Actual behavior:**

While running capa (in multiple versions on Windows and Linux), the output is shown below (with and without --debug option).

The relevant error message is:

**_Traceback (most recent call last):
File "main.py", line 1109, in
File "main.py", line 996, in main
File "main.py", line 839, in get_extractor_from_cli
File "loader.py", line 290, in get_extractor
File "loader.py", line 161, in get_workspace
File "viv_utils/__init__.py", line 118, in getWorkspace
File "vivisect/__init__.py", line 2891, in loadFromFile
File "vivisect/parsers/elf.py", line 32, in parseFile
File "vivisect/parsers/elf.py", line 616, in loadElfIntoWorkspace
File "envi/memory.py", line 213, in readMemoryPtr
File "envi/memory.py", line 195, in readMemValue
File "envi/memory.py", line 607, in readMemory
envi.exc.SegmentationViolation: SegmentationViolation('Bad Memory Read (invalid memory address): 0x0: 0x8')
[PYI-171278:ERROR] Failed to execute script 'main' due to unhandled exception!_**

To the output including --debug option, I pasted only the beginning and the ending:

![image](https://github.com/user-attachments/assets/eec5d124-20a4-45d3-80e6-da015347ed24)
![image](https://github.com/user-attachments/assets/fe905656-edf5-4a18-bc2e-6e457de82eb1)
![image](https://github.com/user-attachments/assets/c97ca82f-8371-41be-8899-c37e1a2d574c)

### Versions

Affected versions: 7.4.0, 7.3.0, 7.2.0 (Windows and Linux)
OS: Linux Ubuntu 24.04.1 x64 LTS (full-updated) ; Windows 11 x64 (full-updated)

### Additional Information

As I have explained above, the binary's hash that causes the problem is: **06abc46d5dbd012b170c97d142c6b679183159197e9d3f6a76ba5e5abf999725**

**I've found this issue while using Python 3.12.3 (on Linux) and Python 3.11.3 (on Windows).**

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported reproduction commands and traceback, then inspect main.py, loader.py, vivisect/parsers/elf.py, and envi/memory.py at the cited call path. Use the supplied binary hash to obtain test.bin if available and confirm the failure during ELF analysis. Done means capa analyzes the file without an unhandled SegmentationViolation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
reverse-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.