T09 · Insecure Skill Coding Practices
- Location
COMPILATION_ERROR_HANDLING.md:411- Finding
Untrusted C# Scripts Can Be Compiled and Executed with Host Process Privileges
- Content
View full analysis
{ log = compilation.GetNatashaLog(); }; try { builder.Add(script); var assembly = builder.GetAssembly(); var type = assembly.GetTypes().First(); var method = type.GetMethods().First(m => m.IsStatic && m.IsPublic); return method.Invoke(null, null); } ``` A second example demonstrates the same unsafe trust model for code loaded from files: **Additional Location**: `references/common-patterns.md:929-970` ```csharp public static List ScanLogical(string[] pluginFiles, string fatherClassName) where T : class { List result = []; AssemblyCSharpBuilder assemblyCSharp = new(); assemblyCSharp .UseRandomLoadContext() .UseSmartMode() .WithDebugCompile(c => c.ForAssembly()); var fileIndexArray = new int[pluginFiles.Length]; Dictionary typeNamesCache = []; for (int i = 0; i < pluginFiles.Length; i++) { var fileIndexString = Path.GetFileNameWithoutExtension(pluginFiles[i]); if (fileIndexString != null && Int32.TryParse(fileIndexString, out var fileIndex)) { var className = $"N{Guid.NewGuid():n}"; typeNamesCache.Add(fileIndex, className); var classMethodText = File.ReadAllText(pluginFiles[i]); var classScript = @$"public class {className} : {fatherClassName}{{ {classMethodText} ...[truncated 2990 chars]- Remediation
View remediation
