[Crash] Segmentation Fault in print_elf64_shdrs due to unchecked section name index

Open Beginner friendly
#4 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
c

Research direction

Start in src/pelf.c at print_elf64_shdrs, specifically line 408, and reproduce the crash with the AddressSanitizer build and modified ELF file described above. Check the section name index before it is used; done means the crafted file no longer causes a segmentation fault or out-of-bounds read under AddressSanitizer.

Written by the indexing model from the issue text.

Description

Description
The parse-elf utility crashes with a Segmentation Fault (SEGV) when parsing a specially crafted ELF file. This is caused by a missing bounds check when reading the section name index (sh_name).

Vulnerability Type
Heap-based Buffer Over-read / Denial of Service.

Steps to Reproduce

  1. Compile the project with AddressSanitizer: gcc -fsanitize=address -g src/pelf.c -o parser
  2. Open a valid ELF file in a hex editor.
  3. Locate the Section Header Table.
  4. Modify the sh_name field of the first section header to 0xFFFFFFFF.
  5. Run the parser: ./parser modified_elf

Crash Log (AddressSanitizer)

==1307716==ERROR: AddressSanitizer: SEGV on unknown address ...
    #0 0x7ffff7936286 in __sanitizer::internal_strlen
    #4 0x55555555a36e in print_elf64_shdrs src/pelf.c:408
SUMMARY: AddressSanitizer: SEGV src/pelf.c:408 in print_elf64_shdrs
Dominant language
C
Stars
7
Forks
3
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

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.

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.