製品・ソフトウェアに関する情報
goshsにおけるパストラバーサルの脆弱性
Title goshsにおけるパストラバーサルの脆弱性
Summary

goshsはGoで書かれたSimpleHTTPServerです。2.0.0-beta.6より前のバージョンには、プレフィックスベースのパス検証によって引き起こされるSFTPルートエスケープの脆弱性があります。認証済みのSFTPユーザーは、構成されたSFTPルート外のファイルシステムパスに対して読み取りおよび書き込みが可能であり、意図されたジャイル境界を破壊し、無関係なサーバーファイルを露出させたり改ざんしたりする可能性があります。SFTPサブシステムはリクエストをsftpserver/sftpserver.go経由でsftpserver/handler.goのDefaultHandler.GetHandler()にルーティングし、そこからファイル操作をreadFile、writeFile、listFile、cmdFileに転送します。これらの関数はすべてsftpserver/helper.goのsanitizePath()に依存しています。helper.goは生の文字列プレフィックス比較を使用しており、ディレクトリ境界のチェックを行っていません。そのため、設定されたルートが/tmp/goshsrootの場合、/tmp/goshsroot_evil/secret.txtのような同階層のパスが同じバイトプレフィックスで始まるために誤って検証を通過してしまいます。この脆弱性は2.0.0-beta.6で修正されました。

Possible impacts 当該ソフトウェアが扱う全ての情報が外部に漏れる可能性があります。 また、当該ソフトウェアが扱う全ての情報が書き換えられる可能性があります。 さらに、当該ソフトウェアが完全に停止する可能性があります。 そして、この脆弱性を悪用した攻撃の影響は、他のソフトウェアには及びません。 
Solution

正式な対策が公開されています。ベンダ情報を参照して適切な対策を実施してください。

Publication Date April 21, 2026, midnight
Registration Date April 27, 2026, 10:47 a.m.
Last Update April 27, 2026, 10:47 a.m.
CVSS3.0 : 重要
Score 8.8
Vector CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Affected System
goshs
goshs 2.0.0
goshs 2.0.0 未満
CVE (情報セキュリティ 共通脆弱性識別子)
CWE (共通脆弱性タイプ一覧)
ベンダー情報
Change Log
No Changed Details Date of change
1 [2026年04月27日]
  掲載
April 27, 2026, 10:47 a.m.

NVD Vulnerability Information
CVE-2026-40876
Summary

goshs is a SimpleHTTPServer written in Go. Prior to 2.0.0-beta.6, goshs contains an SFTP root escape caused by prefix-based path validation. An authenticated SFTP user can read from and write to filesystem paths outside the configured SFTP root, which breaks the intended jail boundary and can expose or modify unrelated server files. The SFTP subsystem routes requests through sftpserver/sftpserver.go into DefaultHandler.GetHandler() in sftpserver/handler.go, which forwards file operations into readFile, writeFile, listFile, and cmdFile. All of those sinks rely on sanitizePath() in sftpserver/helper.go. helper.go uses a raw string-prefix comparison, not a directory-boundary check. Because of that, if the configured root is /tmp/goshsroot, then a sibling path such as /tmp/goshsroot_evil/secret.txt incorrectly passes validation since it starts with the same byte prefix. This vulnerability is fixed in 2.0.0-beta.6.

Publication Date April 22, 2026, 5:17 a.m.
Registration Date April 25, 2026, 4:03 a.m.
Last Update April 25, 2026, 5:38 a.m.
Affected software configurations
Configuration1 or higher or less more than less than
cpe:2.3:a:goshs:goshs:*:*:*:*:*:go:*:* 2.0.0
cpe:2.3:a:goshs:goshs:2.0.0:beta1:*:*:*:go:*:*
cpe:2.3:a:goshs:goshs:2.0.0:beta2:*:*:*:go:*:*
cpe:2.3:a:goshs:goshs:2.0.0:beta3:*:*:*:go:*:*
cpe:2.3:a:goshs:goshs:2.0.0:beta4:*:*:*:go:*:*
cpe:2.3:a:goshs:goshs:2.0.0:beta5:*:*:*:go:*:*
Related information, measures and tools
Common Vulnerabilities List