UnvalidatedDynamicMethodCall query does not detect flow inside try/catch

オープン
#20,098 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
express, javascript
領域
security

調査の方向性

UnvalidatedDynamicMethodCall クエリから始め、issue にリンクされているトレーニングチャレンジを再現してください。arrow-function ハンドラー内で req.params.action を使用する Express route について、try/catch がある場合とない場合を比較し、その後、issue が修正されたときに脆弱な動的呼び出しが検出されることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

question

Hi CodeQL team 👋

I'm currently building some training challenges for developers to help them identify insecure dynamic method calls. I designed one of the exercises based on the UnvalidatedDynamicMethodCall alert.

However, I noticed that the vulnerability I created was not detected by the query. After a lot of debugging, I suspect the query does not handle taint flow properly when the logic is inside arrow functions.

  • The vulnerable code uses an Express route with an arrow function as the handler.
  • Inside the arrow function, I access req.params.action and use it to dynamically invoke a method: userManager[action](...).
  • This allows access to both regular and admin-only methods of the userManager object.

Unfortunately, this pattern wasn't flagged by the query, even though it's clearly unsafe.

I'm still learning how CodeQL queries work, and I'm not very experienced with the query language yet. I'd really appreciate any help understanding why this scenario is missed, and how I might contribute a feature for it.

I'd love to open a PR — just need some guidance on how to proceed the right way.

update: I have tested here like @rvermeulen said and the catch is the try/catch.

git blaming cc: @asgerf

主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 10時間
マージ済み PR(30日)
134

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/codeql のほかの issue

github/codeql の issue をすべて見る

似ている issue

Security の issue をもっと見る

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

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