ml based detection of users anomaly activities (20th owasp night tokyo, japanese)

15
ML based detection of users anomaly activities マママママママママママママママママママママ Yury Leonychev ESG, Rakuten inc. OWASP Night 9/3/2016

Upload: yury-leonychev

Post on 09-Jan-2017

763 views

Category:

Data & Analytics


0 download

TRANSCRIPT

Page 1: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

ML based detection of users anomaly activitiesマシンラーニングによるユーザの不正行為検知Yury LeonychevESG, Rakuten inc.OWASP Night 9/3/2016

Page 2: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

2

アジェンダ• ケーススタディ• ワークショップ

使うもの リソースIDE Continuum Analytics Anaconda

https://www.continuum.io/downloads

Python3+NumPy+SciPy+ScikitLearn

https://www.python.org/downloads/http://www.scipy.org/install.html

Model Application https://github.com/tracer0tong/buzzboard/

Page 3: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

3

問題定義

1. ブラウザでの動きa. ユーザによる操作b. ウェブアプリによる動き2. HTTP リクエストの動きa. 正常なユーザエージェントb. スクリプトやボット3. バックエンドとのデータ交換

Page 4: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

4

CRISP-DM方法論(Cross Industry Standard Process for Data Mining)

https://en.wikipedia.org/wiki/Cross_Industry_Standard_Process_for_Data_Mining

Page 5: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

5

モデルの説明1. ビジネスの理解 – 正規ユーザとスパマーを区別したい。 正規ユーザは CAPTCHA に入力可能ですが、自動化ツールを使ってるスパマーはできない。2. データの理解 – HTTP リクエストと CAPTCHA の結果を確認。3. データの準備 – リクエストを収集し、完全であるのを確認。ユーザからのデータを集め、データベースに入れる。4. モデリング – 決定木の設定を定義し、チューニング。5. 錯誤を計算し、モデルを検証。6. モデルを本番環境に展開。

Page 6: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

6

特徴抽出直接特徴 非直接特徴

HTTP リクエストのサイズ IP アドレスの評価URI アドレスの長さ ユーザの評価ユーザエージェント 履歴関連の特徴HTTP ヘッダの数 時系列的な特徴レスポンス時間・コード ビジネスロジック関連の特徴… …

Page 7: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

7

アプリケーション・ワークフロー

ユーザリクエスト 特徴を集め

メッセージ保存

CAPTCHA のリダイレクト・確認

メッセージ表示CAPTCHA の結果と特徴の保存

Page 8: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

8

アプリケーション・ワークフロー (学習モード )

ユーザリクエスト 特徴を集め

メッセージ保存

CAPTCHA のリダイレクト・確認

メッセージ表示CAPTCHA の結果と特徴の保存 決定木の再学習分類エラーを計算

Page 9: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

9

アプリケーション・ワークフロー (本番モード )

ユーザリクエスト 特徴を集め リクエスト分類

正規か攻撃か

メッセージ保存 メッセージ表示

接続終了

400 を返す

Page 10: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

10

分解

クライアントデータ アプリケーションロジック データベースクエリ

フロントエンドファイアーウォールロードバランサ バックエンド データベース

Page 11: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

11

オフライン計算• オフライン: Hadoop, Spark (MLlib), Elasticsearch• リアルタイム: Spark (Streams and MLlib), Kafka, STORM• AWS や Azure との同じ技術

Page 12: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

12

連続的な実験データ 特徴

特徴セット 実験分類器

本番分類器

理想な分類器 フィードバック

新モデル

品質評価学習セット

Page 13: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

13

ナレッジが大事 !

• 自分は何をやっているのを理解しないと !– 1.0 の精度を持つのは正常 ?– モデルアプリケーションの平均二乗誤差を評価可能 ?– 使用するアルゴリズムとパラメータが適切 ?– これは正しい特徴 ?

METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEAD']def MethodFeature(request): return METHODS.index(request.method)

Page 14: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

14

結論• 分解にする ( 分類のレベルで分ける )• 柔軟な特徴収集• パフォーマンスの制限により、オフライン計算が一般的• 実験!!実験!!実験!!• 継続的実験可能な環境の用意• マシンラーニングを知れ

Page 15: Ml based detection of users anomaly activities (20th OWASP Night Tokyo, Japanese)

15

QUESTIONS?

Yury LeonychevESG, Rakuten inc.OWASP Night 9/3/[email protected]