r/PowerShell • • Oct 20 '26

Script Sharing EoL Dependency Auditing Script For Vulnerability Remediation Work

I've been doing a bit of vulnerability remediation work this past year or so, and I got tired of 'scream tests' across multiple environments, and was unable to affectively find a way to use something like Dependency Walker in a set-it-and-forget-it kind of way, so I built out the following:

https://github.com/cmcalgher/EoL-Dependency-Auditing

This will set the auditing-side of ACL's on specified .DLL files (configured in the CSV's), and will then allow you to parse through the last 24 hours of the security event log to pull instances of processes that touched/acted on those .DLLs.

When ran on individual machines, it will spit out a CSV with a handful of columns, that can be fed into whatever formatting/reporting you see fit.

Internally at the org I work for, we were pretty much immediately able to write off Visual C++ 2012 as accepted risk on our fully up to date on-prem Exchange SE servers, for example. Would Exchange keep working if we had ripped that off? Would we have to restore corrupted DBs? Not sure, but with how many Exchange processes were using those Visual C++ 2012 .DLL's, I'm glad I didn't have to find out.

The above was inspired by the following Microsoft article, detailing how to audit VC++ usage in coding projects:

https://learn.microsoft.com/en-us/cpp/windows/redist-version-auditing?view=msvc-170

8 Upvotes

11 comments sorted by

2

u/uptimefordays Oct 20 '26

Solid approach, using 4663 auditing to see what’s actually touching EoL VC++/.NET/SQL DLLs before you rip them out beats guessing and hoping nothing breaks. Couple things I’d change if you keep working on it:

  1. dependencies.csv and DependencyPaths.csv encode the same patterns by hand in two different schemas. They’ll drift. One catalog (name, base paths, regex, display string) driving both sides would hold up better.
  2. Script hardcodes c:\temp\... instead of reading the CSVs from $PSScriptRoot so the ones in the repo don’t actually get used until you copy them over manually. Worth fixing.
  3. Enable-DependencyEvents adds an audit rule every run with no check if it’s already there. Run this on a schedule (like the README suggests) and you’ll stack duplicate ACEs on every matching file.

Also: -Action with [ValidateSet(...)] so a typo doesn’t just silently do nothing, and SupportsShouldProcess on the ACL-setting function so people can -WhatIf before it touches prod.

Good idea overall, just needs some hardening.

1

u/the_lazy_sysadmin Oct 20 '26

Thank you for the feedback! Suggestions #1 and #2 are ones that I had already planned to go for when time permits. For suggestion #3 though, that is something I hadn't considered, as I assumed it would just see that the same ACE's were there, and just not apply them, or overwrite them I guess. I will look into all of these though, for sure!

2

u/uptimefordays Oct 20 '26

You’re welcome, I love the idea!

2

u/the_lazy_sysadmin 27d ago

update on this, I went ahead and implemented suggestions 1 and 2. Still working through suggestion 3, and testing the changes. So far so good though, it seems?

Thank you again!

1

u/ILoveAppSec Oct 21 '26

The scream-test grind is real. One thing worth adding to the output: EOL does not mean unpatchable. End of life means upstream stopped shipping fixes, not that a fix cannot be applied, known CVEs can be backported onto the exact EOL version you run. So rather than marking everything EOL as a forced replace, separating truly dead from old-but-still-patchable would help. What does it key the version off, file metadata or the manifest?

1

u/the_lazy_sysadmin Oct 21 '26

I don't want to even begin to think about how many CVE's or vulnerabilities that don't even have CVE's that are out there for Visual C++ 2005... A lot of vulnerability scanning tools don't even list individual CVE's for some of that ancient EoL dependency software. It would make more sense to me to try and sell a client on project work to either harden or replace those systems, as some are so old that the software vendors may not even exist anymore. If a client does not want to pursue either, we write the risk off as accepted, usually documenting that it is tied to a critical business application that has no updates available.

1

u/thehuntzman Oct 21 '26

I'm trying to figure out exactly what you mean here. How do you patch something in a supported way that doesn't receive patches anymore from the vendor? Are you suggesting doing a binary diff or something for newer upstream patches on supported versions to try to patch the EoL version yourself?

3

u/uptimefordays Oct 20 '26

Consider just $auditRule instead of return $auditRule on line 60. They behave identically: return only adds an early exit, and PowerShell emits all uncaptured output either way. Dropping it avoids implying this is the function’s only output. (Classes are the exception, where return is required.)

2

u/RR1904 Oct 20 '26

This is an excellent idea. Thank you for sharing!

1

u/[deleted] Oct 20 '26

[removed] — view removed comment

1

u/the_lazy_sysadmin Oct 20 '26

We have the script set to run every 24 hours, and it will append to a log file, not overwrite it. So it will keep writing to it overtime, and it also includes the date at which it was entered into the event log as well. That way, if you STOP seeing something being touched on ever, you can look into whether or not it was an uninstall or upgrade to a piece of software at around the last time it was seen.