mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibWeb: Implement basic high resolution time coarsening
Several interfaces that return a high resolution time require that time to be coarsened, in order to prevent timing attacks. This implementation simply reduces the resolution of the returned timestamp to the minimum values given in the specification. Further work may be needed to make our implementation more robust to the kind of attacks that this mechanism is designed to prevent.
This commit is contained in:
parent
a5be7cb6fb
commit
39445d6dd6
Notes:
github-actions[bot]
2025-01-30 17:39:14 +00:00
Author: https://github.com/tcl3
Commit: 39445d6dd6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3381
Reviewed-by: https://github.com/AtkinsSJ ✅
7 changed files with 100 additions and 5 deletions
|
@ -5,6 +5,14 @@
|
|||
bufferedMessages.push(message);
|
||||
}
|
||||
|
||||
function synchronousWaitMicroseconds(microseconds) {
|
||||
var start = performance.now() * 1000,
|
||||
now = start;
|
||||
while (now - start < microseconds) {
|
||||
now = performance.now() * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
const globalObserver = new PerformanceObserver((list, observer) => {
|
||||
printlnBuffered(`observer === globalObserver: ${observer === globalObserver}`);
|
||||
printlnBuffered(
|
||||
|
@ -53,7 +61,11 @@
|
|||
globalObserver.observe({ entryTypes: ["measure", "mark"] });
|
||||
|
||||
const startMark = performance.mark("start");
|
||||
// The resolution of the clock used by the Performance interface is 100 microseconds, so we wait twice that time
|
||||
// between calls to ensure they are ordered as we expect.
|
||||
synchronousWaitMicroseconds(200);
|
||||
const endMark = performance.mark("end");
|
||||
synchronousWaitMicroseconds(200);
|
||||
const measureMark = performance.measure("measure", "start", "end");
|
||||
|
||||
function printCatchedException(func) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue