Skip to content

Commit 37896cb

Browse files
authored
fix(auth): validate origin of oauth callback to prevent login csrf (#1093)
1 parent 039a3c9 commit 37896cb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/auth/src/loginWithRocketChatOAuth.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ width=800,height=600,left=-1000,top=-1000,rel=opener`;
4545
return new Promise<any>((resolve) => {
4646
if (popup) {
4747
const onMessage = async (e: MessageEvent) => {
48+
if (e.origin !== new URL(config.api.baseUrl).origin) {
49+
return;
50+
}
4851
if (e.data.type === "rc-oauth-callback") {
4952
const { accessToken, expiresIn, serviceName } = e.data.credentials;
5053
const response = await config.api.post("/api/v1/login", {

0 commit comments

Comments
 (0)