Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: Changes to the rules by other programs #34

Closed
falahati opened this issue Nov 14, 2019 · 2 comments
Closed

Q: Changes to the rules by other programs #34

falahati opened this issue Nov 14, 2019 · 2 comments
Assignees

Comments

@falahati
Copy link
Owner

falahati commented Nov 14, 2019

WindowsFirewallHelper caches the underlying COM object and since Windows Firewall COM API does no reflects updates fast enough you can, in theory, get a result that is outdated. How rarely this happens depends on the underlying Firewall API and therefore it might be hard to reproduce.

#32 might be used to detect such changes in the future.

Workaround
Since with version 2 of this library, it is possible to create multiple instances of any IFirewall implemented class, creating a new instance should, in theory, solve this problem by creating a new COM object.

Vista+:
var rules = new FirewallWAS().Rules.ToArray()

XP+:
var rules = new FirewallLegacy().Rules.ToArray()

Doing so leaves the COM object lifetime management to the user of the library.
There is no way to do this with version 1 of this library since these constructors are marked as internal.

Solution
Should add a new IFirewall.Refresh() or IFirewall.Reload() method to clear the COM cache of an instance. This is especially handy when using the FirewallManager class.

@falahati falahati self-assigned this Nov 14, 2019
@falahati
Copy link
Owner Author

microsoft/AttackSurfaceAnalyzer#306 might also be related to this. Not sure tho.

@falahati
Copy link
Owner Author

falahati commented Aug 4, 2021

IFirewall.Reload() added

@falahati falahati closed this as completed Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant