ScanElf: raw LIEF enums in header.flags crash format_event for ARM32/RISC-V ELFs (TypeError: __ne__)

Open Beginner friendly
#598 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
80/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend, security

Research direction

Start in src/python/strelka/scanners/scan_elf.py and inspect how the ELF header flags are added to the scan event; the issue identifies the two fields that retain raw LIEF enums. Check the event formatting path in strelka/strelka.py and run the relevant scanner tests or reproduce with an ARM32 or RISC-V ELF. Done means these inputs scan without dropping the event and the emitted flags are serializable.

Written by the indexing model from the issue text.

Description

Summary

For ELF files whose header has non-zero processor flags (seen with 32-bit ARM EABI5 and RISC-V RVC/double-float binaries), the whole scan event is lost. ScanElf puts raw LIEF enum objects into the event, and format_event's cleanup lambda then raises:

File ".../strelka/strelka.py", line 1022, in format_event
    remap2 = iterutils.remap(remap1, lambda p, k, v: v != "" and v != [] and v != {} and v is not None)
TypeError: __ne__(): incompatible function arguments. The following argument types are supported:
    1. __ne__(self, arg: int, /) -> bool
    2. __ne__(self, arg: lief._lief.ELF.PROCESSOR_FLAGS, /) -> bool
Invoked with types: lief._lief.ELF.PROCESSOR_FLAGS, str

The worker logs unknown exception (see traceback below), the file is moved to processed, and no result is emitted.

Cause

In src/python/strelka/scanners/scan_elf.py:

"flags": {
    "flags_list": elf.header.flags_list,
    "processor": elf.header.processor_flag,

These are the only header fields not converted with str(...). With current LIEF (nanobind bindings), comparing an enum to str raises instead of returning NotImplemented.

Suggested fix

"flags_list": [str(f).split(".")[-1] for f in elf.header.flags_list],
"processor": str(elf.header.processor_flag).split(".")[-1],

Optionally, make format_event's filter tolerant of non-comparable values (e.g. isinstance checks) so that one scanner field can't drop the whole event.

Impact

x86-64, i386 and AArch64 ELFs (processor flags 0) scan fine. 32-bit ARM, RISC-V and MIPS binaries, which is most IoT/router malware, silently produce no result. We hit it with three honeypot-captured samples (2× RISC-V 64, 1× ARM EABI5) out of 49; the x86/AArch64 samples in the same batch were all scanned.

Environment

  • Strelka backend as bundled with Security Onion 3.3.0 (so-strelka-backend container)
  • Python 3.14
  • LIEF 0.17.6
  • Reproducible with any 32-bit ARM EABI5 ELF.
Dominant language
Python
Stars
1k
Forks
144
Avg merge
14d 22h
Merged PRs (30d)
3

Getting set up

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.

More from target/strelka

All issues in target/strelka

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.