Menu

Improved exploit search engine. Try it out

"Android - binder Use-After-Free of VMA via race Between reclaim and munmap"

Author

"Google Security Research"

Platform

android

Release date

2019-02-12

Release Date Title Type Platform Author
2019-05-16 "WeChat for Android 7.0.4 - 'vcodec2_hls_filter' Denial of Service" dos android "Hong Nhat Pham"
2019-03-06 "Android - getpidcon() Usage in Hardware binder ServiceManager Permits ACL Bypass" dos android "Google Security Research"
2019-03-06 "Android - binder Use-After-Free via racy Initialization of ->allow_user_free" dos android "Google Security Research"
2019-02-28 "FTP Server 1.32 - Denial of Service" dos android s4vitar
2019-02-21 "AirDrop 2.0 - Denial of Service (DoS)" dos android s4vitar
2019-02-21 "ScreenStream 3.0.15 - Denial of Service" dos android s4vitar
2019-02-20 "Android Kernel < 4.8 - ptrace seccomp Filter Bypass" dos android "Google Security Research"
2019-02-15 "AirMore 1.6.1 - Denial of Service (PoC)" dos android s4vitar
2019-02-14 "ApowerManager 3.1.7 - Phone Manager Remote Denial of Service (PoC)" dos android s4vitar
2019-02-12 "Android - binder Use-After-Free of VMA via race Between reclaim and munmap" dos android "Google Security Research"
2019-02-12 "Android - binder Use-After-Free via fdget() Optimization" dos android "Google Security Research"
2019-02-11 "AirDroid 4.2.1.6 - Denial of Service" dos android s4vitar
2019-01-15 "1Password < 7.0 - Denial of Service" dos android "Valerio Brussani"
2015-07-06 "AirDroid - Arbitrary File Upload" webapps android "Parsa Adib"
2011-11-28 "Google Android - 'content://' URI Multiple Information Disclosure Vulnerabilities" webapps android "Thomas Cannon"
2017-09-20 "Android Bluetooth - 'Blueborne' Information Leak (2)" remote android "Kert Ojasoo"
2017-08-09 "Android Bluetooth - 'Blueborne' Information Leak (1)" remote android "Kert Ojasoo"
2018-04-06 "LineageOS 14.1 Blueborne - Remote Code Execution" remote android "Marcin Kozlowski"
2018-02-25 "Papenmeier WiFi Baby Monitor Free & Lite < 2.02.2 - Remote Audio Record" remote android iamrastating
2017-07-20 "Virtual Postage (VPA) - Man In The Middle Remote Code Execution" remote android intern0t
2017-07-20 "SKILLS.com.au Industry App - Man In The Middle Remote Code Execution" remote android intern0t
2017-06-30 "Australian Education App - Remote Code Execution" remote android intern0t
2017-06-30 "BestSafe Browser - Man In The Middle Remote Code Execution" remote android intern0t
2017-06-14 "Google Chrome - V8 Private Property Arbitrary Code Execution" remote android Qihoo360
2017-06-30 "eVestigator Forensic PenTester - Man In The Middle Remote Code Execution" remote android intern0t
2017-12-20 "Samsung Internet Browser - SOP Bypass (Metasploit)" remote android "Dhiraj Mishra"
2017-12-18 "Outlook for Android - Attachment Download Directory Traversal" remote android "Google Security Research"
2016-09-27 "Google Android 5.0 < 5.1.1 - 'Stagefright' .MP4 tx3g Integer Overflow (Metasploit)" remote android Metasploit
2016-11-28 "Google Android - 'BadKernel' Remote Code Execution" remote android "Guang Gong"
2016-03-30 "Google Android 5.0.1 - Metaphor Stagefright (ASLR Bypass)" remote android NorthBit
Release Date Title Type Platform Author
2019-05-23 "Microsoft Windows 10 1809 - 'CmKeyBodyRemapToVirtualForEnum' Arbitrary Key Enumeration Privilege Escalation" local windows "Google Security Research"
2019-05-23 "Visual Voicemail for iPhone - IMAP NAMESPACE Processing Use-After-Free" dos ios "Google Security Research"
2019-05-21 "Apple macOS < 10.14.5 / iOS < 12.3 XNU - 'in6_pcbdetach' Stale Pointer Use-After-Free" dos multiple "Google Security Research"
2019-05-21 "Apple macOS < 10.14.5 / iOS < 12.3 XNU - Wild-read due to bad cast in stf_ioctl" dos multiple "Google Security Research"
2019-05-21 "Apple macOS < 10.14.5 / iOS < 12.3 JavaScriptCore - AIR Optimization Incorrectly Removes Assignment to Register" dos multiple "Google Security Research"
2019-05-21 "Apple macOS < 10.14.5 / iOS < 12.3 JavaScriptCore - Loop-Invariant Code Motion (LICM) in DFG JIT Leaves Stack Variable Uninitialized" dos multiple "Google Security Research"
2019-05-21 "Apple macOS < 10.14.5 / iOS < 12.3 DFG JIT Compiler - 'HasIndexedProperty' Use-After-Free" dos multiple "Google Security Research"
2019-05-13 "Google Chrome V8 - Turbofan JSCallReducer::ReduceArrayIndexOfIncludes Out-of-Bounds Read/Write" dos multiple "Google Security Research"
2019-04-30 "Linux - Missing Locking Between ELF coredump code and userfaultfd VMA Modification" dos linux "Google Security Research"
2019-04-26 "systemd - DynamicUser can Create setuid Binaries when Assisted by Another Process" dos linux "Google Security Research"
2019-04-24 "Google Chrome 72.0.3626.121 / 74.0.3725.0 - 'NewFixedDoubleArray' Integer Overflow" remote multiple "Google Security Research"
2019-04-24 "VirtualBox 6.0.4 r128413 - COM RPC Interface Code Injection Host Privilege Escalation" local windows "Google Security Research"
2019-04-23 "Linux - 'page->_refcount' Overflow via FUSE" dos linux "Google Security Research"
2019-04-23 "Linux - Missing Locking in Siemens R3964 Line Discipline Race Condition" dos linux "Google Security Research"
2019-04-23 "systemd - Lack of Seat Verification in PAM Module Permits Spoofing Active Session to polkit" dos linux "Google Security Research"
2019-04-17 "Oracle Java Runtime Environment - Heap Corruption During TTF font Rendering in GlyphIterator::setCurrGlyphID" dos multiple "Google Security Research"
2019-04-17 "Oracle Java Runtime Environment - Heap Corruption During TTF font Rendering in sc_FindExtrema4" dos multiple "Google Security Research"
2019-04-16 "Microsoft Windows 10 1809 - LUAFV PostLuafvPostReadWrite SECTION_OBJECT_POINTERS Race Condition Privilege Escalation" local windows "Google Security Research"
2019-04-16 "Microsoft Windows 10 1809 - LUAFV Delayed Virtualization Cache Manager Poisoning Privilege Escalation" local windows "Google Security Research"
2019-04-16 "Microsoft Windows 10 1809 - LUAFV NtSetCachedSigningLevel Device Guard Bypass" local windows "Google Security Research"
2019-04-16 "Microsoft Windows 10 1809 - LUAFV LuafvCopyShortName Arbitrary Short Name Privilege Escalation" local windows "Google Security Research"
2019-04-16 "Microsoft Windows 10 1809 - LUAFV Delayed Virtualization Cross Process Handle Duplication Privilege Escalation" local windows "Google Security Research"
2019-04-16 "Microsoft Windows 10 1809 - LUAFV Delayed Virtualization MAXIMUM_ACCESS DesiredAccess Privilege Escalation" local windows "Google Security Research"
2019-04-16 "Microsoft Windows 10 1809 / 1709 - CSRSS SxSSrv Cached Manifest Privilege Escalation" local windows "Google Security Research"
2019-04-03 "Google Chrome 72.0.3626.96 / 74.0.3702.0 - 'JSPromise::TriggerPromiseReactions' Type Confusion" remote multiple "Google Security Research"
2019-04-03 "Google Chrome 73.0.3683.39 / Chromium 74.0.3712.0 - 'ReadableStream' Internal Object Leak Type Confusion" dos multiple "Google Security Research"
2019-04-03 "Google Chrome 72.0.3626.81 - 'V8TrustedTypePolicyOptions::ToImpl' Type Confusion" dos multiple "Google Security Research"
2019-04-03 "WebKitGTK+ - 'ThreadedCompositor' Race Condition" dos multiple "Google Security Research"
2019-04-03 "WebKit JavaScriptCore - CodeBlock Dangling Watchpoints Use-After-Free" dos multiple "Google Security Research"
2019-04-03 "WebKit JavaScriptCore - Out-Of-Bounds Access in FTL JIT due to LICM Moving Array Access Before the Bounds Check" dos multiple "Google Security Research"
import requests
response = requests.get('https://www.nmmapper.com/api/exploitdetails/46357/?format=json')
                                                {"url": "https://www.nmmapper.com/api/exploitdetails/46357/?format=json", "download_file": "https://www.nmmapper.com/st/exploitdetails/46357/40801/android-binder-use-after-free-of-vma-via-race-between-reclaim-and-munmap/download/", "exploit_id": "46357", "exploit_description": "\"Android - binder Use-After-Free of VMA via race Between reclaim and munmap\"", "exploit_date": "2019-02-12", "exploit_author": "\"Google Security Research\"", "exploit_type": "dos", "exploit_platform": "android", "exploit_port": null}
                                            

