[Google API潜在的安全风险

问题描述 投票:0回答:1

我已经对此进行了一段时间的故障排除,但是我还没有计算出用户错误,但是我发现的是...经过Google验证的对/youtube/v3/channels?part=id&mine=true的调用返回了先前登录的.auth.currentUser

解决错误的唯一方法是使用Google Chrome浏览器使用CTRL+Shift+Delete清除缓存和保存的密码信息

[我不是用localStorage.getItem来记住旧的登录信息,我正在仔细检查网络呼叫请求是否使用F12(网络检查)从currentUser提供的access_token,结果基本上仍然是错误的“ currentUser” GET请求返回了错误的YouTube频道ID

如果您尝试使用3-4个用户登录并注销,则此错误开始发生。

[请注意,api请求仅需要access_token。可以将access_token链接到错误的currentUsers吗?基本上可以告诉我currentUser是X,但是access_token仍然链接到用户Y

接下来,我需要检查api范围是否仍链接到错误的用户。那将是一种灾难性的安全性失败。

[请评论我如何证明我的发现,我将更新此帖子。

var url = `https://www.googleapis.com/youtube/v3/channels?part=id&mine=true`;

axios
  .get(url, {
    headers: {
      Authorization: `Bearer ${this.props.auth.currentUser.je.tc.access_token}`,
    },
  })
  .then(
    function (response) {
      // handle success
      console.log(response);
     })
  .catch(function (error) {
    // handle error
    console.log(error);
  }) 

登录代码

 GoogleSignIn() {
    this.auth.signIn().then((resp) => {
      console.log(resp);
      this.setState(
        {
          SignInStatus: true,
          userChannel: resp.Pt.Ad,
          access_token: resp.tc.access_token,
          id_token: resp.tc.id_token,
          auth: this.auth,
        },
        () => {
          console.log(this.state.id_token);
          console.log(this.state.userChannel);
          console.log(this.state.access_token);
        }
      );
    });
  }

更新...如何防止HTTP GET缓存????enter image description here

javascript google-chrome security youtube-data-api google-oauth2
1个回答
0
投票

使用无缓存发送请求,现在似乎已解决。

axios
  .get(url, {
    headers: {
      Authorization: `Bearer ${this.props.auth.currentUser.je.tc.access_token}`,
      "Cache-Control": "no-cache",
    },
  })
© www.soinside.com 2019 - 2024. All rights reserved.