
# Git用户凭证泄露漏洞（CVE-2020-5260）
2020年4月15日，Git发布安全通告公布了一个导致Git用户凭证泄露的漏洞（CVE-2020-5260）。Git使用凭证助手(credential helper)来帮助用户存储和检索凭证。
当URL中包含经过编码的换行符（%0a）时，可能将非预期的值注入到credential helper的协议流中。受影响Git版本对恶意URL执行git clone命令时，会触发此漏洞，攻击者可利用恶意URL欺骗Git客户端发送主机凭据。
#### 漏洞编号
CVE-2020-5260
#### 漏洞名称
Git用户凭证泄露漏洞
#### 影响范围
**影响版本**
- Git 2.17.x \<= 2.17.3
- Git 2.18.x \<= 2.18.2
- Git 2.19.x \<= 2.19.3
- Git 2.20.x \<= 2.20.2
- Git 2.21.x \<= 2.21.1
- Git 2.22.x \<= 2.22.2
- Git 2.23.x \<= 2.23.1
- Git 2.24.x \<= 2.24.1
- Git 2.25.x \<= 2.25.2
- Git 2.26.x \<= 2.26.0
**安全版本**
- Git 2.17.4
- Git 2.18.3
- Git 2.19.4
- Git 2.20.3
- Git 2.21.2
- Git 2.22.3
- Git 2.23.2
- Git 2.24.2
- Git 2.25.3
- Git 2.26.1
 
#### 官网解决方案
目前官方已在最新版本中修复了该漏洞，请受影响的用户及时升级到安全版本。
官方下载链接：<https://github.com/git/git/releases>
#### 检测与修复建议
华为云企业主机安全对该漏洞的便捷检测与修复。
1. 检测并查看漏洞详情。 
   详细的操作步骤请参见[扫描漏洞](https://support.huaweicloud.com/usermanual-hss2.0/hss_01_0412.html)和[查看漏洞详情](https://support.huaweicloud.com/usermanual-hss2.0/hss_01_0063.html)。
   
   
2. 进行漏洞的修复与验证。 
   详细的操作步骤请参见[处理漏洞](https://support.huaweicloud.com/usermanual-hss2.0/hss_01_0141.html)。
   
   
 
#### 其他防护建议
若您暂时无法进行升级操作，也可以采用以下方式进行防护：
- 方式一：使用以下命令禁用credential helper **git config --unset credential.helper**
  **git config --global --unset credential.helper**
  **git config --system --unset credential.helper**
  
- 方式二：提高警惕避免恶意URL
  1. 使用git clone时，检查URL的主机名和用户名中是否存在编码的换行符（%0a）或者凭据协议注入的证据（例如：host=github.com）。
  
  2. 避免将子模块与不受信任的仓库一起使用（不使用clone --recurse-submodules；只有在检查gitmodules中找到url之后，才使用git submodule update）。
  
  3. 请勿对不受信任的URL执行git clone。
   
 
