LoginSignup
2
1

More than 1 year has passed since last update.

Docker版OWASP ZAPでBasic認証を突破する

Last updated at Posted at 2022-07-28

始めに

OWASP ZAPはWebアプリケーションの脆弱性診断ができるOSSです。
デスクトップアプリケーションとしての色が強いですがDocker版もリリースされており、特にCI/CD環境で簡単にZAPを実行することで開発フェーズの中で脆弱性診断を行うことができます。

基本的な操作、インストールなどは公式の1次情報がわかりやすいです。
https://www.zaproxy.org/docs/docker/
参考にしたQiita:
https://qiita.com/koujimatsuda11/items/83558cd62c20141ebdda

本記事のOS:AmazonLinux2

Basic認証を突破する

OWASP ZAPでBasic認証のかけられたサイトを診断しようとすると401エラーが返ってきます。

docker run -v $(pwd):/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t https://test.com/ -r test.html

> Automation plan failures:
        Job spider failed to access URL https://test.com/ status code returned : 401 expected 200

Basic認証を突破する方法はいくつかありますが、今回は
HttpリクエストヘッダーにAuthorization: Base <User>:<pass>※base64エンコード
を追加する方法をとりました。
https://developer.mozilla.org/ja/docs/Web/HTTP/Headers/Authorization

ZAPの診断で独自のカスタムヘッダーを追加するには-zオプションでConfigを設定する必要があります。

Linuxであれば echo user:pass | base64でエンコードされた文字列を取得できます。
その文字列をreplacement= Base *****に代入。

docker run -v $(pwd):/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py -t https://test.com/ -r test.html \
  -z " -config replacer.full_list\\(0\\).description=auth1 \ 
  -config replacer.full_list\\(0\\).enabled=true \  
  -config replacer.full_list\\(0\\).matchtype=REQ_HEADER \  
  -config replacer.full_list\\(0\\).matchstr=Authorization \  
  -config replacer.full_list\\(0\\).regex=false \  
  -config replacer.full_list\\(0\\).replacement=Base ***** "

あるいは、以下のようなConfig fileをホームディレクトリ直下に用意しておき、

option.prop
replacer.full_list(0).description=auth1
replacer.full_list(0).enabled=true
replacer.full_list(0).matchtype=REQ_HEADER
replacer.full_list(0).matchstr=Authorization
replacer.full_list(0).regex=false
replacer.full_list(0).replacement=Base *****

ZAP実行時に-zオプションでConfig Fileを指定。

docker run -v $(pwd):/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py \
> -t https://test.com/ -r test.html \
> -z "-configfile /zap/wrk/option.prop"

これでBasic認証を突破できました。

参考にした記事

https://www.zaproxy.org/docs/docker/baseline-scan/
https://www.zaproxy.org/docs/desktop/cmdline/
https://www.zaproxy.org/faq/how-do-you-find-out-what-key-to-use-to-set-a-config-value-on-the-command-line/

2
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
2
1