Skip to content

Commit b061be5

Browse files
authored
- Fix ASLR exclusion force flag and add MSYS2/MinGW scanning. (#1050)
- Set isForce to "on" for per-process ASLR exclusions so they take effect when system-wide Mandatory ASLR is enabled. - Add MSYS2/MinGW executable scanning to BinarySecurityAnalyzer and update UI strings across all locales.
1 parent c95eade commit b061be5

12 files changed

Lines changed: 57 additions & 12 deletions

File tree

Harden System Security/Protect/BinarySecurityAnalyzer.cs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,57 @@ private static List<string> FindIncompatibleGitExes()
191191
return fileList;
192192
}
193193

194+
/// <summary>
195+
/// Searches for executables in MSYS2/MinGW installation directories and returns paths of files not compatible with the ASLR Exploit Protection.
196+
/// MSYS2 ships its own Git and many other executables (compilers, shells, utilities) that may not have ASLR support in their PE headers.
197+
/// </summary>
198+
/// <returns></returns>
199+
private static List<string> FindIncompatibleMSYS2Exes()
200+
{
201+
// Default MSYS2 installation paths
202+
string[] msys2Paths =
203+
[
204+
Path.Combine(GlobalVars.SystemDrive, "msys64"),
205+
Path.Combine(GlobalVars.SystemDrive, "msys32")
206+
];
207+
208+
List<string> fileList = [];
209+
210+
foreach (string basePath in msys2Paths)
211+
{
212+
if (!Directory.Exists(basePath))
213+
{
214+
continue;
215+
}
216+
217+
// Get all directories under the base path
218+
string[] directories = Directory.GetDirectories(basePath, "*", SearchOption.AllDirectories);
219+
220+
foreach (string dir in directories)
221+
{
222+
BinarySecurityProfile[] scanResult = ScanDirectory(dir);
223+
224+
foreach (BinarySecurityProfile item in scanResult)
225+
{
226+
// Find PEs that are not compatible with ASLR
227+
if (item.AddressRandomization is SecurityFeatureStatus.Disabled or SecurityFeatureStatus.Unavailable)
228+
{
229+
fileList.Add(item.BinaryPath);
230+
}
231+
}
232+
}
233+
}
234+
235+
return fileList;
236+
}
237+
194238
internal static HashSet<string> GetASLRIncompatibleGitHubExes()
195239
{
196240
List<string> results = FindIncompatibleGitHubDesktopExes();
197241
results.AddRange(FindIncompatibleGitExes());
242+
results.AddRange(FindIncompatibleMSYS2Exes());
198243

199-
Logger.Write($"Found {results.Count} Git related files incompatible with ASLR Exploit Mitigation feature:");
244+
Logger.Write($"Found {results.Count} Git, GitHub Desktop, and MSYS2/MinGW related files incompatible with ASLR Exploit Mitigation feature:");
200245

201246
foreach (string item in results)
202247
Logger.Write(item);

Harden System Security/Strings/AR/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
<value>فشل في تعيين قيمة Boot Configuration Data (BCD) No-eXecute (NX).</value>
11161116
</data>
11171117
<data name="ApplyMandatoryASLRExcl-MSDefender" xml:space="preserve">
1118-
<value>استبعاد ملفات GitHub Desktop و Git التنفيذية غير المتوافقة من ASLR الإلزامي على مستوى النظام.</value>
1118+
<value>استبعاد ملفات GitHub Desktop و Git و MSYS2/MinGW التنفيذية غير المتوافقة من ASLR الإلزامي على مستوى النظام.</value>
11191119
</data>
11201120
<data name="BetaUpdateChannels-MSDefender" xml:space="preserve">
11211121
<value>تكوين قنوات تحديث محرك ومنصة Microsoft Defender إلى بيتا.</value>

Harden System Security/Strings/ES/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
<value>Falló al establecer el valor Boot Configuration Data (BCD) No-eXecute (NX).</value>
11161116
</data>
11171117
<data name="ApplyMandatoryASLRExcl-MSDefender" xml:space="preserve">
1118-
<value>Excluyendo los ejecutables incompatibles de GitHub Desktop y Git del ASLR obligatorio a nivel del sistema.</value>
1118+
<value>Excluyendo los ejecutables incompatibles de GitHub Desktop, Git y MSYS2/MinGW del ASLR obligatorio a nivel del sistema.</value>
11191119
</data>
11201120
<data name="BetaUpdateChannels-MSDefender" xml:space="preserve">
11211121
<value>Configurando los canales de actualización del motor y plataforma de Microsoft Defender a beta.</value>

Harden System Security/Strings/de-DE/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
<value>Festlegen des No-eXecute-(NX)-Werts in den Bootkonfigurationsdaten (BCD) fehlgeschlagen.</value>
11161116
</data>
11171117
<data name="ApplyMandatoryASLRExcl-MSDefender" xml:space="preserve">
1118-
<value>Inkompatible ausführbare Dateien von GitHub Desktop und Git vom systemweiten verpflichtenden ASLR ausnehmen.</value>
1118+
<value>Inkompatible ausführbare Dateien von GitHub Desktop, Git und MSYS2/MinGW vom systemweiten verpflichtenden ASLR ausnehmen.</value>
11191119
</data>
11201120
<data name="BetaUpdateChannels-MSDefender" xml:space="preserve">
11211121
<value>Aktualisierungskanäle für Engine und Plattform von Microsoft Defender auf Beta konfigurieren.</value>

Harden System Security/Strings/el-GR/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
<value>Αποτυχία ρύθμισης της τιμής Boot Configuration Data (BCD) No-eXecute (NX).</value>
11161116
</data>
11171117
<data name="ApplyMandatoryASLRExcl-MSDefender" xml:space="preserve">
1118-
<value>Εξαίρεση των μη συμβατών εκτελέσιμων αρχείων GitHub Desktop και Git από το υποχρεωτικό ASLR σε επίπεδο συστήματος.</value>
1118+
<value>Εξαίρεση των μη συμβατών εκτελέσιμων αρχείων GitHub Desktop, Git και MSYS2/MinGW από το υποχρεωτικό ASLR σε επίπεδο συστήματος.</value>
11191119
</data>
11201120
<data name="BetaUpdateChannels-MSDefender" xml:space="preserve">
11211121
<value>Διαμόρφωση των καναλιών ενημέρωσης μηχανής και πλατφόρμας του Microsoft Defender σε beta.</value>

Harden System Security/Strings/en-US/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
<value>Failed to set the Boot Configuration Data (BCD) No-eXecute (NX) Value.</value>
11161116
</data>
11171117
<data name="ApplyMandatoryASLRExcl-MSDefender" xml:space="preserve">
1118-
<value>Exclude incompatible GitHub Desktop and Git executables from the system-wide Mandatory ASLR.</value>
1118+
<value>Exclude incompatible GitHub Desktop, Git, and MSYS2/MinGW executables from the system-wide Mandatory ASLR.</value>
11191119
</data>
11201120
<data name="BetaUpdateChannels-MSDefender" xml:space="preserve">
11211121
<value>Configure the Microsoft Defender Engine and Platform update channels to beta.</value>

Harden System Security/Strings/fr-FR/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
<value>Échec de la définition de la valeur No-eXecute (NX) des données de configuration de démarrage (BCD).</value>
11161116
</data>
11171117
<data name="ApplyMandatoryASLRExcl-MSDefender" xml:space="preserve">
1118-
<value>Exclure les exécutables GitHub Desktop et Git incompatibles de l'ASLR obligatoire à l'échelle du système.</value>
1118+
<value>Exclure les exécutables GitHub Desktop, Git et MSYS2/MinGW incompatibles de l'ASLR obligatoire à l'échelle du système.</value>
11191119
</data>
11201120
<data name="BetaUpdateChannels-MSDefender" xml:space="preserve">
11211121
<value>Configurer les canaux de mise à jour du moteur et de la plateforme Microsoft Defender en version bêta.</value>

Harden System Security/Strings/he-IL/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
<value>נכשל בהגדרת ערך No-eXecute (NX) ב-Boot Configuration Data (BCD).</value>
11161116
</data>
11171117
<data name="ApplyMandatoryASLRExcl-MSDefender" xml:space="preserve">
1118-
<value>החרגת קובצי ההפעלה הבלתי תואמים של GitHub Desktop ו-Git מ-Mandatory ASLR בכל המערכת.</value>
1118+
<value>החרגת קובצי ההפעלה הבלתי תואמים של GitHub Desktop, Git ו-MSYS2/MinGW מ-Mandatory ASLR בכל המערכת.</value>
11191119
</data>
11201120
<data name="BetaUpdateChannels-MSDefender" xml:space="preserve">
11211121
<value>הגדרת ערוצי העדכון של Engine ו-Platform של Microsoft Defender ל-beta.</value>

Harden System Security/Strings/hi-IN/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
<value>Boot Configuration Data (BCD) No-eXecute (NX) मान सेट करने में विफल।</value>
11161116
</data>
11171117
<data name="ApplyMandatoryASLRExcl-MSDefender" xml:space="preserve">
1118-
<value>सिस्टम-वाइड अनिवार्य ASLR से असंगत GitHub Desktop और Git एक्जीक्यूटेबल को बाहर कर रहे हैं।</value>
1118+
<value>सिस्टम-वाइड अनिवार्य ASLR से असंगत GitHub Desktop, Git और MSYS2/MinGW एक्जीक्यूटेबल को बाहर कर रहे हैं।</value>
11191119
</data>
11201120
<data name="BetaUpdateChannels-MSDefender" xml:space="preserve">
11211121
<value>Microsoft Defender इंजन और प्लेटफॉर्म अपडेट चैनल को बीटा पर कॉन्फ़िगर कर रहे हैं।</value>

Harden System Security/Strings/ml-IN/Resources.resw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
<value>Boot Configuration Data (BCD) No-eXecute (NX) മൂല്യം സെറ്റ് ചെയ്യുന്നതിൽ പരാജയപ്പെട്ടു.</value>
11161116
</data>
11171117
<data name="ApplyMandatoryASLRExcl-MSDefender" xml:space="preserve">
1118-
<value>സിസ്റ്റം-വൈഡ് നിർബന്ധിത ASLR-ൽ നിന്ന് പൊരുത്തമില്ലാത്ത GitHub Desktop, Git എക്സിക്യൂട്ടബിളുകൾ ഒഴിവാക്കുന്നു.</value>
1118+
<value>സിസ്റ്റം-വൈഡ് നിർബന്ധിത ASLR-ൽ നിന്ന് പൊരുത്തമില്ലാത്ത GitHub Desktop, Git, MSYS2/MinGW എക്സിക്യൂട്ടബിളുകൾ ഒഴിവാക്കുന്നു.</value>
11191119
</data>
11201120
<data name="BetaUpdateChannels-MSDefender" xml:space="preserve">
11211121
<value>Microsoft Defender എഞ്ചിൻ, പ്ലാറ്റ്‌ഫോം അപ്ഡേറ്റ് ചാനലുകൾ ബീറ്റയിലേക്ക് കോൺഫിഗർ ചെയ്യുന്നു.</value>

0 commit comments

Comments
 (0)