Vector35 / Vector35/binaryninja-api

Better support for translating pointer encoding to an address (with optional metadata)

Aperta
#3,053 3 commenti 10 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Component: Core Effort: High Impact: Medium
Lingua principale
C++
Stelle
1.3k
Fork
298
Merge medio
5g 5h
PR unite (30g)
19

Descrizione

What is the feature you'd like to have?
Pointers are not necessarily integers. And they can be bigger than the addresses. I'd like Binja to support such pointer types.
In particular, I'd like the Architecture class to be extended to support translating a given pointer encoding to an address and optional metadata; and BinaryNinja to use this when computing the address of a pointer for references, value set analysis, and other analyses, while optionally displaying the metadata (e.g. in a mouseover popup, or making it available to a DataRenderer). Also, please add an inverse translation function taking an address and metadata to construct a pointer encoding.

This would help introduce a foundation on which to build lifting for instructions that manipulate pointers and their metadata.

Is your feature request related to a problem?
My feature request is related to the problem of reverse engineering binaries with tagged pointers, PAC, and other "weird" pointers.

Are any alternative solutions acceptable?
Alternative solutions include rewriting the binary to strip pointer metadata. However, this is not an acceptable solution, since it discards data, and pointers that contain metadata and don't fit into the current model of "pointers are integers containing only an address" are not used for analysis.

Additional Information:
Pointers are not necessarily integers that contain an address, although this is usually the case for classic architectures. However, this has changed with the introduction of new CPU features. For example:

  • ARMv8 defines Top-Byte-Ignore (TBI). This allows storing arbitrary metadata in bits 63..56 of a pointer.
  • For amd64, the Upper Address Ignore feature was added. Bits 63...57 contain arbitrary metadata.
  • ARMv8.3 introduced Pointer Authentication Codes (PAC). These store a pointer authentication code and optional tag in the top bits of the pointer. The sign bit of the pointer is stored in bit 55. The bits 63..56, and 54..va_size (va_size is implementation defined) store the metadata.
  • Armv8.5-A introduces Memory Tagging Extensions (MTE). This stores a tag in the lower nibble of the top byte, and builds on TBI.
  • In CHERI, pointers (aka capabilities) are 128-bit structures (129 bit, to be precise, although the extra bit is not stored in memory), while the address of the pointer is stored in bits 63..0 and the metadata is stored in bits 127..64.

I'm not sure how this interacts with segmented architectures, but probably applies there too somehow.

Useful Resources

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

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.

Direzione di ricerca

Start by reviewing the Architecture class and the BinaryNinja analysis paths that compute pointer addresses for references and value set analysis. Define the scope for bidirectional pointer-encoding/address translation and optional metadata handling, including how metadata is exposed; done requires agreement on the API and its use across the named analyses.

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

Valutazione

Stack tecnologico
cpp
Ambito
backend-api-design, reverse-engineering
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.