Repository navigation
v2.50.0
๐ก๏ธ ๋์ฉ๋ ์ ๋ก๋ ์ค์ ์ด WAF๋ฅผ ํต์งธ๋ก ๋๊ณ ์์์ต๋๋ค
โ ๏ธ ์ด ์ค์ ์ ์ฐ๊ณ ๊ณ์
จ๋ค๋ฉด ์ง๊ธ๊น์ง ์์ฒญ ๊ฒ์ฌ๊ฐ ์์์ต๋๋ค
์ฑ๋ฅ โ ํ๋ก์ ์์ฒญ ๋ฒํผ๋ง์ off๋ก ๋์ จ๋ค๋ฉด, ๊ทธ ํธ์คํธ์ WAF๋ ์์ฒญ์ ํ๋๋ ๊ฒ์ฌํ์ง ์๊ณ ์์์ต๋๋ค. ์ ์ญ ์ค์ ์ผ๋ก off๋ฅผ ๋์ ๊ฒฝ์ฐ์๋ ๋ชจ๋ ํธ์คํธ๊ฐ ํด๋น๋ฉ๋๋ค.
์ด์ ๋ ์ด๋ ์ต๋๋ค. ๊ทธ๋์ NPG๋ ์์ฒญ ๋ฒํผ๋ง์ด ๊บผ์ง WAF ํธ์คํธ์ SecRequestBodyAccess Off๋ฅผ ์๋์ผ๋ก ๋ฃ์์ต๋๋ค. ์ฃผ์์๋ "๋ณธ๋ฌธ ๊ฒ์ฌ๋ง ๋๊ณ ํค๋์ URL ํจํด์ ๊ณ์ ๋ณดํธํ๋ค"๊ณ ์ ํ ์์๋๋ฐ, ์ฌ์ค์ด ์๋์์ต๋๋ค. ModSecurity v3๋ ์ด ์ค์ ์ด ๊บผ์ง๋ฉด phase 2 ์ ์ฒด๋ฅผ ๊ฑด๋๋๋๋ค. ๊ทธ๋ฐ๋ฐ OWASP CRS๋ ์ ์ ๋์ ๋ฐฉ์์ด๋ผ ์ฐจ๋จ ํ์ ์์ฒด๊ฐ phase 2์ ์์ต๋๋ค. ๊ฒฐ๊ณผ์ ์ผ๋ก ํค๋๋ URL๋ ์๋ฌด๊ฒ๋ ๋ง์ง ๋ชปํ์ต๋๋ค.
์ค์ ๋ก ์ธก์ ํด ๋ดค์ต๋๋ค. ์ฐจ๋จ ๋ชจ๋ ํธ์คํธ์์ ์ด ์ค์ ์ ์ผ ์ ํ๋ก ๊ฐ์ ์์ฒญ์ ๋ณด๋๋๋:
| ๊ณต๊ฒฉ | ์ค์ ์ | ์ค์ ํ |
|---|---|---|
| ์ฟผ๋ฆฌ์คํธ๋ง SQL ์ธ์ ์ | 403 | 200 |
| ์ฟผ๋ฆฌ์คํธ๋ง XSS | 403 | 200 |
๊ฒฝ๋ก ํ์ (../../etc/passwd) |
403 | 200 |
| ์ค์บ๋ User-Agent | 403 | 200 |
| log4shell ํค๋ | 403 | 200 |
| ๋ณธ๋ฌธ SQL ์ธ์ ์ ยท RCE | 403 | 200 |
10๊ฑด ์ค 10๊ฑด์ด ํต๊ณผํ์ต๋๋ค. ๋ ๋์ ๊ฑด ํ๋ฉด์์ผ๋ก๋ WAF๊ฐ ์ด์ ์์ด ๋ณด์๋ค๋ ์ ์ ๋๋ค. ์ค์บ๋ ํ์ง ๊ฐ์ ์ผ๋ถ ๊ท์น์ ๊ณ์ ๋ฐํํด์ WAF ์ด๋ฒคํธ ๋ชฉ๋ก์ ๊ธฐ๋ก์ด ์์ด๋๋ฐ, ์๋ต์ 200์ด์์ต๋๋ค.
๊ทธ๋ฆฌ๊ณ ์ด ์ค์ ์ ์๋ฌด ์ด๋๋ ์์์ต๋๋ค. 300MB ์ ๋ก๋๋ก ํ์ธํด ๋ณด๋, ์ด ์ค์ ์ด ์๋ ์๋ ์์ ํ์ผ์ด ๋๊ฐ์ด 314MB๊น์ง ์๋์ต๋๋ค. WAF๊ฐ ์ผ์ง ํธ์คํธ์์๋ ModSecurity ์ปค๋ฅํฐ๊ฐ ๋ณธ๋ฌธ ์ ์ฒด๋ฅผ ์ด์ฐจํผ ์ฝ๊ธฐ ๋๋ฌธ์, ์ด๋ค ์ค์ ์ผ๋ก๋ ์คํธ๋ฆฌ๋ฐ์ด ๋์ง ์์ต๋๋ค.
์ด์ ์ด ์ค์ ์ ๋ฃ์ง ์์ต๋๋ค. ์ ๊ทธ๋ ์ด๋ํ๋ฉด ์์ฒญ ๊ฒ์ฌ๊ฐ ๊ณง๋ฐ๋ก ๋ณต์๋ฉ๋๋ค.
๐ ํ์ผ ์ ๋ก๋๊ฐ WAF์ ๋งํ๋ ๋ฌธ์
์ ์์ ์ธ ํ์ผ ์ ๋ก๋๊ฐ 403์ผ๋ก ๊ฑฐ๋ถ๋๋ ์ผ์ด ์์์ต๋๋ค. ModSecurity v3์ ๋ฉํฐํํธ ํ์๊ฐ ๊ท๊ฒฉ์ ๋ง๋ ๋ณธ๋ฌธ์๋ "๊ฒฝ๊ณ ๋ฌธ์์ด์ด ๋ง์ง ์์" ํ๋๊ทธ๋ฅผ ์ธ์ฐ๊ณ , ๊ทธ ํ๋๊ทธ๊ฐ ๊ณง๋ฐ๋ก ์ฐจ๋จ์ผ๋ก ์ด์ด์ก๊ธฐ ๋๋ฌธ์ ๋๋ค.
์์ SecRequestBodyAccess Off๋ ์ฌ์ค ์ด ์คํ์ ๋ฎ๊ณ ์์์ต๋๋ค. ๊ทธ๋ฐ๋ฐ ์คํ์ ๋ฒํผ๋ง ์ค์ ๊ณผ ์๋ฌด ์๊ด์ด ์์ต๋๋ค โ ๋ฒํผ๋ง์ ์ผ ํธ์คํธ๋ ๋๊ฐ์ด ๋งํ์ต๋๋ค. ๊ทธ๋์ ์ ์ ์
๋ก๋๊ฐ ๊นจ์ง ํธ์คํธ๋ค์ ์๋ฌด ์ํ๋ ๋ฐ์ง ๋ชปํ ์ฑ, ์๋ฑํ ํธ์คํธ์ WAF๋ง ๊บผ์ ธ ์์์ต๋๋ค.
์ด์ WAF๋ฅผ ์ผ ๋ชจ๋ ํธ์คํธ์์ ํ์์ ์คํ ๊ท์น ๋ ๊ฐ๋ง ์ ๊ฑฐํฉ๋๋ค. CRS์ ๋ฉํฐํํธ ์ฐํ ํ์ง์ ๋ณธ๋ฌธ์ ๋ํ ๋ชจ๋ ๊ฒ์ฌ๋ ๊ทธ๋๋ก ๋์ํฉ๋๋ค.
๋ณธ๋ฌธ์ ์์ ํ์ฑํ ์ ์๋ ์์ฒญ(๊นจ์ง JSONยทXML ํฌํจ)์ ๋ํ ์ฐจ๋จ์ ๊ทธ๋๋ก ๋ก๋๋ค. ํ์ฑ์ด ์ ๋ ๋ณธ๋ฌธ์ ๊ฒ์ฌํ ๋์์ด ์์ผ๋ฏ๋ก, ๊ทธ ์ฐจ๋จ์ด ์ ์ผํ ๋ฐฉ์ด์ ์ ๋๋ค.
๐ข WAF๊ฐ POST๋ฅผ ์ฐจ๋จํ๋ฉด 405๋ฅผ ๋๋ ค์ฃผ๋ ๋ฌธ์
๋ณธ๋ฌธ์ด ์๋ ์์ฒญ์ WAF๊ฐ ๋ง์ผ๋ฉด ํด๋ผ์ด์ธํธ๋ 403์ด ์๋๋ผ 405 Not Allowed๋ฅผ ๋ฐ์์ต๋๋ค. ์ฐจ๋จ ์๋ด ํ์ด์ง๋ฅผ ์ ์ ํ์ผ๋ก ์๋นํ๋ ๊ณผ์ ์์ nginx๊ฐ POST์ 405๋ก ๋ตํ๊ธฐ ๋๋ฌธ์ด์์ต๋๋ค.
๋ก๊ทธ์๋ 405๋ก ๊ธฐ๋ก๋์ต๋๋ค. ๊ทธ๋์ fail2ban์ ์คํจ ์ฝ๋๋ฅผ 403์ผ๋ก ๋์ จ๋ค๋ฉด ๋ณธ๋ฌธ ๊ณต๊ฒฉ ์ฐจ๋จ์ ํ๋๋ ์ธ์ด์ง์ง ์์๊ณ , 403์ ์ธ๋ ๋์๋ณด๋ ์ซ์์์๋ ๋น ์ ธ ์์์ต๋๋ค. ์ด์ 403์ ๋๋ ค์ฃผ๊ณ 403์ผ๋ก ๊ธฐ๋กํฉ๋๋ค.
๐ ์ง์ค ์ฑ๋ฆฐ์ง ๋ชจ๋์์ WAF๊ฐ ๊ฒ์ฌ๋ฅผ ๋ชป ํ๋ ๋ฌธ์
๊ตญ๊ฐ ์ฐจ๋จ์ ์ฑ๋ฆฐ์ง ๋ชจ๋๋ก ์ฐ๋ ํธ์คํธ์์, WAF๊ฐ ์์ฒญ์ ์ ๋๋ก ๊ฒ์ฌํ์ง ๋ชปํ์ต๋๋ค.
์ฑ๋ฆฐ์ง ๋์ ์์ฒญ์ CAPTCHA ํ์ด์ง๋ก ๋ฆฌ๋ค์ด๋ ํธ๋๋๋ฐ, ์ด ๋ฆฌ๋ค์ด๋ ํธ๊ฐ nginx์ ์ด๋ฅธ ์ฒ๋ฆฌ ๋จ๊ณ์์ ์์ฒญ์ ๋๋ด ๋ฒ๋ ค ModSecurity์ ์ฐจ๋จ ํ์ ๋จ๊ณ๊ฐ ์คํ๋์ง ์์์ต๋๋ค. ๊ฐ๋ฐ ํ๊ฒฝ ๋ก๊ทธ๋ก ํ์ธํด ๋ณด๋ ๋ช ํํ์ต๋๋ค โ ์ฑ๋ฆฐ์ง๋ก ๋๋ ์์ฒญ ์ค SQL ์ธ์ ์ ํ์ง(942100)๋ 0๊ฑด, ๊ฐ์ ํธ์คํธ์ ์ผ๋ฐ ์ฐจ๋จ ์์ฒญ์์๋ 2,565๊ฑด์ด์์ต๋๋ค. ์ค์บ๋ ํ์ง ๊ฐ์ ์๋จ ๊ท์น๋ง ๋ก๊ทธ์ ๋จ๊ณ , ์ค์ ๊ณต๊ฒฉ์ ๋ก๊ทธ์กฐ์ฐจ ๋จ์ง ์์์ต๋๋ค.
์ด์ ์ฑ๋ฆฐ์ง ํ๋จ์ ๋ค์ชฝ ๋จ๊ณ๋ก ์ฎ๊ฒจ์, WAF๊ฐ ๋จผ์ ๊ฒ์ฌํ ๋ค ์ฑ๋ฆฐ์ง๊ฐ ๊ฒฐ์ ๋ฉ๋๋ค. ํด์ธ ๋ฐฉ๋ฌธ์ ๊ฒฝํ์ ๊ทธ๋๋ก์ ๋๋ค(์ฟ ํค ์์ผ๋ฉด CAPTCHA, ์ ํจํ ์ฟ ํค๋ฉด ํต๊ณผ, ๊ฒ์๋ด์ ์์ธ). ์ถ๊ฐ API ํธ์ถ๋ ์๊ณ , API๊ฐ ๋ด๋ ค๊ฐ ์์ ๋์ ๋์๋ ์ด์ ๊ณผ ๊ฐ์ต๋๋ค.
๐ซ fail2ban "์๋ฆผ๋ง"์ด ์ค์ ๋ก๋ ์ฐจ๋จํ๋ ๋ฌธ์
์ก์ ์ "์๋ฆผ๋ง" ์ผ๋ก ๋์ จ์ด๋ IP๊ฐ ์ค์ ๋ก ์ฐจ๋จ๋์ต๋๋ค. ํ๋ฉด์ ์ฝ์๊ณผ ์ ๋ฐ๋์์ต๋๋ค.
์ด์ ์ธ ๊ฐ์ง๊ฐ ์ด๋ฆ๋๋ก ๋์ํฉ๋๋ค.
| ์ก์ | ๋์ |
|---|---|
| IP ์ฐจ๋จ | ์ฐจ๋จ + ์๋ฆผ |
| ์๋ฆผ๋ง | ์ฐจ๋จํ์ง ์๊ณ ์๋ฆผ๋ง |
| ๋ก๊ทธ๋ง ๊ธฐ๋ก | ์ปจํ ์ด๋ ๋ก๊ทธ์๋ง ๊ธฐ๋ก |
"์๋ฆผ๋ง"์ ์ํ ์๋ฆผ ์ด๋ฒคํธ(IP ๊ฐ์ง โ ์ฐจ๋จ ์ ํจ)๋ฅผ ์๋ก ์ถ๊ฐํ์ต๋๋ค. ์๋ฆผ ์ค์ ์์ ๋ฐ๋ก ์ผ์ค ์ ์์ต๋๋ค.
โ fail2ban ์คํจ ์ฝ๋ ์ ๋ ฅ ๊ฒ์ฆ
์คํจ ์ฝ๋์ 4o1(์ซ์ 0์ด ์๋ ์ํ๋ฒณ o), 401;403(์ผํ ๋์ ์ธ๋ฏธ์ฝ๋ก ), 4xx ๊ฐ์ ๊ฐ์ ๋ฃ์ด๋ ์ ์ฅ์ ์ ์์ ์ผ๋ก ๋๊ณ , ๊ทธ๋ค์ ์์ํ ์๋ฌด๊ฒ๋ ๋งค์นญ๋์ง ์์์ต๋๋ค. ์ ์ ๊ฑธ๋ฆฌ๋์ง ์ ๋ฐฉ๋ฒ์ด ์์์ต๋๋ค. ์ด์ ์ ์ฅํ ๋ ๊ฑฐ์ ํ๊ณ ๋ฌด์์ด ์๋ชป๋๋์ง ์๋ ค ๋๋ฆฝ๋๋ค.
์คํจ ์ฝ๋์ ๋ํด ํ ๊ฐ์ง ์์ ๋์ค ์ ์ด ์์ต๋๋ค. fail2ban์ ๊ทธ ํธ์คํธ๊ฐ ์ง์ ์๋ตํ ์ฝ๋๋ง ์
๋๋ค. IP๋ก ์ง์ ์ ์ํด ์จ ์์ฒญ์ ๋๋ 444๋ ์ด๋ ํ๋ก์ ํธ์คํธ์๋ ์ํ์ง ์๊ธฐ ๋๋ฌธ์, ์คํจ ์ฝ๋์ ๋ฃ์ผ์
๋ ๋ฐ๋ํ์ง ์์ต๋๋ค. ๋์๋ง์๋ ์ด ๋ด์ฉ์ ์ ์ด ๋์์ต๋๋ค. (#271)
์์ธํ ์ง์ด ์ฃผ์ @re-birkin ๋, @ydrob ๋, @VoltIcaRus ๋ ๊ฐ์ฌํฉ๋๋ค. (#271, #272)
apiยทui ์ด๋ฏธ์ง๋ฅผ ๋ชจ๋ ๋ฐ์ ๋ค์ ์ฌ๋ ค ์ฃผ์ธ์.
docker compose pull && docker compose up -d
๐ก๏ธ A large-upload setting was disabling the WAF entirely
โ ๏ธ If you used it, requests were not being inspected at all
If you set Performance โ Proxy Request Buffering to off, that host's WAF was inspecting nothing. If you set it globally, that applied to every host.
Here is what was happening. NPG emitted SecRequestBodyAccess Off on WAF-enabled hosts whose request buffering was off. The comment claimed it only disabled body inspection and that "WAF still protects headers, URL patterns". That was not true. ModSecurity v3 skips all of phase 2 when that directive is off โ and because OWASP CRS runs in anomaly-scoring mode, the blocking decision itself lives in phase 2. Nothing was blocked.
Measured on a blocking-mode host, identical requests before and after the directive:
| Attack | Without | With |
|---|---|---|
| SQL injection in query string | 403 | 200 |
| XSS in query string | 403 | 200 |
Path traversal (../../etc/passwd) |
403 | 200 |
| Scanner User-Agent | 403 | 200 |
| log4shell header | 403 | 200 |
| SQL injection / RCE in body | 403 | 200 |
Ten out of ten got through. Worse, the WAF still looked alive: some phase-1 rules kept firing, so events kept arriving in the WAF log โ with a 200 response.
And the directive bought nothing. Sampling a 300MB upload showed the temp file growing to the same 314MB with or without it. On a WAF-enabled host the ModSecurity connector reads the whole body regardless, so no configuration can stream around it.
The directive is no longer emitted. Upgrading restores request inspection immediately.
๐ File uploads blocked by the WAF
Ordinary file uploads were rejected with 403. ModSecurity v3's multipart parser raises an "unmatched boundary" flag on spec-compliant bodies, and that flag denied the request outright.
The directive above was in fact papering over this. But the false positive has nothing to do with buffering โ hosts with buffering left on were hit just as hard. So the hosts whose uploads were actually broken got no mitigation, while unrelated hosts had their WAF switched off.
Now every WAF-enabled host drops just the two parser false-positive rules. CRS multipart-evasion detection and all body inspection continue to run.
The deny for bodies that cannot be parsed at all (malformed JSON and XML included) is deliberately kept. A body that failed to parse populates nothing for the rules to inspect, so that deny is the only thing left.
๐ข WAF blocks on POST answered 405
When the WAF blocked a request with a body, the client got 405 Not Allowed, not 403 โ nginx answers a POST that way when the block page is served as a static file.
It was logged as 405 too. So if your fail2ban fail codes included 403, body attacks never counted, and they were missing from any 403-based dashboard figure. It now answers and logs 403.
๐ The WAF could not inspect challenged requests
On hosts using challenge mode for country restriction, the WAF was not properly inspecting requests.
A challenged request is redirected to the CAPTCHA page, and that redirect ended the request early enough that ModSecurity's blocking stage never ran. The logs made it unambiguous: among requests that ended in a challenge, SQL-injection detections (942100) numbered zero, versus 2,565 on ordinary blocked requests for the same host. Only early-stage rules such as scanner detection were logged; real attacks were not logged at all.
The challenge decision now happens later, so the WAF inspects first. The visitor experience is unchanged (no cookie โ CAPTCHA, valid cookie โ through, search bots exempt), with no extra API calls and no change to behavior while the API is down.
๐ซ fail2ban "Notify Only" was banning
With the action set to Notify Only, the address was actually banned โ the opposite of what the control promised.
The three actions now do what they say:
| Action | Behavior |
|---|---|
| Block IP | Bans and notifies |
| Notify Only | Notifies without banning |
| Log Only | Container log only |
A notification event for it (IP detected โ not banned) is now available in the alert settings.
โ fail2ban fail codes are validated
Values like 4o1, 401;403 or 4xx saved successfully and then silently never matched, with no way to tell why. They are now rejected at save time with the reason.
One thing worth knowing about fail codes: fail2ban only counts responses the host itself answered. 444, which drops requests that arrived by IP with no matching host, belongs to no proxy host โ adding it to the fail codes cannot fire. The help text now says so. (#271)
Thanks to @re-birkin, @ydrob and @VoltIcaRus for the detailed reports. (#271, #272)
Pull both the api and ui images and restart.
docker compose pull && docker compose up -d
Docker Images
docker pull svrforum/nginxproxyguard-api:2.50.0
docker pull svrforum/nginxproxyguard-ui:2.50.0
docker pull svrforum/nginxproxyguard-nginx:2.50.0Architectures: linux/amd64, linux/arm64
| Component | Status |
|---|---|
| API | Built |
| UI | Built |
| Nginx | Skipped (no changes) |