rsyncdはデフォルトで共有モジュール名を公開している?

【PR】
※IT系の記事は当方環境での実施内容となるため実施する場合は自己責任でお願いいたします。

rsyncdはデフォルトで共有モジュール名を公開している?

rsyncdの共有モジュール名は実はリストで外部から取得されちゃうんじゃないかと疑っています。
↓ログ モジュール名がバレちゃってる?

May  3 15:13:19 xxxxxx rsyncd[xxxxx]: module-list request from 32.248.140.34.bc.googleusercontent.com (34.140.248.32)
May  3 15:13:25 xxxxxx rsyncd[xxxxx]: connect from 32.248.140.34.bc.googleusercontent.com (34.140.248.32)
May  3 15:13:25 xxxxxx rsyncd[xxxxx]: rsync denied on module モジュール名 from 32.248.140.34.bc.googleusercontent.com

アクセスIP制限やユーザ/PASS設定を適切にしていれば、ファイルそのものは取得されないとは思いますが。。。
今回の不正アクセスIPの調査結果はこちら。とても危険な香り。
https://ip-sc.net/ja/r/34.140.248.32

こちらの記事を見つけた。やっぱりそうか。モジュールの公開/非公開を設定するlistパラメータのデフォルトは「公開」

https://www.upguard.com/blog/secure-rsync
上記より抜粋

List
The list option allows rsync to “hide” a module from anyone who doesn’t know what they’re looking for. When the rsync daemon is queried for available modules, those set to list = false will be omitted from the results. While this kind of security through obscurity is not enough on it’s own, it is one additional layer you can add to protect particularly sensitive file paths. By default, modules are listable, so this parameter must be explicitly set to false for hidden modules.

List = true
The module is visible when the rsync daemon is queried for available paths.

List = false
The module is not visible in the daemon’s list and must be accessed directly.

Default: True. The module will be visible.

具体的なやり方は調べられていないのですが、rsyncdのポートが開いていれば攻撃者はどんな名前でモジュールが共有公開されているかを取得できてしまうのでは。

listをモジュールごとに無効にする

listの公開/非公開方法はこちらのサイトを見るとモジュールの中でyes/no or true/false で書けるみたいです。
https://access.redhat.com/obsolete-documentation/ja/red-hat-openstack-platform/9/paged/manual-installation-procedures/42-configure-rsyncd

上記サイトより抜粋 list = yes の部分。

[account]
max connections = 2
path = /srv/node/
read only = false
write only = no
list = yes
incoming chmod = 0644
outgoing chmod = 0644
lock file = /var/lock/account.lock

設定したところ、ログで

2022/05/04 23:06:29 [8607] connect from scan-17.shadowserver.org (65.49.20.66)
2022/05/04 23:06:37 [8608] connect from scan-17.shadowserver.org (65.49.20.66)
2022/05/04 23:06:37 [8608] module-list request from scan-17.shadowserver.org (65.49.20.66)

の後に、

rsync denied on module モジュール名 from ・・・

が出なくなったように見えるので、一応成功しているのではと思っています。

でも、rsyncdやるなら
・通信ホストを制限する
allowが先に評価され、それ以外は拒否

hosts allow   = ドメイン名 IPアドレス/24
hosts deny    = *

・ユーザー/PASS制御
・LISTをOFF
はやっておいた方がいいかも。
それか、そもそもrsyncdじゃなくて
sshを鍵でアクセスできるようにしておいて、必要な時だけCronでrsyncを実行するとか。

以上。

Tips

Posted by admin