Skip to content

Commit 9117453

Browse files
steveseguinactions-user
authored andcommitted
fix(youtube): validate OAuth state parameter during authentication
Add a check that the `state` returned in the OAuth callback matches the value stored before the sign-in flow began. This prevents CSRF attacks by ensuring the response corresponds to the original request. If the state does not match, an error is thrown with a clear message prompting the user to re-authenticate. [auto-enhanced]
1 parent 523878e commit 9117453

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

sources/websocket/youtube_auth.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@
202202
if (!result || !result.code) {
203203
throw new Error("YouTube sign-in did not return an authorization code.");
204204
}
205+
var expectedState = getStoredState();
206+
if (!expectedState || result.state !== expectedState) {
207+
throw new Error("State mismatch during YouTube sign-in. Please try signing in again.");
208+
}
205209
var data = await postHostedYouTubeAuthJson("/token", {
206210
code: result.code,
207211
redirect_uri: result.redirectUri,

0 commit comments

Comments
 (0)