Translated message

A translation of this page exists in English.

HTTPoxy - 我的 Go 应用程序会受影响吗?

Solution Verified - Updated -

Environment

Red Hat Enterprise Linux 7.x

Issue

这个问题适用于在 CGI 模块中使用 Go 的情况。如果 Go CGI 脚本使用"HTTP_PROXY" 环境变量为后续的 HTTP 请求配置传出 HTTP 代理服务器,或者您的脚本在使用模块或库时暴露这个行为,比如 Go 的 "http" 模块,可让之后所有来自 Go CGI 脚本的 HTTP 流量被重新定向到攻击者控制的外部代理服务器。

请注意,这只会影响在启用了 CGI 的 HTTP 服务器中部署的 Go CGI 脚本,该服务器会使用 "HTTP_PROXY" 环境变量提供传入 HTTP 请求的 "Proxy" 标头。

Resolution

红帽为 HTTP 服务器提供了更新及缓解操作指南,可防止其将 "Proxy" 标头内容作为 "HTTP_PROXY" 环境变量提供。更新您的 HTTP 服务器或应用缓解操作可以关闭此向量,并防止有人利用此缺陷。

可采用以下方法之一防止使用攻击者提供的标头:

  • 配置网页应用程序防火墙,删除 "Proxy:" 标头。
  • 调用 Go 脚本前更改您的 HTTP 服务器配置,删除 "Proxy:" 标头(请参考以下 HTTProxy 文章链接中的其他知识库文章链接)。
  • 在您的程序中进行以下修改:
    在导入中添加 “os”(如果不存在):
    import “os”

在靠近 “main” 功能顶部的位置添加:

    os.Unsetenv(“HTTP_PROXY”)

Root Cause

详情请查看 HTTPoxy - CGI "HTTP_PROXY" variable name clash

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments