SSブログ

WireGuardの検討(OpenBSD 7.2、2022/11/13) [OpenBSD]

VPSでOpenBSDを運用していますが、自宅ローカル環境とVPNのトンネルを作れればといいなと思っています。うちのCISCOルータと接続できるIPsecが良かったのですが、IPsecはパラメータが多くて面倒そうですね…。それに相性問題なども面倒そうですし。

理想はトンネルタイプで、中にルーティングプロトコルを通したいです。OpenVPNを考えたのですが、最近の主流はWireGuardという記事が出てきまして、WireGuardの使用を前提にインストールまでしてみました。
いろいろ設定を煮詰めているうちに、基幹接続部分でNATの使用を前提とするところがあるようで、ちょっとイメージが違うなぁ。

タグ:WireGuard
nice!(0)  コメント(0) 
共通テーマ:日記・雑感

OpenBSD 7.0Rリリース (OpenBSD 7.0R、2021/10/17) [OpenBSD]

OpenBSD 7.0Rがリリースされましたね。sysupgradeで一発です。
私の環境だと/etc/ssh/sshd_configの修正を聞かれましたが、カスタマイズ箇所は分かっているので設定ファイルを上書きした後に、個別に修正しておきました。

参考までにdmesgを挙げておきます。
OpenBSD 7.0 (GENERIC.MP) #232: Thu Sep 30 14:25:29 MDT 2021
    deraadt@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 1056817152 (1007MB)
