Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[BUG] BD000704 matches identifier text: case flip or Unicode homoglyph renaming evades the hostname rule

Aperta
#541 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp
Ambito
security

Direzione di ricerca

Start with Resources/BackdoorRules/data_exfiltration.json and rule BD000704; inspect how OSSGadget's detection engine loads and matches these patterns, then locate the related tests. Compare the reported identifier variants and decide how to test coverage for case changes and Unicode homoglyphs. Done means regression tests demonstrate the intended hostname detection behavior and the rule or detection approach handles the reported variants.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Case Study

Code that collects the hostname (detected):

import os
import platform

hostname = platform.node()
target_host = os.environ["HOST_VALUE"]
print(hostname, target_host)

Detected as 2 findings: BD000704 Security.Backdoor.DataExFiltration.Hostname (Important, Confidence Low), matched on the "hostname" identifier occurrences.

Semantically identical code after a payload-preserving identifier rename (not detected):

import os
import platform

Hostname = platform.node()
Target_host = os.environ["HOST_VALUE"]
print(Hostname, Target_host)

Result: "0 matches found."

Two additional probes confirm the same weakness:

  • "Hostname = 1" -> 0 matches (case flip)
  • "h\u043estname = 1" (Cyrillic 'o') -> 0 matches (Unicode homoglyph)

Both snippets are generated/adapted with the SKILLCLOAK operators "case-flip" and "confusable"; program behaviour is unchanged because only the spelling of a local variable changes.

Current rules

File: Resources/BackdoorRules/data_exfiltration.json, rule BD000704 (severity important, confidence low, scope code)

pattern: ".hostname"   type: string
pattern: "hostname"    type: string

These are token/literal patterns rather than semantic checks: they match the identifier text itself, not the API that obtains the hostname. Renaming the local variable (or substituting a visually identical Cyrillic glyph) removes the only evidence the rule looks at.

Suggested Fix

Prefer an AST/semantic rule for hostname collection, for example Call nodes whose target resolves to:
socket.gethostname, platform.node, os.uname()[1], or reading the HOSTNAME environment variable.
If token patterns are kept for coverage, normalize the source before matching:

  • Unicode NFKC / confusable (homoglyph) folding;
  • case folding for identifier rules;
    and add regression tests for "Hostname", "HOSTNAME" and Cyrillic-homoglyph variants.

Reproduction results

Environment: OSSGadget 0.2.38 (ApplicationInspector rules engine, .NET 8), Windows 11 (10.0.26200).

Commands (from this directory):

ossgadget detect-backdoor -f text ./run/ori
ossgadget detect-backdoor -f text ./run/adv

Results:

ori: 2 matches (BD000704, Important/Low).
adv: 0 matches.

Corpus evidence: on the 453-file corpus, case-flip reduced BD000704 283 -> 158 and BD000703 6 -> 2; confusable reduced BD000704 283 -> 158, BD000600 279 -> 241, BD000701 196 -> 171.

Attachments: ori.py, adv.py

adv.py
ori.py

Lingua principale
C#
Stelle
372
Fork
57
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Apri in Codespaces

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/OSSGadget

Tutte le issue di microsoft/OSSGadget

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.