Skip to Content
ウェブアプリケーションセキュリティ 第2版
book

ウェブアプリケーションセキュリティ 第2版

by Andrew Hoffman
March 2025
Intermediate to advanced
444 pages
6h 9m
Japanese
O'Reilly Media, Inc.
Audio summary available
Content preview from ウェブアプリケーションセキュリティ 第2版

第30章 XXEから身を守る

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

一般的に言って、XXE を防御するのは実に簡単である。XMLパーサで外部エンティティを無効にするだけでよい(図30-1参照)。どのように行うかはXMLパーサに依存するが、通常は1行の設定で済む:

factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);

OWASPは、多くのXXEがデフォルトで有効になっているため、JavaベースのXMLパーサーに対してXXEは特に危険であると指摘している。依存している言語とパーサによっては、XXE がデフォルトで無効になっている可能性がある。必ずXMLパーサーのAPIドキュメントをチェックして確認すること。XXEがデフォルトで無効になっていると思わないこと。

xxe
図 30-1. XXE攻撃は、XMLパーサーを適切に設定することで簡単にブロックできる。

他のデータ形式を評価する

アプリケーションのユースケースによっては、XMLではなく別のデータ形式に依存するようにアーキテクトを変更することが可能かもしれない。このような変更は、コードベースを簡素化すると同時に、XXEリスクを排除することができる。通常、XMLはJSONと 、他の形式を見るときはJSONをデフォルトにすることができる。

一方、JSONは、アプリケーションが実際のXML、SVG、その他のXML由来のファイルタイプをパースする場合には実用的ではない。しかし、アプリケーションがたまたまXMLの形をした標準的な階層のペイロードを送信する場合には、実用的なソリューションとなるだろう。

一般的に言って、JSONとXMLは、表30-1が示すように、あたかも直接の競争相手であるかのように並べて比較することができる。

表30-1. XMLとJSONの比較。
カテゴリー XML JSON

ペイロードサイズ

大型

コンパクト

仕様の複雑さ

高い

低い

使いやすさ

複雑な解析が必要

JavaScript互換性のためのシンプルな構文解析

メタデータのサポート

はい

いいえ

レンダリング(HTMLのような構造化を介して)

簡単だ

難しい

混合コンテンツ

サポート

未対応

スキーマ検証

サポート

未対応

オブジェクトマッピング

なし

JavaScript

読みやすさ

低い

高い

コメントサポート

はい

いいえ

セキュリティ

より低い

より高い

この2つの形式の比較には膨大な時間がかかるだろうが、表30-1を見ればすぐにいくつかのことが把握できるはずだ:

  • JSONはXMLよりもはるかに軽量な形式だ。

  • JSONは剛性に劣るが、より高速で作業しやすいペイロードをもたらす。

  • JSONはJavaScriptのオブジェクトにマッピングされるが、XMLはDOMツリーに近い(DOMはXML由来の形式だから)。

このことから、JavaScriptで解釈される軽量な構造化データを扱うAPIでは、JSONが許容できる選択肢である一方、ペイロードが最終的にレンダリングされるようなケースでは、XMLが依然として理想的であると結論づけることができる。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

ハイパーモダンPython ―信頼性の高いワークフローを構築するモダンテクニック

ハイパーモダンPython ―信頼性の高いワークフローを構築するモダンテクニック

Claudio Jolowicz, 嶋田 健志, 鈴木 駿
Kubernetesで実践するクラウドネイティブDevOps

Kubernetesで実践するクラウドネイティブDevOps

John Arundel, Justin Domingus, 須田 一輝, 渡邉 了介
流暢なReact

流暢なReact

Tejas Kumar

Publisher Resources

ISBN: 9798341627505