[BUG] BD000704 matches identifier text: case flip or Unicode homoglyph renaming evades the hostname rule
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 42/100
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
- Lingua principale
- C#
- Stelle
- 372
- Fork
- 57
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
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 35/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
-
Idiomatic Test OrganizationAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
Tutte le issue di microsoft/OSSGadget
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Nimblesite/SharpLsp#468 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
elastic/ecs-dotnet#575 ·
-
alerts bug effort:S P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
nightscout/nocturne#2511 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 2 giorni
-
Crash in v3.00Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
arkane-systems/mousejiggler#140 ·