Detect Nginx Configuration Vulnerabilities with Gixy: A Practical Guide
This article introduces Gixy, a static analysis tool for Nginx configurations, demonstrates how to detect and fix HTTP header splitting and other security issues, explains its handling of included files, lists detectable vulnerabilities, and provides simple installation instructions.
Introduction
Gixy is a static analysis tool for Nginx configuration files, aimed at preventing security problems caused by improper settings. It works without starting any environment; you only need to specify the path to the config file.
Usage Example
Given a configuration file t.conf :
server {
listen 80 default;
location ~ /v1/((?<action>[^.]*)\.json)?$ {
add_header X-Action $action;
return 200 "OK";
}
}Run the analysis: gixy t.conf The result shows an http_splitting issue because the $action variable may contain a carriage‑return character, leading to an HTTP response header splitting vulnerability (CRLF injection). Example request:
/v1/see%20below%0d%0ax-crlf-header:injected.jsonWhen decoded, the request contains a line break, allowing an attacker to inject an extra header:
HTTP/1.1 200 OK
Server: nginx/1.11.10
Date: Mon, 13 Mar 2017 21:21:29 GMT
Content-Type: application/octet-stream
Content-Length: 2
Connection: close
X-Action: see below
x-crlf-header:injectedTo fix it, tighten the location regex:
location ~ /v1/((?<action>[^/\s]+)\.json)?$ {
...
}Re‑running Gixy confirms the issue is resolved.
Gixy also analyzes files included via include directives, e.g., when nginx.conf contains include servers/*;, all files under servers are checked automatically.
Detectable Issues
SSRF (Server‑Side Request Forgery)
HTTP Splitting (response header injection)
Incorrect referrer/origin validation
Misuse of add_header directive
Host header spoofing
Allowing empty Referer
Multi‑line response headers
Installation
Gixy is published on PyPI and can be installed with: pip install gixy After installation, the gixy command is available.
Conclusion
Gixy is simple and useful; even users with limited security knowledge can gain confidence by scanning their Nginx configurations. The project has gained over 4,000 stars on GitHub: https://github.com/yandex/gixy .
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