For full documentation follow the link above

Browse exploit DB API Browse

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
The following bug report solely looks at the situation on the upstream master
branch; while from a cursory look, at least the wahoo kernel also looks
affected, I have only properly tested this on upstream master.

There is a race condition between the direct reclaim path (enters binder through
the binder_shrinker) and the munmap() syscall (enters binder through the ->close
handler of binder_vm_ops).

Coming from the munmap() syscall:

binder_vma_close()->binder_alloc_vma_close()->binder_alloc_set_vma() sets
alloc->vma to NULL without taking any extra locks; binder_vma_close() is called
from remove_vma()<-remove_vma_list()<-__do_munmap()<-__vm_munmap()<-sys_munmap()
with only the mmap_sem held for writing.

Coming through the direct reclaim path:

binder_alloc_free_page() doesn't hold the mmap_sem on entry. It contains the
following code (comments added by me):

enum lru_status binder_alloc_free_page(struct list_head *item,
                                       struct list_lru_one *lru,
                                       spinlock_t *lock,
                                       void *cb_arg)
{
[...]
        alloc = page->alloc;
        if (!mutex_trylock(&alloc->mutex))
                goto err_get_alloc_mutex_failed;

        if (!page->page_ptr)
                goto err_page_already_freed;

        index = page - alloc->pages;
        page_addr = (uintptr_t)alloc->buffer + index * PAGE_SIZE;
        // unprotected pointer read! `vma` can immediately be freed
        vma = binder_alloc_get_vma(alloc);
        if (vma) {
                if (!mmget_not_zero(alloc->vma_vm_mm))
                        goto err_mmget;
                mm = alloc->vma_vm_mm;
                if (!down_write_trylock(&mm->mmap_sem))
                        goto err_down_write_mmap_sem_failed;
                // mmap_sem is held at this point, but the vma pointer was read
                // before and can be dangling
        }

        list_lru_isolate(lru, item);
        spin_unlock(lock);

        if (vma) {
                trace_binder_unmap_user_start(alloc, index);

                // dangling vma pointer passed to zap_page_range
                zap_page_range(vma,
                               page_addr + alloc->user_buffer_offset,
                               PAGE_SIZE);

                trace_binder_unmap_user_end(alloc, index);

                up_write(&mm->mmap_sem);
                mmput(mm);
        }


Repro instructions:

Unpack the attached binder_race_freevma.tar.
Apply the patch 0001-binder-VMA-unprotected-read-helper.patch to an upstream
git master tree to widen the race window.
Make sure that KASAN is enabled in your kernel config.
Build and boot into the built kernel.
Run "echo 16383 > /sys/module/binder/parameters/debug_mask" for more dmesg debug
output.
Compile the PoC with ./compile.sh and, as root, run ./poc to trigger the bug.

The output of the PoC should look like this:
======================
# ./poc
### PING
0000: 00 . 00 . 00 . 00 .
BR_NOOP:
BR_TRANSACTION:
  target 0000000000000000  cookie 0000000000000000  code 00000001  flags 00000010
  pid     1266  uid        0  data 4  offs 0
0000: 00 . 00 . 00 . 00 .
got transaction!
binder_send_reply(status=0)
offsets=0x7fffb76cf6c0, offsets_size=0
BR_NOOP:
BR_TRANSACTION_COMPLETE:
BR_REPLY:
  target 0000000000000000  cookie 0000000000000000  code 00000000  flags 00000000
  pid        0  uid        0  data 4  offs 0
0000: 00 . 00 . 00 . 00 .
### FLUSHING PAGES
BR_NOOP:
BR_TRANSACTION_COMPLETE:
### END OF PAGE FLUSH
binder_done: freeing buffer
binder_done: free done
### PING DONE
### FLUSHING PAGES
$$$ sleeping before munmap...
$$$ calling munmap now...
$$$ munmap done
### END OF PAGE FLUSH
Killed
======================

The dmesg splat should look like this:
======================
[  803.130180] binder: binder_open: 1265:1265
[  803.132143] binder: binder_mmap: 1265 7fdcbc599000-7fdcbc999000 (4096 K) vma 71 pagep 8000000000000025
[  803.135861] binder: 1265:1265 node 1 u0000000000000000 c0000000000000000 created
[  803.138748] binder: 1265:1265 write 4 at 00007fffb76cf820, read 0 at 0000000000000000
[  803.141875] binder: 1265:1265 BC_ENTER_LOOPER
[  803.143634] binder: 1265:1265 wrote 4 of 4, read return 0 of 0
[  803.146073] binder: 1265:1265 write 0 at 0000000000000000, read 128 at 00007fffb76cf820
[  804.130600] binder: binder_open: 1266:1266
[  804.132909] binder: binder_mmap: 1266 7fdcbc599000-7fdcbc999000 (4096 K) vma 71 pagep 8000000000000025
[  804.138535] binder: 1266:1266 write 68 at 00007fffb76cf850, read 128 at 00007fffb76cf7d0
[  804.142411] binder: 1266:1266 BC_TRANSACTION 2 -> 1265 - node 1, data 00007fffb76cf9a0-00007fffb76cf980 size 4-0-0
[  804.146208] binder: 1265:1265 BR_TRANSACTION 2 1266:1266, cmd -2143260158 size 4-0 ptr 00007fdcbc599000-00007fdcbc599008
[  804.152836] binder: 1265:1265 wrote 0 of 0, read return 72 of 128
[  804.156944] binder: 1265:1265 write 88 at 00007fffb76cf5a0, read 0 at 0000000000000000
[  804.159315] binder: 1265:1265 BC_FREE_BUFFER u00007fdcbc599000 found buffer 2 for active transaction
[  804.161715] binder: 1265 buffer release 2, size 4-0, failed at 000000003c152ea0
[  804.164114] binder: 1265:1265 BC_REPLY 3 -> 1266:1266, data 00007fffb76cf6e0-00007fffb76cf6c0 size 4-0-0
[  804.166646] binder: 1265:1265 wrote 88 of 88, read return 0 of 0
[  804.166756] binder: 1266:1266 BR_TRANSACTION_COMPLETE
[  804.168323] binder: 1265:1265 write 0 at 0000000000000000, read 128 at 00007fffb76cf820
[  804.169876] binder: 1266:1266 BR_REPLY 3 0:0, cmd -2143260157 size 4-0 ptr 00007fdcbc599000-00007fdcbc599008
[  804.171919] binder: 1265:1265 BR_TRANSACTION_COMPLETE
[  804.174743] binder: 1266:1266 wrote 68 of 68, read return 76 of 128
[  804.176003] binder: 1265:1265 wrote 0 of 0, read return 8 of 128
[  804.179416] binder: 1265:1265 write 0 at 0000000000000000, read 128 at 00007fffb76cf820
[  804.179755] binder_alloc: binder_alloc_free_page() starting delay for alloc=000000005f5225f3
[  804.680227] binder_alloc: binder_alloc_free_page() ending delay for alloc=000000005f5225f3
[  804.735851] poc (1266): drop_caches: 2
[  804.772381] binder: 1266:1266 write 12 at 00007fffb76cf8d4, read 0 at 0000000000000000
[  804.774629] binder: 1266:1266 BC_FREE_BUFFER u00007fdcbc599000 found buffer 3 for finished transaction
[  804.791063] binder: 1266 buffer release 3, size 4-0, failed at 000000003c152ea0
[  804.792753] binder: 1266:1266 wrote 12 of 12, read return 0 of 0
[  804.833806] binder_alloc: binder_alloc_free_page() starting delay for alloc=0000000083fec45f
[  805.034060] binder: 1266 close vm area 7fdcbc599000-7fdcbc999000 (4096 K) vma 18020051 pagep 8000000000000025
[  805.041265] binder_alloc: starting binder_alloc_vma_close() for alloc=0000000083fec45f
[  805.045625] binder_alloc: ending binder_alloc_vma_close() for alloc=0000000083fec45f
[  805.331890] binder_alloc: binder_alloc_free_page() ending delay for alloc=0000000083fec45f
[  805.333845] ==================================================================
[  805.338188] BUG: KASAN: use-after-free in zap_page_range+0x7c/0x270
[  805.342064] Read of size 8 at addr ffff8881cd86ba80 by task poc/1266

[  805.346390] CPU: 0 PID: 1266 Comm: poc Not tainted 4.20.0-rc3+ #222
[  805.348277] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
[  805.350777] Call Trace:
[  805.351528]  dump_stack+0x71/0xab
[  805.352536]  print_address_description+0x6a/0x270
[  805.353947]  kasan_report+0x260/0x380
[...]
[  805.356241]  zap_page_range+0x7c/0x270
[...]
[  805.363990]  binder_alloc_free_page+0x41a/0x560
[...]
[  805.369678]  __list_lru_walk_one.isra.12+0x8c/0x1c0
[...]
[  805.373458]  list_lru_walk_one+0x42/0x60
[  805.374666]  binder_shrink_scan+0xe2/0x130
[...]
[  805.378626]  shrink_slab.constprop.89+0x252/0x530
[...]
[  805.383716]  drop_slab+0x3b/0x70
[  805.384721]  drop_caches_sysctl_handler+0x4d/0xc0
[  805.386150]  proc_sys_call_handler+0x162/0x180
[...]
[  805.392156]  __vfs_write+0xc4/0x370
[...]
[  805.399347]  vfs_write+0xe7/0x230
[  805.400355]  ksys_write+0xa1/0x120
[...]
[  805.403501]  do_syscall_64+0x73/0x160
[  805.404488]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
[...]

[  805.424394] Allocated by task 1266:
[  805.425372]  kasan_kmalloc+0xa0/0xd0
[  805.426264]  kmem_cache_alloc+0xdc/0x1e0
[  805.427349]  vm_area_alloc+0x1b/0x80
[  805.428398]  mmap_region+0x4db/0xa60
[  805.429708]  do_mmap+0x44d/0x6f0
[  805.430564]  vm_mmap_pgoff+0x163/0x1b0
[  805.431664]  ksys_mmap_pgoff+0x2cf/0x330
[  805.432791]  do_syscall_64+0x73/0x160
[  805.433839]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

[  805.435754] Freed by task 1267:
[  805.436527]  __kasan_slab_free+0x130/0x180
[  805.437650]  kmem_cache_free+0x73/0x1c0
[  805.438812]  remove_vma+0x8d/0xa0
[  805.439792]  __do_munmap+0x443/0x690
[  805.440871]  __vm_munmap+0xbf/0x130
[  805.441882]  __x64_sys_munmap+0x3c/0x50
[  805.442926]  do_syscall_64+0x73/0x160
[  805.443951]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

[  805.445926] The buggy address belongs to the object at ffff8881cd86ba40
                which belongs to the cache vm_area_struct of size 200
[  805.449363] The buggy address is located 64 bytes inside of
                200-byte region [ffff8881cd86ba40, ffff8881cd86bb08)
[...]
[  805.475924] ==================================================================
[  805.477921] Disabling lock debugging due to kernel taint
[  805.479843] poc (1266): drop_caches: 2
[  810.482080] binder: 1265 close vm area 7fdcbc599000-7fdcbc999000 (4096 K) vma 18020051 pagep 8000000000000025
[  810.482406] binder: binder_flush: 1266 woke 0 threads
[  810.488231] binder_alloc: starting binder_alloc_vma_close() for alloc=000000005f5225f3
[  810.490091] binder: binder_deferred_release: 1266 threads 1, nodes 0 (ref 0), refs 0, active transactions 0
[  810.493418] binder_alloc: ending binder_alloc_vma_close() for alloc=000000005f5225f3
[  810.498145] binder: binder_flush: 1265 woke 0 threads
[  810.499442] binder: binder_deferred_release: 1265 context_mgr_node gone
[  810.501178] binder: binder_deferred_release: 1265 threads 1, nodes 1 (ref 0), refs 0, active transactions 0
======================


Proof of Concept:
https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/46357.zip