[Bug] Prevent collisions in generated identifiers and runtime symbols

Aperta
#8 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, cpp

Direzione di ricerca

Start with the data-symbol collection in src/main.cpp (around lines 162-170), then the name sanitizing in src/decompiler/decompiler.cpp (75-91) and src/decompiler/project.cpp (53-66), and the declaration emission at project.cpp (282-299). The goal is a deterministic unique-name mapping that avoids C keywords and libc names, with every reference following that mapping. Done means a binary using stdout compiles and colliding names like foo-bar and foo_bar get distinct stable identifiers; the payload names no test, so one must be found or added.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Summary

Generated identifiers are sanitized locally but are not made unique or reserved-name safe. The CLI also feeds runtime and libc symbols into the recovered data declarations, which can conflict with headers included by the generated file.

Evidence

src/main.cpp:162-170 collects nearly every non-function ELF symbol as a data name. src/decompiler/decompiler.cpp:75-91 and src/decompiler/project.cpp:53-66 replace invalid characters and prefix digits, but do not detect collisions, C keywords, or names already declared by included headers. Declarations are emitted at src/decompiler/project.cpp:282-299.

For a binary using stdio, the generated project can contain:

#include <stdio.h>
static uintptr_t stdout = 0;

which conflicts with libc's FILE *stdout declaration. Similar conflicts occur when an unrecognized imported function receives a fallback with the same name as a libc declaration, and two symbols such as foo-bar and foo_bar both sanitize to foo_bar.

Impact

Otherwise usable recovered output fails at compile time or silently binds references to the wrong declaration. Runtime/linker symbols and user symbols are common in ELF files, so this is not limited to intentionally adversarial input.

Expected behavior

Generated identifiers should use a dedicated namespace/prefix, be deterministic and unique after sanitization, avoid C keywords and reserved/runtime names, and distinguish external declarations from recovered storage. Standard-library symbols should not be redeclared with incompatible types.

Acceptance criteria

  • A binary containing stdout or another libc runtime symbol produces compilable output.
  • Sanitization collisions receive stable unique names and all references follow the mapping.
  • C keywords and reserved identifiers cannot become generated declarations.
  • Unknown-import fallbacks cannot conflict with declarations from emitted standard headers.
Lingua principale
C++
Stelle
0
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TiElixir/caraxes

Tutte le issue di TiElixir/caraxes

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.