gpt4 book ai didi

javascript - 是什么阻止了 Ionic Security javascript SDK 被恶意行为者的网站加载?

转载 作者:行者123 更新时间:2023-11-30 19:25:29 25 4
gpt4 key购买 nike

Ionic JS SDK documentation提到the postMessage API用于与运行核心 SDK 代码的 iframe 通信。设备配置文件保存在 localStorage 中,范围限定为 iframe 的来源。

是什么阻止了 SDK JS 代码(和后续的 iframe)被加载到恶意站点并用于访问用户创建的用于加密/解密数据的配置文件?

最佳答案

要创建新的设备配置文件,应用程序应调用 enrollUser功能;参见:https://api.ionic.com/jssdk/latest/Docs/tutorial-device_enrollment.html

来自文档

Upon successful authentication within the 10-minute timeout window, an enrollment profile is stored encrypted in localStorage under the appId, userId, and the origin of the calling application.

所以配置文件是加密存储的。配置文件也按 origin、appid 和 userId 嵌套存储和命名空间,如下所示(请参阅 ProfileManager.js 中的 queryProfiles 函数):

profiles[origin][appId][userId]

请注意,origin 信息是从 iframe 中运行的 sdk 核心代码接收到的 postMessage 事件对象中提取的。

loadUser function接受与 enrollUser 相同的参数并执行反向操作,从 localStorage 加载配置文件并解密。

总结一下

What prevents the SDK JS code (and subsequent iframe) from being loaded on a malicious site and used to access the profiles a user has created to encrypt/decrypt data?

应用程序必须有权访问正在运行的相同 appIduserIduserAuth相同的 origin 以访问由另一个应用程序创建的配置文件。

在实践中

  • appId 是针对给定应用程序的硬编码(即在 js/html 中)
  • userIduserAuth 存储在应用程序用户的 session 对象中。这些值可以通过对应用程序源服务器的 ajax 请求获取,也可以写入应用程序 html 中。这类似于 normal handling practices for CSRF tokens .

关于javascript - 是什么阻止了 Ionic Security javascript SDK 被恶意行为者的网站加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56959416/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com