avail mem = 1008816128 (962MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.8 @ 0xf6130 (10 entries)
bios0: vendor SeaBIOS version "1.11.0-2.el7" date 04/01/2014
bios0: Fedora Project OpenStack Nova
acpi0 at bios0: ACPI 1.0
acpi0: sleep states S5
acpi0: tables DSDT FACP APIC
acpi0: wakeup devices
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Xeon(R) CPU E5-2670 v3 @ 2.30GHz, 329.94 MHz, 06-3f-02
cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SS,SSE3,PCLMUL,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,UMIP,IBRS,IBPB,STIBP,SSBD,ARAT,XSAVEOPT,MELTDOWN
cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 16-way L2 cache
cpu0: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu0: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 999MHz
cpu1 at mainbus0: apid 1 (application processor)
cpu1: Intel(R) Xeon(R) CPU E5-2670 v3 @ 2.30GHz, 388.75 MHz, 06-3f-02
cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,SS,SSE3,PCLMUL,SSSE3,FMA3,CX16,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,HV,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,PERF,FSGSBASE,TSC_ADJUST,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,UMIP,IBRS,IBPB,STIBP,SSBD,ARAT,XSAVEOPT,MELTDOWN
cpu1: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 512KB 64b/line 16-way L2 cache
cpu1: ITLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu1: DTLB 255 4KB entries direct-mapped, 255 4MB entries direct-mapped
cpu1: smt 0, core 0, package 1
ioapic0 at mainbus0: apid 0 pa 0xfec00000, version 11, 24 pins
acpiprt0 at acpi0: bus 0 (PCI0)
"ACPI0006" at acpi0 not configured
acpipci0 at acpi0 PCI0
acpicmos0 at acpi0
"PNP0A06" at acpi0 not configured
"PNP0A06" at acpi0 not configured
"PNP0A06" at acpi0 not configured
"QEMU0002" at acpi0 not configured
"ACPI0010" at acpi0 not configured
acpicpu0 at acpi0: C1(@1 halt!)
acpicpu1 at acpi0: C1(@1 halt!)
cpu0: using Broadwell MDS workaround
pvbus0 at mainbus0: KVM
pvclock0 at pvbus0
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel 82441FX" rev 0x02
pcib0 at pci0 dev 1 function 0 "Intel 82371SB ISA" rev 0x00
pciide0 at pci0 dev 1 function 1 "Intel 82371SB IDE" rev 0x00: DMA, channel 0 wired to compatibility, channel 1 wired to compatibility
pciide0: channel 0 disabled (no drives)
atapiscsi0 at pciide0 channel 1 drive 1
scsibus1 at atapiscsi0: 2 targets
cd0 at scsibus1 targ 0 lun 0: <QEMU, QEMU DVD-ROM, 2.5+> removable
cd0(pciide0:1:1): using PIO mode 4, DMA mode 2
uhci0 at pci0 dev 1 function 2 "Intel 82371SB USB" rev 0x01: apic 0 int 11
piixpm0 at pci0 dev 1 function 3 "Intel 82371AB Power" rev 0x03: apic 0 int 9
iic0 at piixpm0
vga1 at pci0 dev 2 function 0 "Bochs VGA" rev 0x02
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
virtio0 at pci0 dev 3 function 0 "Qumranet Virtio Network" rev 0x00
vio0 at virtio0: address 00:00:00:00:00:00
virtio0: msix shared
virtio1 at pci0 dev 4 function 0 "Qumranet Virtio Console" rev 0x00
virtio1: no matching child driver; not configured
virtio2 at pci0 dev 5 function 0 "Qumranet Virtio Storage" rev 0x00
vioblk0 at virtio2
scsibus2 at vioblk0: 1 targets
sd0 at scsibus2 targ 0 lun 0: <VirtIO, Block Device, >
sd0: 102400MB, 512 bytes/sector, 209715200 sectors
virtio2: msix shared
virtio3 at pci0 dev 6 function 0 "Qumranet Virtio Memory Balloon" rev 0x00
viomb0 at virtio3
virtio3: apic 0 int 10
isa0 at pcib0
isadma0 at isa0
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
wsmouse0 at pms0 mux 0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
usb0 at uhci0: USB revision 1.0
uhub0 at usb0 configuration 1 interface 0 "Intel UHCI root hub" rev 1.00/1.00 addr 1
dt: 445 probes
uhidev0 at uhub0 port 1 configuration 1 interface 0 "QEMU QEMU USB Tablet" rev 2.00/0.00 addr 2
uhidev0: iclass 3/0
ums0 at uhidev0: 3 buttons, Z dir
wsmouse1 at ums0 mux 0
vscsi0 at root
scsibus3 at vscsi0: 256 targets
softraid0 at root
scsibus4 at softraid0: 256 targets
root on sd0a (b1b56fef9df9d441.a) swap on sd0b dump on sd0b
fd0 at fdc0 drive 1: density unknown



タグ:OpenBSD
nice!(0)  コメント(0) 
共通テーマ:日記・雑感

httpsサーバをセキュリティ評価してみた(2021/09/08) [OpenBSD]

Let's Encryptの証明書の自動更新の記事を探していると、面白い記事を見つけました。httpsサーバとして、sslの強度・脆弱性テストをするものです。
https://qiita.com/z80/items/62225e6468d823fc73c9

SSL Server Test
https://www.ssllabs.com/ssltest/

メールサーバの中継防止チェックはしっかりやっていますが、Webは個人ブログぐらいしか使っていないので、あまり気にしてなかったですねぇ。
で、試しにやってみたら…
20210906_ssl-test.png

評価Fで最悪な結果でした。

SSLv3やTLS 1.1はデフォルトで無効化されているようですが、TLS 1.2で受け付ける暗号化プロトコルがよくないらしいです。これに関しては有識者がlighttpd向けにガイドを作っているので、そちらを参考に修正します。
https://raymii.org/s/tutorials/Strong_SSL_Security_On_lighttpd.html

明示的な無効化を含めて、差分はこんな感じです。特に最後の行が重要です。
root@openbsd:~ # cat /etc/lighttpd.conf
ssl.use-sslv2 = "disable"
ssl.use-sslv3 = "disable"
ssl.use-compression = "disable"
ssl.cipher-list = "EECDH+AESGCM:EDH+AESGCM:AES128+EECDH:AES128+EDH"


これでAランク判定になりました。



タグ:lighttpd
nice!(0)  コメント(0) 
共通テーマ:日記・雑感

Let's Encryptの更新(2021/09/06) [OpenBSD]

Let's Encryptの証明書の更新タイミングがやってまいりました。

前回、standalone方式からwebroot方式に切り替えているので、Webサーバには手を入れずに更新ができずはずです。失敗があってはいけませんから、一度「certbot --dry-run renew」で試してから問題ないことを確認した上で実施します。
それで成功すれば、本番コマンドを投入します。
root@openbsd:~ # certbot renew
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/www.eimelle.net.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator webroot, Installer None
Renewing an existing certificate for www.eimelle.net
Performing the following challenges:
http-01 challenge for www.eimelle.net
Using the webroot path /var/www/htdocs for all unmatched domains.
Waiting for verification...
Cleaning up challenges

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/www.eimelle.net/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all renewals succeeded: 
  /etc/letsencrypt/live/www.eimelle.net/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

こんな感じでうまくいきました。
更新とプロセスの再起動を定期的にcronに行わせたいのですが、どうすればいいのでしょうね。証明書の有効期間は90daysですが、更新をしたタイミングでさらに90daysが延長されるので、80日目ぐらいで延長を続けるとどんどんずれていく感覚です。

つまり、80days → 160days → 240days → 320days → 1year + 35days
といった感じなり、cronの毎月xx日といった形式では指定できない訳です。このあたりは、おいおい考えることにしましょう。



タグ:Let's Encrypt
nice!(0)  コメント(0) 
共通テーマ:日記・雑感

OpenBSD環境でJS CMSを動かすときのメモ(2021/05/08) [OpenBSD]

ブログはJS CMSが軽量で使いやすいです。導入も楽ですし、何よりもWordPressのようにMySQLといった専用DBが必要ないことです。これによって少ないメモリでも動作させることができます。
https://www.js-cms.jp/

ひとつだけ、バックアップ機能がうまく動きません。エラーコード 500が意味不明です。ログにも何も残りません。

20210508_jscms_01.png


backup.phpで発生しているようなので、backup.phpの先頭に以下のコードを追加します。
ini_set("display_errors", 1);
error_reporting(E_ALL);


すると以下のようにエラーコードが200に変わりました。parsererrorとのことです。

20210508_jscms_02.png


エラーログにも明確なメッセージが残るようになりました。ZipArchiveがないとのことで、これだけ個別に導入する必要がありそうです。
PHP message: PHP Fatal error:  Uncaught Error: Class 'ZipArchive' not found in /htdocs/js-cms/_cms/backup.php:177


php-zip-7.3.28をpkg_addで導入し、php.iniに「extension=zip」を追加して対応完了です。FastCGI Process Manager(PFM)を動かしている場合は、サービスの再起動が必要です。


nice!(0)  コメント(0) 
共通テーマ:日記・雑感

OpenBSD環境でchroot環境を作るときのメモ(2021/05/08) [OpenBSD]

lighttpdエラー
2021-05-08 12:06:16: configfile.c.1380) opening /dev/null failed: No such file or directory
2021-05-08 12:06:16: server.c.1509) Opening errorlog failed. Going down.

