《Nginx配置文件安全分析工具:Gixy》要點(diǎn):
本文介紹了Nginx配置文件安全分析工具:Gixy,希望對(duì)您有用。如果有疑問,可以聯(lián)系我們。
Gixy是一款用來分析Nginx配置文件的工具. Gixy的主要目標(biāo)是防止安全配置錯(cuò)誤,并自動(dòng)進(jìn)行缺陷檢測(cè).
Gixy特性
項(xiàng)目地址:https://github.com/yandex/gixy
Gixy安裝
Gixy是一個(gè)Python開發(fā)的應(yīng)用,目前支持的Python版本是2.7和3.5+.
安裝步驟非常簡(jiǎn)單,直接使用pip安裝即可:
$ pip install gixy
如果你的系統(tǒng)比較老,自帶Python版本比較低.可參考「使用pyenv搭建python虛擬環(huán)境」或者「如何在CentOS上啟用軟件集Software Collections(SCL)」升級(jí)Python版本.
Gixy使用
Gixy默認(rèn)會(huì)檢查/etc/nginx/nginx.conf
配置文件.
$ gixy
也可以指定NGINX配置文件所在的位置.
$ gixy /usr/local/nginx/conf/nginx.conf
==================== Results ===================
No issues found.
==================== Summary ===================
Total issues:
Unspecified: 0
Low: 0 ? ?Medium: 0
High: 0
來看一個(gè)http折分配置有問題的示例,修改Nginx配置:
server {
…
location ~ /v1/((?<action>[^.]*)\.json)?$ {
add_header X-Action $action;
}
…}
再次運(yùn)行Gixy檢查配置.
$ gixy /usr/local/nginx/conf/nginx.conf
==================== Results ===================
>> Problem: [http_splitting] Possible HTTP-Splitting vulnerability.
Description: Using variables that can contain “\n” may lead to http injection.
Additional info: https://github.com/yandex/gixy/blob/master/docs/en/plugins/httpsplitting.md
Reason: At least variable “$action” can contain “\n”
Pseudo config:server {
server_name localhost mike.hi-linux.com;location ~ /v1/((?<action>[^.]*)\.json)?$ {
add_header X-Action $action;
}
}==================== Summary ===================
Total issues:
Unspecified: 0
Low: 0
Medium: 0
High: 1
從結(jié)果可以看出檢測(cè)到了一個(gè)問題,指出問題類型為http_splitting
.原因是$action
變量中可以含有換行符.這就是HTTP響應(yīng)頭拆分漏洞,通過CRLFZ注入實(shí)現(xiàn)攻擊.
如果你要暫時(shí)忽略某類錯(cuò)誤檢查,可以使用--skips
參數(shù):
$ gixy –skips http_splitting /usr/local/nginx/conf/nginx.conf
==================== Results ===================
No issues found.==================== Summary ===================
Total issues:
Unspecified: 0
Low: 0
Medium: 0
High: 0
更多使用方法可以參考gixy --help
命令.
參考文檔
http://www.google.comhttps://github.com/yandex/gixy
文章來自微信公眾號(hào):運(yùn)維之美
轉(zhuǎn)載請(qǐng)注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/3764.html