Skip to content

Commit e62d083

Browse files
AguilexCopilotmattleibow
authored
Enable BufferSecurityCheck for native DLLs to resolve BinSkim BA2007 (#3404)
* Enable BufferSecurityCheck for native DLLs to resolve BinSkim BA2007 This change enables the /GS (Buffer Security Check) compiler flag for three native libraries to resolve BinSkim error BA2007: - libHarfBuzzSharp.dll: Added BufferSecurityCheck=true to all configurations in the vcxproj file, including creating the missing Debug|ARM64 ItemDefinitionGroup - libEGL.dll and libGLESv2.dll: Added /GS flag to extra_cflags in the ANGLE GN build configuration The /GS flag enables compile-time buffer overrun detection, which is an important security feature that helps prevent stack-based buffer overflow attacks. * Merge duplicate Debug|Win32 ItemDefinitionGroup in libHarfBuzzSharp.vcxproj (#3405) * Initial plan * Merge duplicate Debug|Win32 sections in libHarfBuzzSharp.vcxproj Co-authored-by: mattleibow <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: mattleibow <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: mattleibow <[email protected]>
1 parent 5f0c7df commit e62d083

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

native/windows/libHarfBuzzSharp/libHarfBuzzSharp.vcxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
147147
<ObjectFileName>$(IntDir)</ObjectFileName>
148148
<ControlFlowGuard>Guard</ControlFlowGuard>
149+
<BufferSecurityCheck>true</BufferSecurityCheck>
149150
</ClCompile>
150151
<Link>
151152
<SubSystem>Windows</SubSystem>
@@ -164,6 +165,7 @@
164165
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
165166
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
166167
<ControlFlowGuard>Guard</ControlFlowGuard>
168+
<BufferSecurityCheck>true</BufferSecurityCheck>
167169
</ClCompile>
168170
<Link>
169171
<SubSystem>Windows</SubSystem>
@@ -182,6 +184,7 @@
182184
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
183185
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
184186
<ControlFlowGuard>Guard</ControlFlowGuard>
187+
<BufferSecurityCheck>true</BufferSecurityCheck>
185188
</ClCompile>
186189
<Link>
187190
<SubSystem>Windows</SubSystem>
@@ -202,6 +205,7 @@
202205
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
203206
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
204207
<ControlFlowGuard>Guard</ControlFlowGuard>
208+
<BufferSecurityCheck>true</BufferSecurityCheck>
205209
</ClCompile>
206210
<Link>
207211
<SubSystem>Windows</SubSystem>
@@ -224,6 +228,7 @@
224228
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
225229
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
226230
<ControlFlowGuard>Guard</ControlFlowGuard>
231+
<BufferSecurityCheck>true</BufferSecurityCheck>
227232
</ClCompile>
228233
<Link>
229234
<SubSystem>Windows</SubSystem>
@@ -246,6 +251,7 @@
246251
<DisableSpecificWarnings>4267;4244</DisableSpecificWarnings>
247252
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
248253
<ControlFlowGuard>Guard</ControlFlowGuard>
254+
<BufferSecurityCheck>true</BufferSecurityCheck>
249255
</ClCompile>
250256
<Link>
251257
<SubSystem>Windows</SubSystem>

native/winui-angle/build.cake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Task("ANGLE")
123123
$"angle_enable_wgpu=false " +
124124
$"angle_enable_gl_desktop_backend=false " +
125125
$"angle_enable_vulkan=false " +
126-
$"extra_cflags=[ '/guard:cf' ] " +
126+
$"extra_cflags=[ '/guard:cf', '/GS' ] " +
127127
$"extra_ldflags=[ '/guard:cf' ]");
128128

129129
RunNinja(ANGLE_PATH, $"out/winui{suffix}/{arch}", target);

0 commit comments

Comments
 (0)