You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/binary-exploitation/libc-heap/house-of-spirit.md
+26-3Lines changed: 26 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,6 +64,7 @@ int main() {
64
64
### Requirements
65
65
66
66
- This attack requires an attacker to be able to create a couple of fake fast chunks indicating correctly the size value of it and then to be able to free the first fake chunk so it gets into the bin.
67
+
- With **tcache (glibc ≥2.26)** the attack is even simpler: only one fake chunk is needed (no next-chunk size check is performed on the tcache path) as long as the fake chunk is 0x10-aligned and its size field falls in a valid tcache bin (0x20-0x410 on x64).
67
68
68
69
### Attack
69
70
@@ -72,6 +73,9 @@ int main() {
72
73
73
74
**The code from**[**guyinatuxedo**](https://guyinatuxedo.github.io/39-house_of_spirit/house_spirit_exp/index.html)**is great to understand the attack.** Although this schema from the code summarises it pretty good:
74
75
76
+
<details>
77
+
<summary>Fake chunk layout</summary>
78
+
75
79
```c
76
80
/*
77
81
this will be the structure of our two fake chunks:
@@ -96,9 +100,30 @@ int main() {
96
100
*/
97
101
```
98
102
103
+
</details>
104
+
99
105
> [!TIP]
100
106
> Note that it's necessary to create the second chunk in order to bypass some sanity checks.
101
107
108
+
### Tcache house of spirit (glibc ≥2.26)
109
+
110
+
- On modern glibc the **tcache fast-path** calls `tcache_put` before validating the next chunk size/`prev_inuse`, so only the current fake chunk has to look sane.
111
+
- Requirements:
112
+
- Fake chunk must be **16-byte aligned** and not marked `IS_MMAPPED`/`NON_MAIN_ARENA`.
113
+
-`size` must belong to a tcache bin and include the **prev_inuse bit set** (`size | 1`).
114
+
- Tcache for that bin must not be full (default max 7 entries).
- **Safe-linking** is not a barrier here: the forward pointer stored in tcache is automatically encoded as `fd = ptr ^ (heap_base >> 12)` during `free`, so the attacker does not need to know the key when using a single fake chunk.
125
+
- This variant is handy when glibc hooks were removed (≥2.34) and you want a fast arbitrary write or to overlap a target buffer (e.g., stack/BSS) with a tcache chunk without creating additional corruptions.
0 commit comments