fbsamples / fbsamples/messenger-platform-samples

Potential reflected XSS in the WebSub intent verification

オープン
#181 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
1.8k
フォーク
2.5k
PR マージ指標
30日以内にマージされた PR はありません

説明

I believe the WebSub intent verification might be vulnerable to XSS because it reflects the hub.challenge parameter with a HTML content type:

Example in Flask (uses HTML by default):

~~~python
@app.route("/webhook", methods=["GET", "POST"])
def webhook():
# Webhook verification
if request.method == "GET":
if request.args.get("hub.mode") == "subscribe" and request.args.get(
"hub.challenge"
):
if not request.args.get("hub.verify_token") == TOKEN:
return "Verification token mismatch", 403
print("WEBHOOK_VERIFIED")
return request.args["hub.challenge"], 20
elif request.method == "POST":
...
~~~

Example in Express:

~~~js
app.get('/webhook', (req, res) => {
if (req.query['hub.verify_token'] === env.VERIFY_TOKEN) {
res.send(req.query['hub.challenge']);
}
});
~~~

Another example in Express:

~~~js
// Accepts GET requests at the /webhook endpoint
app.get('/webhook', (req, res) => {

const VERIFY_TOKEN = process.env.TOKEN;

// Parse params from the webhook verification request
let mode = req.query['hub.mode'];
let token = req.query['hub.verify_token'];
let challenge = req.query['hub.challenge'];

// Check if a token and mode were sent
if (mode && token) {

// Check the mode and token sent are correct
if (mode === 'subscribe' && token === VERIFY_TOKEN) {

// Respond with 200 OK and challenge token from the request
console.log('WEBHOOK_VERIFIED');
res.status(200).send(challenge);

} else {
// Responds with '403 Forbidden' if verify tokens do not match
res.sendStatus(403);
}
}
});
~~~

Reference: https://www.w3.org/TR/websub/

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。