chroot後に/dev/nullが見えないため。

root@openbsd:~ # ls -la /dev/null
crw-rw-rw-  1 root  wheel    2,   2 May  8 12:06 /dev/null

root@openbsd:/var/www # mkdir dev
root@openbsd:/var/www # cd dev
root@openbsd:/var/www/dev # mknod -m 666 null c 2 2
root@openbsd:/var/www/dev # ls -la
crw-rw-rw-  1 root  daemon    2,   2 May  8 12:24 null




タグ:メモ
nice!(0)  コメント(0) 
共通テーマ:日記・雑感

Let's Encryptの自動更新見直し (2021/03/24) [OpenBSD]

うちのドメインはLet's Encryptにサーバ証明書を発行してもらっていますが、当初勝手が分からずStandalone方式を設定してしまっています。この方式の場合、証明書の更新の度にWebサーバを終了させてなければなりません。ちょっとこれは面倒です。せっかくなのでWebroot方式に変更することにします。

一応、私のLet's Encrypt(ACME)に関する理解は以下の通りです。基本的に自分のサーバの身の証を立てる(インターネット上に存在していることを示す)ための方式が2つあり、それぞれ

Standalone方式:一時的なテンポラリサーバをTCP/80で待ち受け、外部(Let's Encrypt)からのアクセスによって身の証を立てる方法。そのためWebサーバが動作中だとListenポートが競合する。

Webroot方式:Webサーバが既に動作中あることを前提に、Webサーバ上のWebページを一時的に間借りする方法。(外部からアクセスできるWebページを一時生成して認証に使う)

なお、Let's Encryptにおける証明書の発行・更新は1時間に5回までに制限されていますので、失敗を前提に何度もリトライするのであれば「--dry-run 」オプションを付けておきましょう。

私は以下のページなどを参考にさせて頂きました。
https://qiita.com/tmatsumot/items/aca49d99558d2646ef36

/etc/letsencrypt/配下を一旦綺麗に掃除し、以下のコマンドで一発でした。
openbsd# certbot certonly --agree-tos --webroot -w /var/www/htdocs/ -d xxx.xxxxx.xxx -m xxxxx@xxxxxx.xxx
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

-dで自分のFQDN(https://xxxxxxx/の、xxxxxxxとなる部分)を指定し、-mでメールアドレスを指定します。

約3ヶ月後、Webroot方式での更新もチャレンジしてみます。



タグ:Let's Encrypt
nice!(0)  コメント(0) 
共通テーマ:日記・雑感

OpenSMTPD脆弱性(OpenBSD 6.6R、2020/2/26) [OpenBSD]

OpenSMTPDで脆弱性が報告されているので使用中の方は至急パッチ当てをしましょう。移植されているFreeBSD版でも当てはまるのかな。こういうときに、本家を使うと迅速な対応ができて良いですね。
https://www.openbsd.org/errata66.html
021: SECURITY FIX: February 24, 2020 All architectures
An out of bounds read in smtpd allows an attacker to inject arbitrary commands into the envelope file which are then executed as root. Separately, missing privilege revocation in smtpctl allows arbitrary commands to be run with the _smtpq group.
A source code patch exists which remedies this problem.

smtpdの領域外メモリー参照(バッファオーバーフロー?)により、攻撃者は、root権限でメール内に記載した任意(arbitrary)のコマンドが実行できてしまう。
さらに、smtpdctlの権限剥奪処理の欠如(権限チェック機構が未実装だったこと?)により、任意のコマンドが_smtpdグループ権限で実行できてしまう。

syspatchコマンドでパッチを当てられると思います。

タグ:OpenSMTPD
nice!(0)  コメント(0) 
共通テーマ:日記・雑感

Certbot説明(OpenBSD 6.6R、2020/2/26) [OpenBSD]

This directory contains your keys and certificates.

`privkey.pem`  : the private key for your certificate.
`fullchain.pem`: the certificate file used in most server software.
`chain.pem`    : used for OCSP stapling in Nginx >=1.3.7.
`cert.pem`     : will break many server configurations, and should not be used
                 without reading further documentation (see link below).

WARNING: DO NOT MOVE OR RENAME THESE FILES!
         Certbot expects these files to remain in this location in order
         to function properly!

We recommend not moving these files. For more information, see the Certbot
User Guide at https://certbot.eff.org/docs/using.html#where-are-my-certificates.


タグ:Let's Encrypt
nice!(0)  コメント(0) 
共通テーマ:日記・雑感

lighttpdとLet's Encryptの組み合わせ(OpenBSD 6.6R、2020/2/2) [OpenBSD]

別のWebサーバを運営しているのですが、最近はhttps接続でないWebサーバは警告が出るようになるなど、面倒な世の中になったものですね。その流れでうちのWebサーバもhttps化する必要が出てきたのですが、さすがに商用のサーバ証明書(高い)を取得できる訳もなく、困ったことになりました。

まあ、世の中にはそういった人達のための救済手段があり、有名なものとしてLet’s Encryptが挙げられます。私もLet’s Encryptを利用してみることにします。非営利の団体なので、趣旨に賛同できるようであれば寄付をお願い致します。https://letsencrypt.org/ja/
一つだけ注意点を挙げるとすると、Let’s Encryptはドメインの有効性・存在性を保証するものであって、Webサーバで提供されるコンテンツの安全性を保証するものではないとうことです。

・・・実はLet’s Encryptは2019年11月頃にOpenBSD上にお試しで導入しておりまして、導入過程などの情報がさっぱり抜け落ちてしまっています。少なくとも以下のソフトウェアが導入されており、これらを使ってどうにかしたはずなのですが。
openbsd# pkg_info
acme-client-0.1.16  privilege-separated letsencrypt client
certbot-0.38.0      client for certificate authorities using ACME protocols
実は今回、90日の期限が切れるのでその更新処理を行った訳です。.confの設定ファイルは当時作っていたので、何も考えずにcertbot renewと入力したら証明書は更新されました。

ただ、lighttpdへの反映が面倒で、秘密鍵とサーバ証明書が別で提供される場合は、事前にマージさせておく必要があります。Let’s Encryptで提供される証明書は、つまりはそういう形態になっているということです。
ssl.pemfile = "/etc/letsencrypt/live/mydomain/merged-cert.pem"
ssl.ca-file = "/etc/letsencrypt/live/mydomain/fullchain.pem"
cronでの自動化を考えていますが、このマージ処理は面倒ですね。これがapacheだと、秘密鍵、サーバ証明を個別に指定することができるようです。

改めてlighttpdのマニュアルを見ていると、ssl.privkey:path to the PEM file private key (required if private key is not in ssl.pemfile) (since 1.4.53)となっており、割と最近にapacheと同様の設定が追加されたようです。以下のように設定してみたところ、問題なく動いているようです。便利になりましたね。
ssl.pemfile = "/etc/letsencrypt/live/mydomain/cert.pem"
ssl.privkey = "/etc/letsencrypt/live/mydomain/privkey.pem"
ssl.ca-file = "/etc/letsencrypt/live/mydomain/fullchain.pem"


nice!(0)  コメント(0) 
共通テーマ:日記・雑感