在 iframe 中访问表单数据

Accessing form data inside iframe

是否可以从外部源在 iframe 中使用 javascript 访问表单数据?

例如:我在 example.com 上有一家网上商店。如果我将支付网关 stripe.com 与 iframe 集成 https://stripe.com/checkout 结合使用,是否可以访问用户在 iframe 弹出窗口中以 1 秒间隔插入的输入数据?

我想确定万一有人入侵我的网站,无法访问客户的付款详细信息。

Is it possible to access form data with javascript inside iframe from external source?

没有。这是由同源策略阻止的。

If I use payment gateway stripe.com with iframe integration https://stripe.com/checkout is it possible to access input data user inserts

不是以直接的 JS 方式,而是针对 iframe 中的内容进行了多次点击劫持攻击。参见示例 http://www.contextis.com/documents/5/Context-Clickjacking_white_paper.pdf

但是在这种情况下,这一点没有实际意义,因为:

I would like to be sure that i case one hacks into my website, one cannot access payment details of customers.

这是无法实现的。如果您的站点受到损害(在服务器或客户端通过 XSS),攻击者可以更改父页面以使其弹出一个虚假的结帐 iframe,而不是使用真正的 Stripe 脚本,该脚本会泄露输入的付款详细信息。

这是所有基于 iframe 的结帐的风险:用户无法验证 iframe 的来源和 HTTPS 详细信息,因此他们必须信任父页面(商家)的信息。