HTTP 引荐来源网址陷阱?

发布于 2024-07-21 20:12:29 字数 203 浏览 9 评论 0原文

我需要确保我的网页始终位于第三方拥有的 iframe 内。 该第三方使用 src="../index.php" 引用我们的登陆页面。

现在我的问题是,如果我使用引荐来源网址来确保该页面是由我自己或第三方请求的,并且如果不强制重新加载第 3 方网站,是否有我应该注意的重大问题?

例如,是否有某些常见浏览器不遵循引用规则?

谢谢。

I need to ensure that my webpage is always within an iframe owned by a 3rd party. This third party refers to our landing page using src="../index.php".

Now my question is, if I make use of referrer to ensure that the page was requested by either myself or from the third party and if not force a reload of the 3rd party site, are there any big gotchas I should be aware of?

For example, are there certain common browsers that don't follow the referrer rules?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

一腔孤↑勇 2024-07-28 20:12:29

另外,它是 REFERER 因为它在规范中不知何故拼写错误。 这是我的第一个 REFERER 问题。

Also, it's REFERER because it somehow got misspelled in the spec. That was my very first REFERER gotcha.

眼泪都笑了 2024-07-28 20:12:29

您可以执行此操作的唯一方法是直接授权请求,因为引用者操纵。

如果您想宽松,或者要求包含的客户端,您可以将请求限制为一组IP地址/system 对于 iframe 中显示的请求有一个身份验证 cookie

祝你好运

The only way you could do this is to directly authorize the request because of referrer manipulation..

You could restrict requests to a set of IP addresses, if you want to be lax, or require that the including client/system has an authentication cookie for requests shown in the iframe.

Good Luck

愿得七秒忆 2024-07-28 20:12:29

不需要推荐人。 如果浏览器不提供它,那么您将陷入无限的重定向循环。 Referrer 实际上是“自愿的”,就像 cookies、java 和 javascript 一样。

虽然。 您可以保留 IP 和 IP 的日志。 最后重定向的时间。 删除超过 5 分钟的日志,并且每 5 分钟重定向一次以上。 您应该捕获 99.9% 的用户,但避免其余用户出现无限重定向循环。 日志不能依赖于浏览器中的任何内容(这是最初的问题),因此没有 cookie 也没有会话。 一个简单的 2 列数据库表就足够了。

Referrers are not required. If a browser doesn't supply it then you'll get yourself into an endless redirect loop. Referrer is effectively "voluntary" just like cookies, java, and javascript.

Although. You could keep a log of IP & time last redirected. Prune the logs for anything over 5 minutes old and never redirect more than once per 5 minutes. You should catch 99.9% of users out there but avoid an infinite redirect loop for the rest. The log cannot rely on anything in the browser (that's the original problem) so no cookie and no session. A simple 2-column database table should suffice.

与之呼应 2024-07-28 20:12:29

You can't use referrer to "ensure" that the webpage is always being called from somewhere else because of referrer spoofing.

幸福丶如此 2024-07-28 20:12:29

即使是众所周知的格式也可能会改变......

谷歌显然已经改变了它的引用网址。 2009 年 4 月 14 日,Google.com 即将发生的变化搜索推荐; Google Analytics(分析)不受影响

从本周开始,您可能会开始看到针对来自 Google 搜索结果页的访问者的新引荐网址格式。 例如,到目前为止,点击“鲜花”搜索结果的通常引荐来源网址将如下所示:

 http://www.google.com/search?hl=en&q=flowers&btnG=Google+Search

现在您将开始看到一些如下所示的引用字符串:

 http://www.google.com/url? 
      sa=t&源=web&ct=res&cd=7 
      &url=http%3A%2F%2Fwww.example.com%2Fmypage.htm 
      &ei=0SjdSa-1N5O8M_qW8dQN&rct=j 
      &q=鲜花 
      &usg=AFQjCNHJXSUh7Vw7oubPaO3tZOzz-F-u_w 
      &sig2=X8uCFh6IoPtnwmvGMULQfw

另请参阅 Google 正在将其引用网址从 /search 更改为 /url .任何已知问题?

Even well-known formats may change...

Google apparently has changed its referrer URL. April 14, 2009, An upcoming change to Google.com search referrals; Google Analytics unaffected:

Starting this week, you may start seeing a new referring URL format for visitors coming from Google search result pages. Up to now, the usual referrer for clicks on search results for the term "flowers", for example, would be something like this:

  http://www.google.com/search?hl=en&q=flowers&btnG=Google+Search

Now you will start seeing some referrer strings that look like this:

  http://www.google.com/url?
    sa=t&source=web&ct=res&cd=7
    &url=http%3A%2F%2Fwww.example.com%2Fmypage.htm
    &ei=0SjdSa-1N5O8M_qW8dQN&rct=j
    &q=flowers
    &usg=AFQjCNHJXSUh7Vw7oubPaO3tZOzz-F-u_w
    &sig2=X8uCFh6IoPtnwmvGMULQfw

(See also Google is changing its referrer URLs from /search into /url. Any known issues?)

走野 2024-07-28 20:12:29

请注意,每当用户通过 JavaScript 导航到链接时,Internet Explorer(所有版本)都会专门省略 HTTP REFERRER。 (错误报告)

例如

function doSomething(url){
  //save some data to the session
  //...
  location.href = url;//IE will NOT pass the HTTP REFERRER on this link
}

Be aware that Internet Explorer (all versions) specifically OMITS the HTTP REFERRER whenever a user navigates to a link as a result of JavaScript. (bug report)

e.g.

function doSomething(url){
  //save some data to the session
  //...
  location.href = url;//IE will NOT pass the HTTP REFERRER on this link
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文