《Nginx配置文件安全分析工具:Gixy》要點:
本文介紹了Nginx配置文件安全分析工具:Gixy,希望對您有用。如果有疑問,可以聯系我們。
Gixy是一款用來分析Nginx配置文件的工具. Gixy的主要目標是防止安全配置錯誤,并自動進行缺陷檢測.
Gixy特性
項目地址:https://github.com/yandex/gixy
Gixy安裝
Gixy是一個Python開發的應用,目前支持的Python版本是2.7和3.5+.
安裝步驟非常簡單,直接使用pip安裝即可:
$ pip install gixy
如果你的系統比較老,自帶Python版本比較低.可參考「使用pyenv搭建python虛擬環境」或者「如何在CentOS上啟用軟件集Software Collections(SCL)」升級Python版本.
Gixy使用
Gixy默認會檢查/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
來看一個http折分配置有問題的示例,修改Nginx配置:
server {
…
location ~ /v1/((?<action>[^.]*)\.json)?$ {
add_header X-Action $action;
}
…}
再次運行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
從結果可以看出檢測到了一個問題,指出問題類型為http_splitting
.原因是$action
變量中可以含有換行符.這就是HTTP響應頭拆分漏洞,通過CRLFZ注入實現攻擊.
如果你要暫時忽略某類錯誤檢查,可以使用--skips
參數:
$ 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
文章來自微信公眾號:運維之美
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/3764.html