1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CSRF対策とは何?

Posted at

Webアプリケーションを作成するにあたって、「CSRF対策」という言葉を聞いたことはありませんか?
そこで、今回は「CSRF対策」について記載します。

CSRF対策とは?

「CSRF」とは、リクエストを強要させることを指します。
つまり、別のサイトにコンテンツ上したはずのリンクが実は罠で、これを踏ませてWebアプリケーションの重要な処理(例えば、ネットショッピングの最終決済など)を呼び出すように誘導することを表すのです。
よって、このような悪徳攻撃に対策をとるのが、「CSRF対策」です。

この攻撃の対象となるのは、フォームがサーバーから供給されたものだと確認していないWebアプリケーションです。
そのため、罠であるリンクを埋め込まれないようにする対策が必要なのです。

CSRFの対策方法とは?

では、その対策とは一体何でしょうか?

使うキーワードは、openssl_random_pseudo_bytesbin2hexです。

openssl_random_pseudo_bytes

これは、疑似乱数のバイト文字列(いわゆる普通の文字列)を生成する働きがあります。
詳しくはコチラ

bin2hex

これは、バイナリ(2進数)のデータを16進表現に変換する働きがあります。
詳しくはコチラ

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?