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版

第22章. セキュアなアプリケーション構成

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

セキュアなウェブアプリケーションを顧客にうまく提供するための一つの 要素は、提供するウェブアプリケーションが、ビルトインのブラウザセキュリティメカニズムを利用するように設定されていることを確認することである。

今日のウェブ・アプリケーションは、多数の言語、フレームワーク、および技術に基づいて構築されている。しかし、ウェブ・アプリケーションを提供する唯一の方法は、依然としてブラウザであるため、ブラウザに内蔵されたセキュリティ・メカニズムを利用する方法を学ぶことは、優れたセキュリティ態勢を確立するために不可欠である。

この章では、ウェブブラウザが実装しているいくつかのセキュリティ技術を評価し、議論する。また、ウェブアプリケーションのセキュリティを最大化するために、それらを正しく設定する方法についても学ぶ。

コンテンツ・セキュリティ・ポリシー

コンテンツ・セキュリティ・ポリシー(CSP) は、ブラウザ・クライアントを巻き込む最も一般的な形態のサイバー攻撃から保護するための、ブラウザの主要なセキュリティ・メカニズムの1つである。正しく実装されていれば、XSS、データインジェクション、フィッシング、フレーム、リダイレクト攻撃を防ぐことができる。

インターネットを破壊することなくクリーンな開発者体験を提供するために、CSPはかなりの量の設定オプションを実装するように設計された。このため、強いCSPポリシーと弱いCSPポリシーは大きく異なる。実際、CSPポリシーを一切使用せずに完全に機能するWebサイトを実行することは可能であり、ブラウザは一般的な攻撃に対する緩和策を実装しないことになる。

実装の観点から CSP ポリシーを深く見てみよう。ブラウザがユーザに代わってセキュリティ機構を実装できるようにするために、Web アプリケーションで CSP ポリシーを適切に構成する方法を学ぶことができる。

CSPの実装

CSPは、2つのメソッドのいずれかを介してウェブ・アプリケーションに実装することができる。最も一般的なメソッドは、サーバがリクエストごとにContent-Security-Policy ヘッダを返すようにすることである。X-Content-Security-PolicyX-Webkit-CSP ヘッダは非推奨であり、CSP ポリシーを実装するためにもはや使用すべきではないことに注意すること。

あるいは、各HTMLページの<HEAD></HEAD>meta タグを記述することで、CSPポリシーを実装することもできる。このようなメタ・タグは以下のようになる:

<meta
  http-equiv="Content-Security-Policy"
  content="default-src 'self'; img-src data:" />

CSPの構造

どの実装を選択しても、CSP ポリシーの構成メソッドはほぼ同じである。CSP ポリシーは、セミコロン (;) で区切られた ディレクティブで構成される。各ディレクティブの後に、そのディレクティブに対応する設定オプションを含めることができ、ブラウザによって実装される。

ディレクティブの例はscript-src scripts.mega-bank.com で、これはWebサイトが指定されたオリジンscripts.mega-bank.com ...

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