What changed, and why it matters
This commit fixes a simple but potentially important coding mistake: a constructor parameter named `loadAssembliesInDefaultLoadContext` was not being saved into its matching field. As a result, the plugin loader's intended setting about where to load assemblies was effectively ignored, and the code would fall back to the default value (false). This could change how plugins are isolated from the main application, potentially weakening the sandbox between plugins and the host.
Review how `ManagedLoadContext` is instantiated and confirm whether any production code relied on `loadAssembliesInDefaultLoadContext = true`. If so, assess whether the prior default-false behavior created unsafe plugin isolation or type-confusion conditions. Apply the patch and add regression tests or static analysis rules to catch unassigned constructor parameters.
Security signals we found
Missing field assignment in plugin loader constructor
Behavioral mismatch between requested and actual load context policy
Potential weakening of assembly isolation boundary
Silent misconfiguration with no runtime error
Evidence from the diff
In ManagedLoadContext.cs, the constructor accepted loadAssembliesInDefaultLoadContext but never assigned it to _loadAssembliesInDefaultLoadContext. The patch adds the missing assignment. Because the field would retain its default false value, any caller requesting loadAssembliesInDefaultLoadContext = true would silently get the opposite behavior. In a plugin loader, this misconfiguration could cause plugin assemblies to be loaded into a non-default context when they were meant to share the default one, or vice versa, affecting isolation, dependency resolution, and possibly type-identity issues.
Changed components
BTCPayServer.Plugins.Dotnet.Loader.ManagedLoadContextInspect captured patch +1 / −0
diff --git a/BTCPayServer/Plugins/Dotnet/Loader/ManagedLoadContext.cs b/BTCPayServer/Plugins/Dotnet/Loader/ManagedLoadContext.cs
index 09add8a..cb83ccf 100644
--- a/BTCPayServer/Plugins/Dotnet/Loader/ManagedLoadContext.cs
+++ b/BTCPayServer/Plugins/Dotnet/Loader/ManagedLoadContext.cs
@@ -69,6 +69,7 @@ namespace BTCPayServer.Plugins.Dotnet.Loader
_additionalProbingPaths = additionalProbingPaths ?? throw new ArgumentNullException(nameof(additionalProbingPaths));
_assemblyLoadContexts.Add(defaultLoadContext);
_preferDefaultLoadContext = preferDefaultLoadContext;
+ _loadAssembliesInDefaultLoadContext = loadAssembliesInDefaultLoadContext;
_loadInMemory = loadInMemory;
_lazyLoadReferences = lazyLoadReferences;
Why this scored 34/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.