postfixの mail.log を見ると、ソースが10.0.2.100 で rootless コンテナ安心だけど、crowdsecと連動したい場合は接続元IPを補足したいので、root化しようとしたが、なぜか立ち上がらず嵌る。
podmanは root が利用するイメージとユーザ用は違うのを忘れていた、それとnft化により、podmanのネットワーク(bridge)が壊れているらしく、root用のイメージビルドには「sudo podman build –network=host -t localhost/mypostfix .」と –network=host する必要があるとのこと(本来は podmanの設定を直したいところだけど
~
」コンテナに変更します。WPのエディタに慣れてきました。
作業日報
- postfix コンテナの root動作化
- mypostfox.container の調整・テスト(かなり苦労)
- croudsec 側の調整
- Jenkins側へのメンテナンススクリプト追加
日常
- 夜実家へ戻る
🤖AIに相談したこと
❓Dockerの基本イメージと実際の設置イメージ、カスタムイメージとの差異はどのような形で吸収するのがいいですか?
🤖ブランチでの管理はおすすめしません。「runtaime inject」(環境差分)方式がおすすめです。
➡prod.envでカスタムできるようにしておく
❓サーバーのログ解析依頼。Jenkisマシンの様子がおかしかった(おかしなプロセス名が多数、Loadが300)ので攻撃・侵入かとおもいの疑い伺う
🤖➡ログの提出 → かなり怪しい
Jenkinsu解析依頼
失礼しました、Jenkinsで以下のプロセスが延々と作業をしていたのでいったん止めました
www-data 521080 0.0 2.8 375460 58128 ? S Apr19 0:09 apache2 -DFOREGROUND
root 570067 0.0 0.4 1235348 8916 ? Sl Apr20 0:11 /usr/bin/containerd-shim-runc-v2 -namespace moby -id e7e13ee2ed9b18c594e947c3dc3a78f5d1ac02975b95e38e775ae215856c8d29 -address /run/containerd/con
tainerd.sock
ubuntu 570091 0.0 0.0 2572 100 ? Ss Apr20 0:05 /usr/bin/tini — /usr/local/bin/jenkins.sh
root 570134 0.0 0.0 1746852 1764 ? Sl Apr20 0:00 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8081 -container-ip 172.20.0.2 -container-port 8080 -use-listen-fd
root 570148 0.0 0.0 1673120 1764 ? Sl Apr20 0:00 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 50000 -container-ip 172.20.0.2 -container-port 50000 -use-listen-fd
ubuntu 570161 0.3 28.7 3146960 577508 ? Sl Apr20 7:48 java -Duser.home=/var/jenkins_home -Djenkins.model.Jenkins.slaveAgentPort=50000 -Dhudson.lifecycle=hudson.lifecycle.ExitLifecycle -jar /usr/share/
jenkins/jenkins.war
ubuntu 572215 0.0 0.0 204 48 ? Ss Apr20 0:08 bassbhssb
ubuntu 572216 0.0 0.0 0 0 ? Z Apr20 0:00 [babbhhhasbaah] <defunct>
ubuntu 572218 0.0 0.0 0 0 ? Z Apr20 0:00 [babbhhhasbaah] <defunct>
ubuntu 572228 0.0 0.0 0 0 ? Z Apr20 0:39 [babbhhhasbaah] <defunct>
ubuntu 572967 0.0 0.0 0 0 ? Z Apr20 0:39 [babbhhhasbaah] <defunct>
ubuntu 573085 0.0 0.0 0 0 ? Z Apr20 0:35 [babbhhhasbaah] <defunct>
ubuntu 573094 0.0 0.0 0 0 ? Z Apr20 0:35 [babbhhhasbaah] <defunct>
ubuntu 573107 0.0 0.0 0 0 ? Z Apr20 0:40 [babbhhhasbaah] <defunct>
ubuntu 573122 0.0 0.0 0 0 ? Z Apr20 0:39 [babbhhhasbaah] <defunct>
ubuntu 573136 0.0 0.0 0 0 ? Z Apr20 0:40 [babbhhhasbaah] <defunct>
ubuntu 573151 0.0 0.0 0 0 ? Z Apr20 0:40 [babbhhhasbaah] <defunct>
ubuntu 573293 0.0 0.0 0 0 ? Z Apr20 0:39 [babbhhhasbaah] <defunct>
ubuntu 573302 0.0 0.0 0 0 ? Z Apr20 0:39 [babbhhhasbaah] <defunct>
ubuntu 573318 0.0 0.0 0 0 ? Z Apr20 0:39 [babbhhhasbaah] <defunct>
ubuntu 573396 0.0 0.0 0 0 ? Z Apr20 0:40 [babbhhhasbaah] <defunct>
ubuntu 573530 0.0 0.0 0 0 ? Z Apr20 0:40 [babbhhhasbaah] <defunct>
結論
これは Jenkins コンテナ内で不審なプロセスが生成されていた可能性が高いです。
理由:
通常 Jenkins コンテナで出るプロセスは
tini
jenkins.sh
java (jenkins.war)
sh
git
bash
java agent
などです。
しかし今回の
bassbhssb
babbhhhasbaah
これは 意味不明なランダム文字列風プロセス名 です。
かなり典型的に:
- マルウェア
- crypto miner
- ボット
- wget/curlで落とされた一時実行ファイル
- メモリ上で名前偽装されたプロセス
で見られる挙動です。
まとめ:Incident Response Checklist for Jenkins
- 停止する前にコンテナログ、公開穴調査
docker log ,podman logs
docker ps systemctl status jenkins ss -tulpn - jobsファイルリスト精査・保存
/var/jenkins_home/jobs
find /var/jenkins_home -type f | grep -Ei “sh|groovy|py|pl” - ホスト側確認(できればコンテナ側も)
ps auxf
crontab & sudo crontab
ls /tmp & ls /var/tmp - Jenkins jobに shell 実行あるか確認
docker run -v image_jenkins_jenkins_home:/dst -it alpine grep -R “<command>” /dst/jobs | head -100
jenkins_home/jobs に “sh ‘” “bash” “mktmp” “/tmp/” を含むコマンドが含まれていないか確認
や
docker run -v image_jenkins_jenkins_home:/dst -it alpine \
grep -R “bassbhssb\|babbhhhasbaah\|mktemp\|chmod +x” /dst/jobs - 外部ログイン痕跡確認(以下の位置)
/var/jenkins_home/secrets/
/var/jenkins_home/users/
/var/jenkins_home/config.xml - trigger 確認
docker run –rm -v image_jenkins_jenkins_home:/dst alpine sh -c “grep -Rni ‘<spec>’ /dst/jobs”
環境の差し替え刷新も含めて鍵の再発行等も合理化しておきたいな