fix(script-analysis): forbid System.AppDomain in scripts (CMN-2, WP1 task 1.2)
AppDomain's assembly-loading members (ExecuteAssembly[ByName], Load, CreateInstanceFrom[AndUnwrap], CreateInstanceAndUnwrap) were neither a forbidden scope nor exact gateway names, so a script could load and run an external assembly (even from a UNC path) in the host process. The whole type is now a forbidden scope, like System.Environment and System.GC. AppContext/Debugger were considered and left alone (no assembly-load surface). Tests: every AppDomain loading spelling (member access, ?., using static, alias) is flagged; the ban is exact-type.
This commit is contained in:
@@ -43,6 +43,7 @@ The following namespace/type prefixes are forbidden in all scripts:
|
||||
| `Microsoft.Win32` | Win32 API access — forbidden entirely |
|
||||
| `System.Environment` | Whole type — forbidden entirely; exposes process control (`Exit`/`FailFast`), the host environment, and secrets via environment variables (e.g. `SCADABRIDGE_API_KEY`). Scripts that need a line break use `"\n"` instead of `Environment.NewLine`. |
|
||||
| `System.GC` | Whole type — forbidden entirely; GC control (`Collect`, `KeepAlive`, memory-pressure knobs) has no legitimate script use. |
|
||||
| `System.AppDomain` | Whole type — forbidden entirely (code review 2026-12-02 CMN-2); its assembly-loading members (`ExecuteAssembly`, `ExecuteAssemblyByName`, `Load`, `CreateInstanceFrom[AndUnwrap]`, `CreateInstanceAndUnwrap`) load and run external code — a UNC path needs no local write — inside the host process. |
|
||||
| `Microsoft.Data` | Concrete ADO.NET provider namespace (`Microsoft.Data.SqlClient`, …) — forbidden; closes the arbitrary-host `new SqlConnection("Server=attacker")` channel |
|
||||
| `System.Data.SqlClient` | Concrete ADO.NET SQL Server provider — forbidden (see provider-namespace posture below) |
|
||||
| `System.Data.Odbc` | Concrete ADO.NET ODBC provider — forbidden |
|
||||
@@ -60,7 +61,7 @@ The following types are explicitly allowed despite falling within a forbidden na
|
||||
- `System.Threading.CancellationToken` — cooperative cancellation
|
||||
- `System.Threading.CancellationTokenSource` — cooperative cancellation
|
||||
|
||||
The scoping rationale: `System.Diagnostics.Process` is the dangerous type (spawns processes); `Stopwatch`, `Debug`, and `Activity` are harmless diagnostic utilities. Forbidding the whole `System.Diagnostics` namespace, as some earlier call sites did, was overly broad. In contrast, `System.Environment` and `System.GC` are forbidden as **whole types** because — unlike `System.Diagnostics` — they have no harmless members a script legitimately needs.
|
||||
The scoping rationale: `System.Diagnostics.Process` is the dangerous type (spawns processes); `Stopwatch`, `Debug`, and `Activity` are harmless diagnostic utilities. Forbidding the whole `System.Diagnostics` namespace, as some earlier call sites did, was overly broad. In contrast, `System.Environment`, `System.GC` and `System.AppDomain` are forbidden as **whole types** because — unlike `System.Diagnostics` — they have no harmless members a script legitimately needs.
|
||||
|
||||
#### Reflection-gateway members
|
||||
|
||||
|
||||
Reference in New Issue
Block a user