简体   繁体   English

使用“代理”在HTTPS站点中显示HTTP内容

[英]Displaying HTTP content in HTTPS site using a “proxy”

I have an https web application in which we display external content in iframes (totally customizable by the user) 我有一个https Web应用程序,其中我们在iframe中显示外部内容(可由用户完全自定义)

Since mixed content is blocked by many browsers I do the following for HTTP content: 由于混合内容被许多浏览器阻止,因此我对HTTP内容执行以下操作:
An iframe links to my own JSP and sends the requested url as a parameter. 一个iframe链接到我自己的JSP,然后将请求的网址作为参数发送。 The JSP then creates an input stream with the url and returns the response. 然后,JSP使用url创建输入流并返回响应。

BufferedReader reader = null;
URL url;
String strUrl = (String) request.getParameter("url");
try {
    url = new URL(strUrl);
    reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));

    for (String line; (line = reader.readLine()) != null;) {
        out.println(line);
    }
} catch (Exception e) {
    log.warn("Error on URL " + strUrl);
} finally {
    if (reader != null)
        try {
            reader.close();
        } catch (IOException ignore) {
        }
}

This works very well. 这很好。
The question is: 问题是:
Can someone explain what are the security concerns here, is this something I would want to do? 有人可以解释一下这里的安全问题吗,这是我想做的吗? (I can technically say that only HTTPS urls are supported...). (从技术上讲,我只能支持HTTPS网址...)。

Thanks! 谢谢!

Yes, this is certainly a security concern. 是的,这当然是安全问题。 What you've created is called an ' open redirect ' and it's used in phishing attacks. 您创建的内容称为“ 开放重定向 ”,用于网络钓鱼攻击。

An attackers can abuse the trust your users have in your website (communication signed and encrypted with your SSL certificate) to redirect them to a malicious site. 攻击者可以滥用用户对您网站的信任(使用SSL证书签名和加密的通信),将他们重定向到恶意网站。

Even though, they may not be able to control the usage of this JSP on your website, they can use it in an email or website comment. 即使他们可能无法控制您网站上此JSP的使用,也可以在电子邮件或网站评论中使用它。 See this question for more information. 有关更多信息,请参见此问题

You can solve this problem by maintaining the list of sites you want to convert from HTTP to HTTPS at the server side and refer to them by index or keyword, like: 您可以通过在服务器端维护要从HTTP转换为HTTPS的站点列表,并通过索引或关键字引用它们来解决此问题,例如:

https://myserver/proxy.jsp?url=site1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM