
NGINX 구성을 스캔하여 CVE-2026-42945의 영향을 받는지 확인하세요.
CVE-2026-42945와 관련된 rewrite/set 패턴을 감지하는 NGINX 구성 파일용 정적 스캐너입니다.
이 스캐너는 crossplane으로 NGINX 구성을 파싱하고, location 블록을 순회하며, 영향을 받은 것처럼 보이는 모든 location을 다음 형식으로 출력합니다:
/<path-to>/xxx.conf:<line-number> -> location XXXXX
예시:
/path/to/nginx.conf:39 -> location ~ ^/api/(.*)$
참고: CVE-2026-42945-POC.
의존성은 pyproject.toml에서 uv로 관리되며 uv.lock에 잠겨 있습니다. 유일한 런타임 의존성은 crossplane입니다.
저장소 루트에서:
uv sync
별도의 설정 단계를 건너뛰고 uv run이 처음 사용 시 환경을 생성하도록 할 수도 있습니다.
구성 파일 하나 스캔:
uv run ./scan.py /etc/nginx/nginx.conf
디렉터리를 재귀적으로 스캔:
uv run ./scan.py -r /etc/nginx
현재 디렉터리에서 *.conf 파일을 재귀적으로 스캔:
uv run ./scan.py -r './*.conf'
스캐너가 재귀적으로 확장하도록 하려면 글로브를 따옴표로 묶으세요. 셸이 먼저 ./*.conf를 확장하면 스캐너는 셸이 매칭한 파일만 받습니다.
제공된 파일만 스캔하고 include 지시문을 따르지 않음:
uv run ./scan.py --single ./site.conf
누락된 include 파일을 포함한 파서 경고 표시:
uv run ./scan.py -v -r /etc/nginx
동일한 출력 형식과 종료 코드를 사용하는 Go 구현체가 go/에 제공됩니다. NGINX 구성 파싱에는 nginx-go-crossplane을, CLI 플래그에는 pflag를 사용합니다. Go 1.23 이상이 필요합니다.
go run으로 실행:
cd go
go run . -r ../tests/fixtures
탐지 결과가 있으면 스캐너는 코드 1로 종료합니다. 이 경우 go run은 exit status 1 줄을 추가로 출력하므로, 스캐너 출력만 원한다면 바이너리를 빌드하세요.
독립 실행형 바이너리 빌드:
cd go
go build -o cve-2026-42945-scan-go .
./cve-2026-42945-scan-go -r ../tests/fixtures
위험한 구성 패턴은 다음을 포함하는 location입니다:
?가 포함된 rewrite 지시문last, break, redirect, permanent 같은 종료 rewrite 플래그가 없음$1, ${1}, $name, ${name} 같은 정규식 캡처를 복사하는 set 지시문취약한 패턴 예시:
location ~ ^/api/(.*)$ {
rewrite ^/api/(.*)$ /internal?migrated=true;
set $original_endpoint $1;
}
스캐너는 rewrite나 set 줄이 아니라 location 줄을 보고합니다. location이 검토하고 수정해야 할 실행 가능한 블록이기 때문입니다.
tests/fixtures/ 디렉터리에는 예제로 사용할 수 있는 작은 NGINX 구성이 들어 있습니다:
| Fixture | Expected result |
|---|---|
tests/fixtures/vulnerable.conf | 위치 캡처 발견을 보고함 |
tests/fixtures/named_capture.conf | 명명된 캡처 발견을 보고함 |
tests/fixtures/missing_include_still_scans.conf | include가 누락되어도 발견을 보고함 |
tests/fixtures/safe_break_flag.conf | rewrite가 break를 사용하므로 발견 없음 |
tests/fixtures/safe_no_capture.conf | 사용 가능한 캡처가 없으므로 발견 없음 |
모든 예제 픽스처에 대해 스캐너 실행:
uv run ./scan.py -r tests/fixtures
예상 결과:
/absolute/path/to/tests/fixtures/missing_include_still_scans.conf:6 -> location ~ ^/partial/(.*)$
/absolute/path/to/tests/fixtures/named_capture.conf:2 -> location /users
/absolute/path/to/tests/fixtures/vulnerable.conf:2 -> location ~ ^/api/(.*)$
영향을 받은 location이 발견되면 각 발견 항목이 별도의 줄로 출력됩니다:
/absolute/path/to/file.conf:30 -> location ~ ^/aaaa/dddd/(.*)$
/absolute/path/to/nginx.conf:39 -> location ~ ^/api/(.*)$
출력이 없으면 파싱된 구성에서 영향을 받은 location을 찾지 못했다는 뜻입니다.
이 도구는 정적 구성 스캐너입니다. 다음을 수행하지 않습니다:
발견 항목을 검토하고 수정해야 할 location으로 취급하세요. 호스트가 실제로 영향을 받는 경우는 취약한 NGINX 버전 범위와 위험한 구성 패턴이 모두 존재할 때뿐입니다.
테스트 스위트 실행:
uv run python -m unittest discover -s tests -v
Go 테스트 스위트 실행:
cd go
go test ./...
구문 검사 실행:
uv run python -m py_compile scan.py
번들된 POC 구성에 대해 실행:
uv run ./scan.py CVE-2026-42945-POC/env/nginx.conf
예상 출력:
/absolute/path/to/CVE-2026-42945-POC/env/nginx.conf:39 -> location ~ ^/api/(.*)$