From 9a905c9bfcaed4eaf9a7ee2da394525129367499 Mon Sep 17 00:00:00 2001 From: Open Source Contributor Date: Sun, 21 Jun 2026 03:03:58 +0530 Subject: [PATCH] fix: prevent face detection bypass via spacebar hold and click propagation (#515) - Added a check in handlePlayPause() to block resuming playback when an anomaly is active (pauseVid || rewindVid || doGesture). - Ignored repeated Spacebar keydown events (event.repeat === true) in the window keydown listener. - Blocked click/mousedown event propagation on the Anomaly overlay wrapper, ConfirmOverlay, and NavigatingOverlay to prevent them from bubbling up and toggling playback. --- frontend/src/components/video.tsx | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/video.tsx b/frontend/src/components/video.tsx index bf68c9d66..3a861b065 100644 --- a/frontend/src/components/video.tsx +++ b/frontend/src/components/video.tsx @@ -327,12 +327,16 @@ export default function Video({ URL, startTime, nextItemId, endTime, points, ano // Prevent playing if current time is at or beyond endTime if (endTimeSeconds > 0 && currentTime >= endTimeSeconds) { return; - }else{ - player.playVideo(); } + // Block resuming if any proctoring anomalies or gesture prompts are active + if (pauseVid || rewindVid || doGesture) { + console.log("🔒 Play blocked: Anomaly or gesture prompt active"); + return; + } + player.playVideo(); setTimeout(() => { playerRef.current?.setPlaybackRate?.(playbackRate); }, 50); } - }, [playing, endTimeSeconds, currentTime, isSkipping, isStopFailed, isStopping, playbackRate]); + }, [playing, endTimeSeconds, currentTime, isSkipping, isStopFailed, isStopping, playbackRate, pauseVid, rewindVid, doGesture]); const handleBackward = () => { const player = playerRef.current; @@ -989,6 +993,10 @@ export default function Video({ URL, startTime, nextItemId, endTime, points, ano if (rawEvent.code === 'Space') { rawEvent.preventDefault(); rawEvent.stopImmediatePropagation(); + if (rawEvent.repeat) { + // Ignore held down spacebar to prevent rapid play/pause bypass + return; + } handlePlayPause(); return; } @@ -1355,6 +1363,10 @@ export default function Video({ URL, startTime, nextItemId, endTime, points, ano className='shadow-2xl' + onClick={(e) => e.stopPropagation()} + + onMouseDown={(e) => e.stopPropagation()} + style={{ position: 'absolute', @@ -2095,6 +2107,8 @@ export function NavigatingOverlay({ return (
e.stopPropagation()} + onMouseDown={(e) => e.stopPropagation()} > @@ -2152,6 +2166,8 @@ export function ConfirmOverlay({ return (
e.stopPropagation()} + onMouseDown={(e) => e.stopPropagation()} >