demo: add toggle for Date.now()=NaN or untamed
MODIFY
demo/demo-start.js
demo/demo-start.js
@@ -40,7 +40,13 @@ function start() {
}
// build the SES Realm and evaluate the defender inside
- const r = SES.makeSESRootRealm();
+ const options = {};
+ document.getElementById('dateNowStatus').textContent = 'Date.now() returns NaN';
+ if (window.location.search.indexOf('dateNow=enabled') !== -1) {
+ document.getElementById('dateNowStatus').textContent = 'Date.now() enabled';
+ options.dateNowTrap = false;
+ }
+ const r = SES.makeSESRootRealm(options);
const defenderSrc = buildDefenderSrc();
const d = r.evaluate(defenderSrc, { getRandomValues, setMacguffinText, delayMS, setAttackerGuess, launch, log });

MODIFY
demo/index.html
demo/index.html
@@ -31,7 +31,10 @@ worked out the full password, roughly 18 seconds later.</p>
<p>However an SES-confined program does not get access to non-determinism
(except as mediated by the code that built the environment), so this attacker
-doesn't get a clock, and cannot read from the covert channel.</p>
+doesn't get a clock, and cannot read from the covert channel. Load this page
+<a href="?dateNow=enabled">with ?dateNow=enabled</a> to demonstrate the
+attack with <code>Date.now</code> enabled, or <a href="?dateNow=NaN">with
+?dateNow=NaN</a> to properly confine the attacker.</p>
<p>The defender is given access to two functions which the attacker does not
get: one which provides random values to create the MacGuffin (normally
@@ -70,6 +73,8 @@ setGuess('0000000000');
<button id="attacker-stop" type="button">Stop</button>
</div>
+<p><span id="dateNowStatus" /></p>
+
<h2>Sample Attacks:</h2>
<p>Click the button to populate the test code, then use Execute to run it.</p>

demo: add toggle for Date.now()=NaN or untamed