github / github/codeql

UnvalidatedDynamicMethodCall query does not detect flow inside try/catch

Offen
#20,098 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
question
Vorherrschende Sprache
CodeQL
Sterne
10.1k
Forks
2.1k
Ø Merge
2 T. 15 Std.
Gemergte PRs (30 T.)
141

Beschreibung

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](https://github.com/fguisso/backoffice-balm) 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with the UnvalidatedDynamicMethodCall query and reproduce the training challenge linked in the issue. Compare the Express route using req.params.action inside an arrow-function handler with and without try/catch, then confirm that the vulnerable dynamic call is detected when the issue is fixed.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
express, javascript
Bereich
security
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.