mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-11-22 08:13:59 +00:00
An application page could load any local file through file: URLs and reach any network destination with images, fetch, XHR or WebSockets, bypassing the component's fetch grants. The shell now checks every resource load: files inside the UI directory, inline data:, blob: and about: resources and the session bridge are allowed; anything else fails with a network error before a request leaves the renderer. tests/frame/check_confinement.py probes each path on the nested desktop and requires that no HTTP request or TCP connection reaches the host. The frame check's slow stylesheet becomes a file next to the page held back with a file lease, so it stays inside the confined scope.
65 lines
2 KiB
HTML
65 lines
2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>confinement</title>
|
|
<style>
|
|
html, body { margin: 0; height: 100%; }
|
|
body { display: flex; flex-direction: column; }
|
|
div { flex: 1; background: #808080; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="own-image"></div>
|
|
<div id="bridge"></div>
|
|
<div id="outside-image"></div>
|
|
<div id="other-image"></div>
|
|
<div id="http-image"></div>
|
|
<div id="http-fetch"></div>
|
|
<div id="websocket"></div>
|
|
<script>
|
|
// One band per probe: green when the outcome matches the policy, red when it
|
|
// does not. Every refused probe would succeed without the policy: the images
|
|
// are valid PNG files, the fetch uses no-cors, so an opaque response would
|
|
// resolve it, and the WebSocket listener accepts connections. The harness
|
|
// substitutes the ports and the path of a file outside the package.
|
|
var HTTP = 'http://127.0.0.1:@HTTP_PORT@/';
|
|
var TCP = 'ws://127.0.0.1:@TCP_PORT@/';
|
|
var OTHER = '@OTHER_URL@';
|
|
|
|
function mark(id, ok) {
|
|
document.getElementById(id).style.background = ok ? '#00c000' : '#e00000';
|
|
}
|
|
function image(id, src, shouldLoad) {
|
|
var img = new Image();
|
|
img.onload = function () { mark(id, shouldLoad); };
|
|
img.onerror = function () { mark(id, !shouldLoad); };
|
|
img.src = src;
|
|
}
|
|
|
|
image('own-image', 'own.png', true);
|
|
image('outside-image', '../outside.png', false);
|
|
image('other-image', OTHER, false);
|
|
image('http-image', HTTP + 'image.png', false);
|
|
fetch(HTTP + 'probe', { mode: 'no-cors' }).then(
|
|
function () { mark('http-fetch', false); },
|
|
function () { mark('http-fetch', true); });
|
|
|
|
try {
|
|
var ws = new WebSocket(TCP);
|
|
ws.onopen = function () { mark('websocket', false); };
|
|
ws.onerror = function () { mark('websocket', true); };
|
|
} catch (e) {
|
|
mark('websocket', true);
|
|
}
|
|
|
|
(function bridge() {
|
|
if (!window.weftIpc) { setTimeout(bridge, 50); return; }
|
|
window.weftIpc.onmessage = function (raw) {
|
|
try { mark('bridge', typeof JSON.parse(raw).count === 'number'); } catch (_) {}
|
|
};
|
|
window.weftIpc.send('get');
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|