From 1f9a65a197cd7bf8cdeda83f46ad5e2b43fc0870 Mon Sep 17 00:00:00 2001 From: Andrew Krasichkov Date: Tue, 10 Oct 2017 14:59:18 +0300 Subject: [PATCH] [alias_traversal] Added documentation --- README.RU.md | 1 + README.md | 1 + docs/en/plugins/aliastraversal.md | 25 +++++++++++++++++++++++++ docs/ru/plugins/aliastraversal.md | 25 +++++++++++++++++++++++++ 4 files changed, 52 insertions(+) diff --git a/README.RU.md b/README.RU.md index 222589c..265b59d 100644 --- a/README.RU.md +++ b/README.RU.md @@ -24,6 +24,7 @@ Gixy — это утилита для анализа конфигурации Ng * [[host_spoofing] Подделка заголовка запроса Host](https://github.com/yandex/gixy/blob/master/docs/ru/plugins/hostspoofing.md) * [[valid_referers] none in valid_referers](https://github.com/yandex/gixy/blob/master/docs/ru/plugins/validreferers.md) * [[add_header_multiline] Многострочные заголовоки ответа](https://github.com/yandex/gixy/blob/master/docs/ru/plugins/addheadermultiline.md) + * [[alias_traversal] Path traversal при использовании alias](https://github.com/yandex/gixy/blob/master/docs/ru/plugins/aliastraversal.md) Проблемы, которым Gixy только учится можно найти в [Issues с меткой "new plugin"](https://github.com/yandex/gixy/issues?q=is%3Aissue+is%3Aopen+label%3A%22new+plugin%22) diff --git a/README.md b/README.md index a054bc5..4eb4d55 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Right now Gixy can find: * [[host_spoofing] Request's Host header forgery](https://github.com/yandex/gixy/blob/master/docs/en/plugins/hostspoofing.md) * [[valid_referers] none in valid_referers](https://github.com/yandex/gixy/blob/master/docs/en/plugins/validreferers.md) * [[add_header_multiline] Multiline response headers](https://github.com/yandex/gixy/blob/master/docs/en/plugins/addheadermultiline.md) + * [[alias_traversal] Path traversal via misconfigured alias](https://github.com/yandex/gixy/blob/master/docs/en/plugins/aliastraversal.md) You can find things that Gixy is learning to detect at [Issues labeled with "new plugin"](https://github.com/yandex/gixy/issues?q=is%3Aissue+is%3Aopen+label%3A%22new+plugin%22) diff --git a/docs/en/plugins/aliastraversal.md b/docs/en/plugins/aliastraversal.md index e69de29..55e05a6 100644 --- a/docs/en/plugins/aliastraversal.md +++ b/docs/en/plugins/aliastraversal.md @@ -0,0 +1,25 @@ +# [alias_traversal] Path traversal via misconfigured alias + +The [alias](https://nginx.ru/ru/docs/http/ngx_http_core_module.html#alias) directive is used to replace path of the specified location. +For example, with the following configuration: +```nginx +location /i/ { + alias /data/w3/images/; +} +``` +on request of `/i/top.gif`, the file `/data/w3/images/top.gif` will be sent. + +But, if the location doesn't ends with directory separator (i.e. `/`): +```nginx +location /i { + alias /data/w3/images/; +} +``` +on request of `/i../app/config.py`, the file `/data/w3/app/config.py` will be sent. + +In other words, the incorrect configuration of `alias` could allow an attacker to read file stored outside the target folder. + +## What can I do? +It's pretty simple: + - you must find all the `alias` directives; + - make sure that the parent prefixed location ends with directory separator. diff --git a/docs/ru/plugins/aliastraversal.md b/docs/ru/plugins/aliastraversal.md index e69de29..d4f8998 100644 --- a/docs/ru/plugins/aliastraversal.md +++ b/docs/ru/plugins/aliastraversal.md @@ -0,0 +1,25 @@ +# [alias_traversal] Path traversal при использовании alias + +Директива [alias](https://nginx.ru/ru/docs/http/ngx_http_core_module.html#alias) используется для замены пути указанного локейшена. +К примеру, для конфигурации: +```nginx +location /i/ { + alias /data/w3/images/; +} +``` +на запрос `/i/top.gif` будет отдан файл `/data/w3/images/top.gif`. + +Однако, если локейшен не оканчивается разделителем директорий (`/`): +```nginx +location /i { + alias /data/w3/images/; +} +``` +то на запрос `/i../app/config.py` будет отдан файл `/data/w3/app/config.py`. + +Иными словами, не корректная конфигурация `alias` может позволить злоумышленнику прочесть файл за пределами целевой директории. + +## Что делать? +Все довольно просто: + - необходимо найти все директивы `alias`; + - убедится что вышестоящий префиксный локейшен оканчивается на `/`.