System.AccessViolationException: Attempted to read or write protected memory
Describe the bug When I want execute scan on my machines in ansible pipeline I have 50:50 to run it without this issue. For now i fixed this issue bu retrying 5 times whole command until it's successful ( when first attempt fail second is generally finished successfully). But it is not clear solution.
To Reproduce Steps to reproduce the behavior: C:/Tools/asa/asa.exe collect --all --runid first-scan
System Configuration (please complete the following information):
- OS: Windows
- OS Version: Windows server 2016 build 1607
- Application Version: v.2.1.62+ab6efca434
- CLI or GUI: CLI
CMD line output
"cmd": "C:/Tools/asa/asa.exe collect --all --runid first-scan",
"delta": "0:05:08.453043",
"end": "2020-01-28 12:13:17.200622",
"msg": "non-zero return code",
"rc": 1,
"start": "2020-01-28 12:08:08.747578",
"stderr": "Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.\n
at AttackSurfaceAnalyzer.Utils.NativeMethods.WinVerifyTrust(IntPtr, System.Guid, WinTrustData)\n
at AttackSurfaceAnalyzer.Utils.NativeMethods.WinVerifyTrust(IntPtr, System.Guid, WinTrustData)\n
at AttackSurfaceAnalyzer.Utils.NativeMethods.VerifyEmbeddedSignature(System.String)\n
at AttackSurfaceAnalyzer.Collectors.FileSystemCollector.FilePathToFileSystemObject(System.String, Boolean, Boolean)\n
at AttackSurfaceAnalyzer.Collectors.FileSystemCollector+<>c__DisplayClass8_0.<ExecuteInternal>b__0(System.String)\n
at System.Threading.Tasks.Parallel+<>c__DisplayClass44_0`2[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<PartitionerForEachWorker>b__1(System.Collections.IEnumerator ByRef, Int32, Boolean ByRef)\n
at System.Threading.Tasks.TaskReplicator+Replica.Execute()\n
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)\n
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)\n
at System.Threading.ThreadPoolWorkQueue.Dispatch()", "stderr_lines": ["Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.", "
at AttackSurfaceAnalyzer.Utils.NativeMethods.WinVerifyTrust(IntPtr, System.Guid, WinTrustData)", "
at AttackSurfaceAnalyzer.Utils.NativeMethods.WinVerifyTrust(IntPtr, System.Guid, WinTrustData)", "
at AttackSurfaceAnalyzer.Utils.NativeMethods.VerifyEmbeddedSignature(System.String)", "
at AttackSurfaceAnalyzer.Collectors.FileSystemCollector.FilePathToFileSystemObject(System.String, Boolean, Boolean)", "
at AttackSurfaceAnalyzer.Collectors.FileSystemCollector+<>c__DisplayClass8_0.<ExecuteInternal>b__0(System.String)", "
at System.Threading.Tasks.Parallel+<>c__DisplayClass44_0`2[[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<PartitionerForEachWorker>b__1(System.Collections.IEnumerator ByRef, Int32, Boolean ByRef)", "
at System.Threading.Tasks.TaskReplicator+Replica.Execute()", "
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)", "
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)", "
at System.Threading.ThreadPoolWorkQueue.Dispatch()"],
"stdout_lines": [
"[07:08:09 INF] AttackSurfaceAnalyzer v.2.1.62+ab6efca434"
"[07:08:10 INF] This application collects usage data to help us improve Attack Surface Analyzer."
"[07:08:10 INF] For our privacy policy visit: https://github.com/Microsoft/AttackSurfaceAnalyzer/blob/master/PRIVACY.md."
"[07:08:10 INF] To disable telemetry run Attack Surface Analyzer with these arguments: 'config --telemetry-opt-out true'."
"[07:08:11 INF] Loaded filters: Embedded"
"[07:08:11 INF] Begin first-scan."
"[07:08:11 INF] Starting 9 Collectors."
"[07:08:11 INF] Starting FileSystemCollector."
"[07:08:11 INF] Scanning root C:\\"
]}```
Thanks for your report. I've seen this before but haven't been able to reproduce it, as this exception should already be being captured on line 424 of NativeMethods.cs.
Could you try running "asa.exe collect -f --parallelization false --verbose"? That should print out each filename as it is being scanned so we can at least identify which file it is failing on.