The structural lesson, which is the one worth taking away after the immediate scramble: this is an inventory problem, and you are solving it under time pressure because the inventory did not exist.
What makes the next one easier:
- Generate a software bill of materials for anything you build or deploy. Most build tools can emit a dependency list; store it with the artefact.
- Prefer distribution packages over vendor bundles where you have the choice, precisely so the package manager can answer questions like this one.
- Record what each server runs, at the application level, somewhere queryable. When the next advisory lands, the first question is always "where do we run this", and an hour of grep is a bad answer.
None of this helps today. All of it converts a two-day fire drill into a ten-minute query next time.