Description
Target Language
csharp
Query Name (Optional)
SsrfReflectionInjection
Query Type
Security
Query Description
AI Scan reported 2 medium-severity CWE-426, CWE-470 (ssrf reflection injection) finding(s) in C# public synthetic repositories that the baseline CodeQL default-setup scan did not report. Gap categories: missing-query, query-absent. Existing queries considered: none.
Why CodeQL appears to have missed these (unverified until reproduced with a test database):
- The installed security-extended suite has no C# query for attacker-selected reflection or Activator.CreateInstance targets.
- Process started by bare executable name (untrusted search path) has no C# query; issue covers CWE-426 family.
Linked findings (gap-key: csharp/query-create/ssrf-reflection-injection)
| Repo | CWE | Severity | AI scan alert | Summary |
|---|---|---|---|---|
| scan-testing | CWE-470 | medium | https://github.com/codeql-forks-felickz/scan-testing/security/code-scanning/7 | The program resolves a type name from a command-line argument and instantiates it with Activator.CreateInstance. This permits loading and constructing arbitrary available types, including constructor side effects, rather than enforcing an allowlist. |
| NIST-Juliet-CSharp-1.3 | CWE-426 | medium | https://github.com/codeql-forks-felickz/NIST-Juliet-CSharp-1.3/security/code-scanning/4248 | The application starts ls or cmd.exe by bare name rather than by a trusted absolute path. A local attacker who can place a same-named executable earlier in the service's search path can cause their binary to execute with the application's privileges. |
Findings come from AI Scan on public synthetic apps. Hypotheses above are unverified until reproduced with a test database. Verify first whether CodeQL already covers a case (for example via a different query or threat model) before adding code.
Handling decision
- Type: Query Create
- Decision: Create a new CodeQL query. No existing query covers these patterns (most findings are gap type
query-absentormissing-query). Because coverage of lower-severity patterns can be heuristic, target Community Packs unless precision is shown to be high enough for github/codeql. - Recommended actions across the findings: write-new-query (2)
Patterns in this gap
missing-query(1 finding), for example scan-testing Oopsies/CtorIsBoring/Program.csquery-absent(1 finding), for example NIST-Juliet-CSharp-1.3 src/src/testcases/CWE426_Untrusted_Search_Path/CWE426_Untrusted_Search_Path__Process_01.cs
Finding details
Each finding below has its own context so the agent can work from this issue alone.
1. scan-testing Oopsies/CtorIsBoring/Program.cs:4 (CWE-470, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/scan-testing/security/code-scanning/7
- AI Scan message: The program resolves a type name from a command-line argument and instantiates it with Activator.CreateInstance. This permits loading and constructing arbitrary available types, including constructor side effects, rather than enforcing an allowlist.
- Why CodeQL appears to miss it: missing-query: The installed security-extended suite has no C# query for attacker-selected reflection or Activator.CreateInstance targets.
- Recommended action from the comparison: write-new-query (classification confidence: high)
2. NIST-Juliet-CSharp-1.3 src/src/testcases/CWE426_Untrusted_Search_Path/CWE426_Untrusted_Search_Path__Process_01.cs:49 (CWE-426, medium)
- AI Scan alert: https://github.com/codeql-forks-felickz/NIST-Juliet-CSharp-1.3/security/code-scanning/4248
- AI Scan message: The application starts
lsorcmd.exeby bare name rather than by a trusted absolute path. A local attacker who can place a same-named executable earlier in the service's search path can cause their binary to execute with the application's privileges. - Context for the agent: In NIST-Juliet-CSharp-1.3 at src/src/testcases/CWE426_Untrusted_Search_Path/CWE426_Untrusted_Search_Path__Process_01.cs:49, The application starts
lsorcmd.exeby bare name rather than by a trusted absolute path. A local attacker who can place a same-named executable earlier in the service's search path can cause their binary to execute with the application's privileges. CodeQL would need: Process started by bare executable name (untrusted search path) has no C# query; issue covers CWE-426 family. - Why CodeQL appears to miss it: query-absent: Process started by bare executable name (untrusted search path) has no C# query; issue covers CWE-426 family.
- Recommended action from the comparison: write-new-query (classification confidence: low)
Expected Severity
Medium
Code Examples
See the linked alerts above for the vulnerable pattern; reduce each to a minimal test case with a safe counterpart that should not alert.
CWE/CVE Reference (Optional)
CWE-426, CWE-470
References (Optional)
https://cwe.mitre.org/data/definitions/426.html
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
felickz commentedon Nov 3, 2026
Upstream triage
precision:lowAudit-grade or weak signal. Community Packs, always tags:experimental.
tags:experimental
Goes to Community Packs: performance, false-positive or synthetic-only concerns.
Community Packs, experimental. Recommended for the Community Packs repository, not
github/codeql. The issue is labeledtags:experimentalfor this.Linked pull request: #341
Why. Two new queries with no C# equivalent upstream (the Java reflection analog is still experimental). cs/untrusted-search-path reports every Process.Start of a bare tool name such as git or ping and picks sources by regexp over all string literals, so it is audit grade. cs/unsafe-reflection uses exact Type, Activator and Assembly sinks, but its tests only run under the local threat model. Both fit Community Packs as experimental.
mediumin the pull request). cs/untrusted-search-path flags every bare-name Process.Start or ProcessStartInfo literal (git, ping, netstat) via regexps on string literals: audit grade. cs/unsafe-reflection is nearer high (BCL sinks, allow-list barriers) but its tests only cover the local threat model.Concerns, overlap and next steps
False-positive concerns
Performance concerns
Heuristics used
What an upstream change would look like. Community Packs csharp/src/security/CWE-470/UnsafeReflection.ql and csharp/src/audit/UntrustedSearchPath.ql (audit grade), each with qhelp and tests under csharp/test; submit as two PRs.
Before opening an upstream pull request
Split note. cs/unsafe-reflection is nearer high precision, but it is a new query and the Java equivalent is still experimental upstream, so both queries go to Community Packs. cs/untrusted-search-path is audit grade; submit the two separately.
This is a recommendation only. A human reviews it before any pull request is opened against
github/codeqlor the Community Packs repository.