Bounty 初體驗 - 資安

By Quanna
at 2021-03-31T17:26
at 2021-03-31T17:26
Table of Contents
※ 引述《CMJ0121 (不要偷 Q)》之銘言:
> 在待業的過程中 繼續找零用錢
因為之前有回報過 Synology 邀請我參加 7.0 beta 的測試 時間軸如下
2020-12-10 -> 收到邀請
2020-12-29 發送第二次回報 <-
2021-01-29 -> 終於確認受理範圍與獎金 (預計 2/29 發金)
同時宣告不能在 2021-03-29 前公布細節
2021-02-29 (沒收到 $$)
2021-03-03 還沒收到 $$ 寄信詢問 <-
2021-03-04 -> 表示會計問題 延遲發放
2021-03-15 寄信詢問發放時間 <-
2021-03-17 -> 宣稱 3/31 會發放獎金
2021-03-31 -> 表示發生意外、會額外寄送禮物表示歉意
2021-04-27 -> 已收到禮物
2021-05-03 -> 已收到獎金 <- 現在 (結案)
這次找到比較有趣的漏洞 是屬於 misconfiguration[0] 的類型
透過審慎 review 數千行 nginx 後 發現一個設定錯誤 在 nginx 設定檔中有很多重複出現下面的設定
location ~ ^/volume(?:X|USB|SATA|Gluster)?\d+/ {
internal;
root /;
open_file_cache off;
include conf.d/x-accel.*.conf;
}
在 nginx 官方文件描述[1] 設定 internal 的 location
只能被內部存取 (internal requests) 如果需要外部存取則需要透過
- error_page / index / random_index / try_files 做重導向
- 來自 upstream 且有 X-Accel-Redirect 這個額外 header 的重導向
- 透過 rewrite 的指定路徑
很明顯的 在這個 location 下可以存取的檔案都屬於高價值 (bounty 應該也比較高)
按照上面的可存取方式 最後發現幾個沒有正確的設定 像是
location ~ ^/oo/t/ {
rewrite /oo/t/([0-9a-zA-Z_.]+)$ /webman/3rdparty/Spreadsheet/index.html last;
rewrite /oo/t/(.*) /$1 last;
include scgi_params;
scgi_pass synoscgi;
}
透過 nginx 存取 /oo/t/ 開頭的路徑時 會做 redirect 判斷
- 符合 /oo/t/`數字、字母、底線、. 的組合` -> /webman/3rdparty/Spreadsheet/index.html
- 其他狀況 -> 其他狀況
表示如果存取 /oo/t/abcde 就會連到 /webman/3rdparty/Spreadsheet/index.html
但是連到 /oo/t/ab/cde 就會連到 /ab/cde
結合最開始的找到有趣的 inernal location 規則
就可以用 /oo/t/volumnX/Y/Z 存取 /volumnX/Y/Z 下的檔案了
## How to fix ##
其實解決方式也很簡單 Synology 的開發者其實也知道
就是在有機會做 redirect 的 location 下額外下 root 就可以 像是下面這個規則就不存在這個漏洞
location ~ ^/mo/sharing/(.+)\.cgi {
root /usr/syno/synoman; # <-- 關鍵的一行
rewrite /mo/sharing/(.+) /$1 break;
include scgi_params;
scgi_read_timeout 3600s;
scgi_pass synoscgi;
}
## 警語 ##
打 bounty 賺零用錢是不錯 如果想要當正職可能需要思考一下
尤其當公司方因為若干原因還不給你錢的時候 ...
[0]: https://owasp.org/www-project-top-ten/2017/A6_2017-Security_Misconfiguration
[1]: http://nginx.org/en/docs/http/ngx_http_core_module.html#internal
--
> 在待業的過程中 繼續找零用錢
因為之前有回報過 Synology 邀請我參加 7.0 beta 的測試 時間軸如下
2020-12-10 -> 收到邀請
2020-12-29 發送第二次回報 <-
2021-01-29 -> 終於確認受理範圍與獎金 (預計 2/29 發金)
同時宣告不能在 2021-03-29 前公布細節
2021-02-29 (沒收到 $$)
2021-03-03 還沒收到 $$ 寄信詢問 <-
2021-03-04 -> 表示會計問題 延遲發放
2021-03-15 寄信詢問發放時間 <-
2021-03-17 -> 宣稱 3/31 會發放獎金
2021-03-31 -> 表示發生意外、會額外寄送禮物表示歉意
2021-04-27 -> 已收到禮物
2021-05-03 -> 已收到獎金 <- 現在 (結案)
這次找到比較有趣的漏洞 是屬於 misconfiguration[0] 的類型
透過審慎 review 數千行 nginx 後 發現一個設定錯誤 在 nginx 設定檔中有很多重複出現下面的設定
location ~ ^/volume(?:X|USB|SATA|Gluster)?\d+/ {
internal;
root /;
open_file_cache off;
include conf.d/x-accel.*.conf;
}
在 nginx 官方文件描述[1] 設定 internal 的 location
只能被內部存取 (internal requests) 如果需要外部存取則需要透過
- error_page / index / random_index / try_files 做重導向
- 來自 upstream 且有 X-Accel-Redirect 這個額外 header 的重導向
- 透過 rewrite 的指定路徑
很明顯的 在這個 location 下可以存取的檔案都屬於高價值 (bounty 應該也比較高)
按照上面的可存取方式 最後發現幾個沒有正確的設定 像是
location ~ ^/oo/t/ {
rewrite /oo/t/([0-9a-zA-Z_.]+)$ /webman/3rdparty/Spreadsheet/index.html last;
rewrite /oo/t/(.*) /$1 last;
include scgi_params;
scgi_pass synoscgi;
}
透過 nginx 存取 /oo/t/ 開頭的路徑時 會做 redirect 判斷
- 符合 /oo/t/`數字、字母、底線、. 的組合` -> /webman/3rdparty/Spreadsheet/index.html
- 其他狀況 -> 其他狀況
表示如果存取 /oo/t/abcde 就會連到 /webman/3rdparty/Spreadsheet/index.html
但是連到 /oo/t/ab/cde 就會連到 /ab/cde
結合最開始的找到有趣的 inernal location 規則
就可以用 /oo/t/volumnX/Y/Z 存取 /volumnX/Y/Z 下的檔案了
## How to fix ##
其實解決方式也很簡單 Synology 的開發者其實也知道
就是在有機會做 redirect 的 location 下額外下 root 就可以 像是下面這個規則就不存在這個漏洞
location ~ ^/mo/sharing/(.+)\.cgi {
root /usr/syno/synoman; # <-- 關鍵的一行
rewrite /mo/sharing/(.+) /$1 break;
include scgi_params;
scgi_read_timeout 3600s;
scgi_pass synoscgi;
}
## 警語 ##
打 bounty 賺零用錢是不錯 如果想要當正職可能需要思考一下
尤其當公司方因為若干原因還不給你錢的時候 ...
[0]: https://owasp.org/www-project-top-ten/2017/A6_2017-Security_Misconfiguration
[1]: http://nginx.org/en/docs/http/ngx_http_core_module.html#internal
--
Tags:
資安
All Comments

By Gilbert
at 2021-04-05T01:32
at 2021-04-05T01:32

By Isla
at 2021-04-09T09:38
at 2021-04-09T09:38

By Gary
at 2021-04-13T17:44
at 2021-04-13T17:44

By Joseph
at 2021-04-18T01:50
at 2021-04-18T01:50

By Irma
at 2021-04-22T09:56
at 2021-04-22T09:56

By Elma
at 2021-04-26T18:02
at 2021-04-26T18:02

By Kumar
at 2021-05-01T02:09
at 2021-05-01T02:09

By Dorothy
at 2021-05-05T10:15
at 2021-05-05T10:15

By James
at 2021-05-09T18:21
at 2021-05-09T18:21
Related Posts
RHCE

By Hardy
at 2021-03-26T21:01
at 2021-03-26T21:01
canary tokens

By Megan
at 2021-03-10T13:38
at 2021-03-10T13:38
GnuPG Heap Buffer Overflow

By Rae
at 2021-02-01T12:31
at 2021-02-01T12:31
sudo CVE-2021-3156

By Delia
at 2021-01-27T21:16
at 2021-01-27T21:16
Bounty 初體驗

By Linda
at 2020-12-31T12:40
at 2020-12-31T12:40