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版

第34章. クライアント側からの攻撃に対する防御

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

第16章では、 、クライアントサイド攻撃の3つの形態(プロトタイプ汚染、クリックジャッキング、タブナッビング)を幅広く取り上げた。これらの攻撃では、エンドユーザを攻撃するためにサーバを経由するのではなく、クライアントブラウザを経由してユーザを攻撃することができた。ブラウザ・クライアントが年々高度化するにつれ、クライアントサイド攻撃は増加傾向にある。

クライアントサイド攻撃を検知しようとすると限界があるため、攻撃者がクライアントサイド攻撃 を成功させるのが難しいように、アプリケーションをセットアップする方法を理解することが不可欠である。この章では、あなたのウェブ・アプリケーションがクライアントサイド攻撃の標的にされたときに、可能な限りセキュリ ティを確保できるようにするためのテクニックを説明します。

プロトタイプ汚染からの防衛

プロトタイプ汚染 攻撃は機能するためにJavaScriptのプロトタイプ継承システムに依存している(詳細な攻撃とペイロード開発については第16章を参照)。JavaScriptインタプリタは関数やデータを探してプロトタイプの連鎖を上がっていくので、攻撃者が直接アクセスすることなく(継承階層の関連オブジェクトを汚染することで)1つのオブジェクトを汚染することは非常に可能である。

プロトタイプ汚染攻撃は、その大部分がJavaScript固有の言語機能に依存しているため、最初は発見も緩和も難しいが、いったんコツをつかめば、緩和策はかなり理解しやすくなる。プロトタイプ汚染攻撃を阻止するための最も効果的な緩和策をいくつか見てみよう。

キーの消毒

プロトタイプ汚染攻撃を防ぐ最も簡単な方法の1つは、アプリケーションのJavaScriptコードが、ユーザから提供されたすべてのキーを、そのキーを持つJavaScriptオブジェクトをマージしたり操作したりする前に、確実にサニタイズすることである。

次のコード・スニペットを考えてみよう。このJavaScriptコードのスニペットは、悪意のあるユーザの入力の代わりにアプリケーションで生成される入力を表している:

// submitted via address collection form
const obj = {
  "__proto__": { "role": "admin" }
}

この場合、キーとなる__proto__ は、他のオブジェクトにマージされたときにプロトタイプ・チェーンを利用するオブジェクトの部分である。

利用可能なキーの許可リストを提供すれば、ユーザの入力を簡単に反復処理し、単純なサニタイズによって攻撃を防ぐことができる:

const allowedKeys = ["street", "city", "state", "firstName", "lastName"];

const isKeyValid = function(key) {
  if (!allowedKeys.includes(key) {
    return false;
  } else {
    return true;
  }
};

const updateUserData(data) {
 let isValid = true;

 for (const [key, value] of Object.entries(data)) {
  if (!
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