楼主: 
CMJ0121 (请多指教!!)   
2021-03-31 17:26:32※ 引述《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;    # <