Skip to content

Commit 2bc0d19

Browse files
Merge pull request #2 from MahmoudGSaleh/TylerMSFT-patch-1-1
Update Visual C++ Runtime auditing guide
2 parents 79fe7d2 + 8b617f4 commit 2bc0d19

File tree

1 file changed

+47
-66
lines changed

1 file changed

+47
-66
lines changed

docs/windows/redist-version-auditing.md

Lines changed: 47 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: "cpp-redist-version-auditing"
3-
description: "This article provides a detailed guide for auditing usage of Visual C++ Runtime versions within your organization."
2+
title: "How to audit Visual C++ Runtime version usage"
3+
description: "A detailed guide for auditing Visual C++ Runtime file usage."
44
ms.date: 12/2/2024
55
helpviewer_keywords:
66
[
@@ -11,89 +11,74 @@ author: MahmoudGSaleh
1111
ms.author: msaleh
1212
---
1313

14-
# How to audit Visual C++ Runtime version usage within your organization
14+
# How to audit Visual C++ Runtime version usage
1515

16-
The Microsoft Visual C++ Redistributable and the Visual Studio C++ Runtime (collectively, "VC Runtime") are critical components to thousands of applications. Across your enterprise network, machines may still be running applications that install and use an out-of-support version of the VC Runtime. NTFS File Auditing can be used to identify such usage as a step towards helping you replace these applications with ones that take a dependency on a supported version of the VC Runtime. This guide will walk you through setting up NTFS File Auditing, provide troubleshooting tips, and highlight the benefits of regular audits.
16+
The Microsoft Visual C++ Redistributable and the Visual Studio C++ Runtime (collectively, "VC Runtime") are critical components of many applications. Across your network, machines may still be running applications that install and use an out-of-support version of the VC Runtime. You can use NTFS file auditing to identify such usage as a step towards replacing those applications with ones that use a supported version of the VC Runtime. This guide walks you through setting up NTFS file auditing, provides troubleshooting tips, and highlights the benefits of regular audits.
1717

18-
For details on the versions of VC Runtime no longer supported, see [Microsoft Visual C++ Redistributable latest supported downloads](/cpp/windows/latest-supported-vc-redist).
18+
For more information about the versions of VC Runtime that are no longer supported, see [Microsoft Visual C++ Redistributable latest supported downloads](/cpp/windows/latest-supported-vc-redist).
1919

20-
## Enabling NTFS File Auditing to determine usage of VC Runtime
20+
## Enable NTFS file auditing to determine VC Runtime usage
2121

22-
NTFS File Auditing can be used to determine which process is calling VC Runtime files. You can use this information on machines with legacy versions of the VC Runtime already installed to determine which applications are calling the unsupported versions of the VC Runtime.
22+
You can use NTFS file auditing to determine which applications are calling the unsupported versions of the VC Runtime.
2323

24-
This guide will first provide steps to manually enable NTFS File Auditing and review logs. Because there are several component files that can be used by an application, this guide also shows how to use PowerShell's [Get-Acl](/powershell/module/microsoft.powershell.security/get-acl) and [Set-Acl](/powershell/module/microsoft.powershell.security/set-acl) cmdlets to update Auditing permissions. For details on how to configure the audit policies on a file, see [Apply a basic audit policy on a file or folder.](/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/apply-a-basic-audit-policy-on-a-file-or-folder)
24+
This guide provides the steps to manually enable NTFS file auditing and review audit events. Because there are several files that can be used by an application, this guide also shows how to use PowerShell's [`Get-Acl`](/powershell/module/microsoft.powershell.security/get-acl) and [`Set-Acl`](/powershell/module/microsoft.powershell.security/set-acl) cmdlets to update auditing permissions. For more information about how to configure audit policies for a file, see [Apply a basic audit policy on a file or folder](/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/apply-a-basic-audit-policy-on-a-file-or-folder).
2525

2626
### Manually enable object access auditing on the system
2727

28-
Object access must be enabled before you enable file level auditing.
28+
Object access must be enabled before you enable file level auditing:
2929

30-
1. Open Group Policy: Press Windows + R to open the **Run** dialog , type `gpedit.msc`, and press Enter.
31-
2. Navigate to **Computer Configuration** > **Windows Settings** > **Security Settings** > **Advanced Audit Policy Configuration** > **System Audit Policies** > **Object Access**.
32-
3. Double-click on **Audit File System**. In the **Audit File System Properties** dialog, select **Configure the following audit events**, select **Success** and then select **OK**.
33-
4. Close the Group Policy Editor app
30+
1. Open the Local Group Policy Editor by pressing Windows + R to open the **Run** dialog, then type `gpedit.msc`, and press Enter.
31+
1. Navigate to **Computer Configuration** > **Windows Settings** > **Security Settings** > **Advanced Audit Policy Configuration** > **System Audit Policies** > **Object Access**.
32+
1. Double-click **Audit File System**. In the **Audit File System Properties** dialog, select **Configure the following audit events** > **Success** > **OK**.
33+
1. Close the Group Policy Editor.
3434

35-
Alternatively, you may use auditpol.exe to enable object access.
35+
Alternatively, you may use `auditpol.exe` to enable object access:
3636

37-
1. List the current settings with `AuditPol.exe /get /category:"Object Access"`.
38-
2. Enable/Disable with `AuditPol.exe /set /category:"Object Access" /subcategory:"File System" /success:enable`.
37+
1. List the current settings from the command line with `AuditPol.exe /get /category:"Object Access"`.
38+
1. Enable object access with `AuditPol.exe /set /category:"Object Access" /subcategory:"File System" /success:enable`.
3939

4040
### Manually enable auditing on a file
4141

42-
To monitor which process is accessing a VC Runtime file, enable auditing on the file.
42+
To monitor which process accesses a VC Runtime file, enable auditing on the file:
4343

44-
1. Right-click on the file that you want to audit, select **Properties**, and then select **Security** tab.
44+
1. Right-click the file that you want to audit, select **Properties**, and then select the **Security** tab. For more information about finding installed VC Runtime files, see [VC Runtime installed locations](#vcruntime_install_location).
45+
1. Select **Advanced**.
46+
1. In the **Advanced Security Settings** dialog box, select the **Auditing** tab and then select **Continue**.
47+
1. To add a new auditing rule, select **Add**. In the **Auditing Entry** dialog, select a principal, then type the name of the user or group you want to add such as **(Everyone)**, and then select **OK**.
48+
1. In **Type**, select ensure that **Success** is selected.
49+
1. Select **Show advance permissions** > **Clear all** > **Traverse folder / execute file** > **OK**.
50+
1. There should now be a new row in the **Auditing** entries matching what you have selected. Select **OK**.
51+
1. In the **Properties** Dialog, select **OK**.
4552

46-
* See the section below [VC Runtime installed locations](#vcruntime_install_location) to find the VC Runtime files installed on a machine.
47-
48-
2. Select **Advanced**.
49-
50-
3. In the **Advanced Security Settings** dialog box, select **Auditing** tab and then select **Continue**.
51-
52-
4. To add a new auditing rule, select **Add**. In the **Auditing Entry** dialog, select a principal, then type the name of the user or group you want to add (Everyone) and then select OK.
53-
54-
5. In the Type box, use the default of **Success**.
55-
56-
6. Select **Show advance permissions**, select **Clear all** and then select **Traverse folder / execute file**, and select **OK**.
57-
58-
7. At this point there should be a new row in the **Auditing** entries matching what you have selected. Select **OK**.
59-
60-
8. In the **Properties** Dialog, select **OK**.
61-
62-
The audit rule is enabled now.
53+
The audit rule is now enabled for the file.
6354

6455
### Manually review audit logs
6556

66-
NTFS File Auditing will generate ["Event 4663: An attempt was made to access an object"](/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4663) for each file that includes + audit permission and the+ process accessing process namethe file.
67-
68-
1. Open Event Viewer: Press Windows + R to open the **Run** dialog , type `eventvwr.msc`, and press Enter.
57+
NTFS file auditing generates ["Event 4663: An attempt was made to access an object"](/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4663) for each file that includes the audit permission and that is accessed by a process.
6958

70-
2. Navigate to Security Logs: In the Event Viewer, expand Windows Logs and select **Security**. The results pane lists individual security events.
71-
72-
3. Filter and Analyze the Logs: Use the **Filter Current Log** option to narrow down the events to Event ID 4663 (Audit Success for the File System Category).
59+
1. Open the Event Viewer by pressing `Windows` + `R` to open the **Run** dialog. Then type `eventvwr.msc`, and press Enter.
60+
1. Navigate to the **Security** logs in the Event Viewer by expanding **Windows Logs** > **Security**. The results pane lists security events.
61+
1. Find the audit events by choosing **Filter Current Log...** in the **Actions** pane. Narrow down the events to **Event ID 4663 (Audit Success for the File System Category)** by entering **4663 into the Includes/Excludes Event IDs** text box.
7362

7463
For an example of a File Access Auditing Event 4663, see ["4663(S): An attempt was made to access an object."](/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-4663)
7564

7665
![Event Viewer showing security logs](media/windows-events.png)
7766

78-
### Using PowerShell to enable auditing of VC Runtime usage
79-
80-
The general workflow for updating the File Auditing Permissions with PowerShell is as follows:
81-
82-
1. Define the [file system audit rule](/dotnet/api/system.security.accesscontrol.filesystemauditrule.-ctor) to be applied to the file(s).
83-
84-
2. Obtain a file's security descriptor with [Get-Acl](/powershell/module/microsoft.powershell.security/get-acl).
67+
### Use PowerShell to audit VC Runtime usage
8568

86-
3. [Apply the audit rule](/dotnet/api/system.security.accesscontrol.filesystemsecurity.setaccessrule) to the security descriptor.
69+
To update File Auditing Permissions with PowerShell:
8770

88-
4. Apply the updated security descriptor on the original file with [Set-Acl](/powershell/module/microsoft.powershell.security/set-acl).
71+
1. Define the [file system audit rule](/dotnet/api/system.security.accesscontrol.filesystemauditrule.-ctor) to apply to the file(s).
72+
1. Obtain a file's security descriptor with [`Get-Acl`](/powershell/module/microsoft.powershell.security/get-acl).
73+
1. [Apply the audit rule](/dotnet/api/system.security.accesscontrol.filesystemsecurity.setaccessrule) to the security descriptor.
74+
1. Apply the updated security descriptor on the original file with [`Set-Acl`](/powershell/module/microsoft.powershell.security/set-acl).
75+
1. View File Access Auditing Event 4663 records with [`Get-WinEvent`](/powershell/module/microsoft.powershell.diagnostics/get-winevent).
8976

90-
5. View File Access Auditing Event 4663 records with [Get-WinEvent](/powershell/module/microsoft.powershell.diagnostics/get-winevent).
77+
### PowerShell: Audit out-of-support VC Runtime files
9178

92-
### PowerShell: Enable auditing on out-of-support VC Runtime files
79+
The following PowerShell code enables you to audit installed VC Runtime files that are no longer supported.
9380

94-
The following PowerShell section of code will enable usage auditing of the currently installed out-of-support VC Runtime files.
95-
96-
```sh
81+
```powershell
9782
function Get-AuditRuleForFile {
9883
$auditRuleArguments = 'Everyone' <# identity #>,
9984
'ExecuteFile, Traverse' <# fileSystemRights #>,
@@ -138,13 +123,11 @@ ForEach-Object {
138123
}
139124
```
140125

141-
### PowerShell: Viewing file auditing events
142-
143-
PowerShell provides `Get-WinEvent` to obtain event records for various event logs.
126+
### PowerShell: View file audit events
144127

145-
The following PowerShell section of code will list all of the Auditing Event 4663 records over the past 24 hours.
128+
PowerShell provides `Get-WinEvent` to obtain event records for various event logs as shown in the following PowerShell code which lists all of the Auditing Event 4663 records over the past 24 hours:
146129

147-
```sh
130+
```powershell
148131
function Get-AuditEntries {
149132
param (
150133
[Parameter(Mandatory = $true)]
@@ -171,9 +154,7 @@ function Get-AuditEntries {
171154
Get-AuditEntries -oldestTime (Get-Date).AddHours(-24)
172155
```
173156

174-
Example output from the above block of code is as follows:
175-
176-
```
157+
```output
177158
TimeCreated : 11/20/2024 5:00:11 AM
178159
Accesses : Execute/Traverse
179160
SubjectUserSid : \*\*\*\*\*
@@ -193,7 +174,7 @@ ResourceAttributes : S:AI
193174

194175
### Next steps after auditing VC Runtime usage
195176

196-
After you have determined which processes are using the VC Runtime files or which applications have installed the VC Redistributable, uninstall those applications or upgrade them to newer versions that don't depend on unsupported VC Runtimes.
177+
After you have determined which processes are using the VC Runtime files, or which applications have installed the VC Redistributable, uninstall those applications or upgrade them to newer versions that don't depend on unsupported VC Runtimes.
197178

198179
Some Microsoft applications require legacy versions of the VC Runtime. For details, see [Visual C++ Redistributable and runtime libraries FAQ | Microsoft Learn](/lifecycle/faq/visual-c-faq).
199180

@@ -213,6 +194,6 @@ The following is where each version of the VC Runtime is installed.
213194

214195
## See also
215196

216-
[Redistributing Visual C++ Files](redistributing-visual-cpp-files.md)<br/>
217-
[The latest supported Visual C++ downloads](latest-supported-vc-redist.md)<br/>
197+
[Redistributing Visual C++ Files](redistributing-visual-cpp-files.md)\
198+
[The latest supported Visual C++ downloads](latest-supported-vc-redist.md)\
218199
[Lifecycle FAQ - Visual C++ Redistributable and runtime libraries](/lifecycle/faq/visual-c-faq)

0 commit comments

Comments
 (0)