インシデント事後分析(ポストモーテム) —— 開発・運用チームのための根本原因分析と再発防止策。
flawopen.com/インシデント/PostgreSQL CVE-2025-1094
CVE-2025-1094:インジェクションを防ぐはずのエスケープ処理自体が脆弱性だった理由
わかりやすく解説 (ELI5)
発言が命令と誤解されないよう、すべてを鍵括弧で囲む通訳がいます。未知の文字を渡すと通訳が混乱し、末尾の括弧を閉じ忘れてしまいます。結果として括弧の外へ飛び出した単語が、そのまま管理者への実行命令として解釈されてしまいました。
The lessons that actually transfer
- ✓Parameterised queries are structurally safer than escaping, not just stylistically. A bound parameter travels to the server separately from the query text, so there is no quoting step that can be tricked. Escaping is a correctness problem someone has to solve perfectly, every time, for every encoding; parameterisation removes the problem.
- ✓Do not use an interactive CLI as a programmatic database driver. psql is a human tool with human conveniences like meta-commands. Piping application data through it imports those conveniences as an attack surface. Use the language's real client library.
- ✓Encoding validation belongs at the boundary. Reject input that is not well-formed in its declared encoding before it reaches any parser or escaper. A great many quoting and canonicalisation bugs begin with a byte sequence that should never have been accepted in the first place.
- ✓Patch your client libraries, not just the server. This was a flaw in libpq and psql — the client side. Teams that only tracked their PostgreSQL server version would have missed it.
- ✓Treat privileged-access vendors as part of your attack surface. Remote support and PAM tooling holds the keys by design. Its compromise is a direct route into every environment it serves.
FAQ
Does this mean escaping functions can't be trusted?
It means they are ordinary software with ordinary bugs, and that relying on them puts a correctness burden in a place where a single mistake is exploitable. Parameterised queries avoid the burden entirely, which is why they remain the primary recommendation.
Was my application vulnerable if I use an ORM?
Most ORMs and modern drivers use the extended query protocol with bound parameters rather than libpq's escaping helpers, which sidesteps the flaw. The exposure was concentrated in code that explicitly called the escape functions or shelled out to psql. Patching the client library is still the correct action.
Which versions fixed it?
PostgreSQL 17.3, 16.7, 15.11, 14.16 and 13.19, released on 13 February 2025.
Related reading
情報源および公式アドバイザリ