Skip to content

Commit 8c8eeee

Browse files
committed
Doc: AssemblyBuilder require fully trusted environment with trusted input
1 parent 92d0aaa commit 8c8eeee

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

xml/System.Reflection.Emit/AssemblyBuilder.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,14 @@
7676
</Attributes>
7777
<Docs>
7878
<summary>Defines and represents a dynamic assembly.</summary>
79-
<remarks>For more information about this API, see <see href="/dotnet/fundamentals/runtime-libraries/system-reflection-emit-assemblybuilder">Supplemental API remarks for AssemblyBuilder</see>.</remarks>
79+
<remarks>For more information about this API, see <see href="/dotnet/fundamentals/runtime-libraries/system-reflection-emit-assemblybuilder">Supplemental API remarks for AssemblyBuilder</see>.
80+
<format type="text/markdown">
81+
<![CDATA[
82+
> [!WARNING]
83+
> `AssemblyBuilder` APIs require a fully trusted environment with trusted input, similarly as other technologies such as compilers. There are no restrictions other than basic validation for generated IL, for member name, count and associated metadata such as custom attributes, that the AssemblyBuilder can contain. For example untrusted input that directly affects the produced IL written to an assembly that later loaded and executed, such input can do whatever it wishes.
84+
]]>
85+
</format>
86+
</remarks>
8087
<example>
8188
<format type="text/markdown"><![CDATA[
8289
The following code example shows how to define and use a dynamic assembly. The example assembly contains one type, `MyDynamicType`, that has a private field, a property that gets and sets the private field, constructors that initialize the private field, and a method that multiplies a user-supplied number by the private field value and returns the result.

xml/System.Reflection.Emit/ILGenerator.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@
8484
8585
MSIL is used as input to a just-in-time (JIT) compiler.
8686
87+
> [!WARNING]
88+
> There are no restrictions, other than basic validation for ILGenerator APIs that used for producing method IL. If untrusted input is used for producing IL:
89+
90+
> - IL and metadata can contain secrets provided by the consumer.
91+
> - IL can be invalid such as not having a balanced push vs. pop opcodes, or invalid operands for a given opcode.
92+
> - Can contain any code that may, for example, deadlock, have infinite stack recursion, or have an infinite loop.
93+
> - IL can load and execute code on any other reachable assembly.
94+
95+
> Such code can do whatever it wishes when the method is loaded and executed. To restrict such vulnerabilities `ILGenerator` require a fully trusted environment with trusted input.
8796
]]></format>
8897
</remarks>
8998
</Docs>

xml/System.Reflection.Emit/PersistedAssemblyBuilder.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@
2525
</Attributes>
2626
<Docs>
2727
<summary>Provides an AssemblyBuilder implementation that can persist assembly to a disk or stream.</summary>
28-
<remarks>To be added.</remarks>
28+
<remarks>For more information about this API, see <see href="/dotnet/fundamentals/runtime-libraries/system-reflection-emit-persistedassemblybuilder">Persisted dynamic assemblies in .NET</see>.
29+
<format type="text/markdown">
30+
<![CDATA[
31+
> [!WARNING]
32+
> `PersistedAssemblyBuilder` APIs require a fully trusted environment with trusted input, similarly as other technologies such as compilers. There are no restrictions other than basic validation for generated IL, for member name, count and associated metadata such as custom attributes, that the AssemblyBuilder can contain. For example untrusted input that directly affects the produced IL written to an assembly that later loaded and executed, such input can do whatever it wishes.
33+
]]>
34+
</format>
35+
</remarks>
2936
</Docs>
3037
<Members>
3138
<Member MemberName=".ctor">

0 commit comments

Comments
 (0)