House of Roman
Tip
Apprenez et pratiquez le hacking AWS :
HackTricks Training AWS Red Team Expert (ARTE)
Apprenez et pratiquez le hacking GCP :HackTricks Training GCP Red Team Expert (GRTE)
Apprenez et pratiquez le hacking Azure :
HackTricks Training Azure Red Team Expert (AzRTE)
Soutenir HackTricks
- Vérifiez les plans d’abonnement !
- Rejoignez le 💬 groupe Discord ou le groupe telegram ou suivez-nous sur Twitter 🐦 @hacktricks_live.
- Partagez des astuces de hacking en soumettant des PR au HackTricks et HackTricks Cloud dépôts github.
Informations de base
C’était une technique très intéressante qui permettait l’obtention d’une RCE sans leaks via fake fastbins, l’attaque unsorted_bin et des relative overwrites. Cependant elle a été patched.
Applicabilité en 2026
- glibc window : Fonctionne de façon fiable sur 2.23–2.27 (le PoC how2heap a testé 2.23–2.25). À partir de 2.28, le patch “additional checks for unsorted bin integrity” rend l’écriture unsorted‑bin peu fiable, donc le taux de réussite chute fortement. À partir de 2.34,
__malloc_hook/__free_hookont été supprimés, rendant la cible originale indisponible. Ne l’utilisez que sur d’anciennes libc (ou des builds personnalisés qui conservent les hooks) ou pour des challenges CTF qui fournissent une ancienne libc. - Tcache era (≥2.26) : Tcache mangera vos allocations 0x70 et bloquera les primitives fastbin/unsorted. Désactivez-le (
setenv("GLIBC_TUNABLES","glibc.malloc.tcache_count=0",1);) avant toute allocation ou remplissez chaque bin tcache 0x70 avec 7 frees pour le vider. - Safe-linking : Il s’applique à tcache/fastbin à partir de ≥2.32, mais House of Roman n’a besoin que d’un partial pointer overwrite of a libc address already present in fd/bk, donc safe-linking n’aide pas le défenseur ici (l’attaquant ne forge jamais un pointeur neuf). Le vrai frein est la suppression des hooks et les vérifications d’unsorted-bin.
Code
- Vous pouvez trouver un exemple dans https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c
Objectif
- RCE en abusant des relative pointers
Prérequis
- Éditer les pointeurs fastbin et unsorted bin
- 12 bits d’aléa doivent être bruteforcés (0,02 % de chance) pour fonctionner
Étapes de l’attaque
Partie 1 : Fastbin Chunk pointe vers __malloc_hook
Créez plusieurs chunks :
fastbin_victim(0x60, offset 0) : chunk UAF, utilisé plus tard pour éditer le heap pointer afin qu’il pointe vers la valeur libc.chunk2(0x80, offset 0x70) : pour un bon alignementmain_arena_use(0x80, offset 0x100)relative_offset_heap(0x60, offset 0x190) : offset relatif sur le chunk ‘main_arena_use’
Ensuite free(main_arena_use) qui placera ce chunk dans la liste unsorted et obtiendra un pointeur vers main_arena + 0x68 dans les deux pointeurs fd et bk.
On alloue ensuite un nouveau chunk fake_libc_chunk(0x60) car il contiendra les pointeurs vers main_arena + 0x68 dans fd et bk.
Puis relative_offset_heap et fastbin_victim sont libérés.
/*
Current heap layout:
0x0: fastbin_victim - size 0x70
0x70: alignment_filler - size 0x90
0x100: fake_libc_chunk - size 0x70 (contains a fd ptr to main_arena + 0x68)
0x170: leftover_main - size 0x20
0x190: relative_offset_heap - size 0x70
bin layout:
fastbin: fastbin_victim -> relative_offset_heap
unsorted: leftover_main
*/
fastbin_victimpossède unfdqui pointe versrelative_offset_heaprelative_offset_heapest un offset de distance depuisfake_libc_chunk, qui contient un pointeur versmain_arena + 0x68- Modifier le dernier octet de
fastbin_victim.fdfait quefastbin_victimpointe versmain_arena + 0x68.
Pour les actions précédentes, l’attaquant doit être capable de modifier le pointeur fd de fastbin_victim.
Ensuite, main_arena + 0x68 n’est pas si intéressant, donc modifions-le pour que le pointeur pointe vers __malloc_hook.
Notez que __memalign_hook commence généralement par 0x7f avec des zéros avant, il est donc possible de le falsifier comme une valeur dans le fast bin 0x70. Comme les 4 derniers bits de l’adresse sont aléatoires il y a 2^4=16 possibilités pour que la valeur finisse par pointer là où nous sommes intéressés. Ainsi, une BF attack est effectuée ici de sorte que le chunk se termine comme : 0x70: fastbin_victim -> fake_libc_chunk -> (__malloc_hook - 0x23).
(Pour plus d’infos sur le reste des octets, consultez l’explication dans l’how2heap example). Si le brute force échoue, le programme plante simplement (redémarrez le programme jusqu’à ce que ça fonctionne).
Ensuite, 2 mallocs sont effectués pour retirer les 2 chunks initiaux du fast bin et un troisième est alloué pour obtenir un chunk dans __malloc_hook.
malloc(0x60);
malloc(0x60);
uint8_t* malloc_hook_chunk = malloc(0x60);
Part 2: Unsorted_bin attack
Pour plus d’informations vous pouvez consulter :
Mais en gros, cela permet d’écrire main_arena + 0x68 à n’importe quelle adresse spécifiée dans chunk->bk. Pour l’attaque, nous choisissons __malloc_hook. Ensuite, après l’avoir écrasé, nous utiliserons un relative overwrite pour pointer vers un one_gadget.
Pour cela, nous commençons par obtenir un chunk et le placer dans le unsorted bin:
uint8_t* unsorted_bin_ptr = malloc(0x80);
malloc(0x30); // Don't want to consolidate
puts("Put chunk into unsorted_bin\n");
// Free the chunk to create the UAF
free(unsorted_bin_ptr);
Use an UAF in this chunk to point unsorted_bin_ptr->bk to the address of __malloc_hook (we brute forced this previously).
Caution
Note that this attack corrupts the unsorted bin (hence small and large too). So we can only use allocations from the fast bin now (a more complex program might do other allocations and crash), and to trigger this we must alloc the same size or the program will crash.
So, to trigger the write of main_arena + 0x68 in __malloc_hook we perform after setting __malloc_hook in unsorted_bin_ptr->bk we just need to do: malloc(0x80)
Step 3: Set __malloc_hook to system
In step one we controlled a chunk containing __malloc_hook (in the variable malloc_hook_chunk) and in the second step we managed to write main_arena + 0x68 there.
Now, we abuse a partial overwrite in malloc_hook_chunk to use the libc address we wrote there (main_arena + 0x68) to point to a one_gadget address.
Here is where it’s needed to bruteforce 12 bits of randomness (more info in the how2heap example).
Finally, once the correct address is overwritten, call malloc and trigger the one_gadget.
Modern tips & variants
- Unsorted-bin hardening (2.28+): The extra integrity checks on unsorted chunks (size sanity + list linkage) make the classic unsorted‑bin write fragile. To survive
_int_malloc, you must keepfd/bklinks consistent and sizes plausible, which usually requires stronger primitives than a simple partial overwrite. - Hook removal (2.34+): With
__malloc_hookgone, adapt the primitive to land on any writable GOT/global you can later reuse (e.g., overwriteexit@GOTin non-PIE binaries) or pivot to a House of Pie style top‑chunk hijack to controltopinstead of a hook. - Any‑address fastbin alloc (romanking98 writeup): The second part shows repairing the 0x71 freelist and using the unsorted‑bin write to land a fastbin allocation over
__free_hook, then placingsystem("/bin/sh")and triggering it viafree()on libc‑2.24 (pre-hook removal).
References
- https://github.com/shellphish/how2heap
- https://github.com/shellphish/how2heap/blob/master/glibc_2.23/house_of_roman.c
- https://ctf-wiki.mahaloz.re/pwn/linux/glibc-heap/house_of_roman/
- https://halloween.synacktiv.com/publications/heap-tricks-never-get-old-insomnihack-teaser-2022.html
- https://gist.github.com/romanking98/9aab2804832c0fb46615f025e8ffb0bc
- https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=NEWS;hb=glibc-2.34
- https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b90ddd08f6dd688e651df9ee89ca3a69ff88cd0c
Tip
Apprenez et pratiquez le hacking AWS :
HackTricks Training AWS Red Team Expert (ARTE)
Apprenez et pratiquez le hacking GCP :HackTricks Training GCP Red Team Expert (GRTE)
Apprenez et pratiquez le hacking Azure :
HackTricks Training Azure Red Team Expert (AzRTE)
Soutenir HackTricks
- Vérifiez les plans d’abonnement !
- Rejoignez le 💬 groupe Discord ou le groupe telegram ou suivez-nous sur Twitter 🐦 @hacktricks_live.
- Partagez des astuces de hacking en soumettant des PR au HackTricks et HackTricks Cloud dépôts github.


