runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Single file bundle extraction fails on systems with on-access antivirus protection

Open dasMulli opened this issue 7 years ago • 10 comments

Steps to reproduce

(Win10 1903 x64)

  • Use a system with McAffee endpoint protection with enabled on-access scanning.
  • Run a single-file exe (preview 6)

Expected behavior

App runs.

Actual behavior

>testcons.exe
Failure processing application bundle.
Failed to commit extracted to files to directory [C:\Users\ullrimar\AppData\Local\Temp\.net\testcons\s33gpzrx.fiq]
A fatal error was encountered. Could not extract contents of the bundle

Workarounds

  1. Disable on-access scanning (bad. souldn't be required to run .NET applications)

  2. Run the app multiple times until it works - apparrently McAffee recognizes things it already scanned and eventually will not block the file/directory access.

  3. Not use single-file publishing 😢

Environment data

Windows 10 1903, x64 .NET Core 3.0 Preview 6

dasMulli avatar Jul 04 '19 12:07 dasMulli

@swaroop-sridhar my suspicion is that renaming a directory after writing a bunch of dlls and native executables to it doesn't work well on windows+corporate AV 😢

dasMulli avatar Jul 05 '19 08:07 dasMulli

You could try procmon (Process Monitor) to see exactly what file access is going on and maybe get some more info. (I did this to diagnose some build flakiness that sounds similar to this: part of our toolset likes to write an EXE to disk then immediately move it, and Windows Defender ATP holds it open and causes a failure. I ended up adding retries.)

dagood avatar Jul 05 '19 15:07 dagood

@dasMulli could you please email me (contact info should be in my profile on GitHub)? We're trying to workout the right fix, and it would be great to get a validation on the system where it fails.

vitek-karas avatar Jul 09 '19 21:07 vitek-karas

Sent mail

dasMulli avatar Jul 10 '19 06:07 dasMulli

Candidate fix has been merge here: https://github.com/dotnet/core-setup/pull/7135

vitek-karas avatar Jul 10 '19 08:07 vitek-karas

Fixed with dotnet/core-setup#7135

AaronRobinsonMSFT avatar Jul 10 '19 15:07 AaronRobinsonMSFT

Validated the fix on company machines together with @ThomasBergholdWieser and @mobilewhatelse with a test app provided by @vitek-karas. Thanks for the quick fix!

dasMulli avatar Jul 11 '19 06:07 dasMulli

I am still getting this error on 3.0 preview 7. "Failure processing application bundle. Failed to commit extracted to files to directory" If I run it a couple more times then it works. This is being run from a corporate network with antivirus protection enabled.

EDIT: Apologies I just checked and this fix is not in 3.0 preview 7. I will wait until it's in the next .NET core release :)

AhmadChaker avatar Jul 30 '19 01:07 AhmadChaker

@AhmadChaker Can you give us some more details on the type of anti-virus being used? Is this the official preview 7? Can you please run the following command from a developer command prompt on the applications exe: dumpbin /headers <application_exe> This should give us enough details to determine exactly what build is being used.

cc @vitek-karas @jeffschwMSFT @swaroop-sridhar

AaronRobinsonMSFT avatar Jul 30 '19 04:07 AaronRobinsonMSFT

Doesn't seem to be in preview7 as it didn't work when i tried yesterday, figured it didn't make it in - same error message and failing step as before. I worked around by registering the exe names of my projects as exclusions in the AV.

trace file reads

--- Invoked apphost [version: 3.0.0-preview7-27912-14, commit hash: 4da6ee6450e4dd43ef8c05925fec22d9ac3892f3]

And the retry code is not yet in the repo at that commit hash.

Headers Microsoft (R) COFF/PE Dumper Version 14.23.27911.0 Copyright (C) Microsoft Corporation. All rights reserved.

Dump of file HelloWorld.exe

PE signature found

File Type: EXECUTABLE IMAGE

FILE HEADER VALUES 8664 machine (x64) 6 number of sections 5D29536D time date stamp Sat Jul 13 05:43:41 2019 0 file pointer to symbol table 0 number of symbols F0 size of optional header 22 characteristics Executable Application can handle large (>2GB) addresses

OPTIONAL HEADER VALUES 20B magic # (PE32+) 14.16 linker version 15800 size of code 11600 size of initialized data 0 size of uninitialized data 12130 entry point (0000000140012130) 1000 base of code 140000000 image base (0000000140000000 to 000000014002BFFF) 1000 section alignment 200 file alignment 6.00 operating system version 0.00 image version 6.00 subsystem version 0 Win32 version 2C000 size of image 400 size of headers 0 checksum 3 subsystem (Windows CUI) C160 DLL characteristics High Entropy Virtual Addresses Dynamic base NX compatible Control Flow Guard Terminal Server Aware 180000 size of stack reserve 1000 size of stack commit 100000 size of heap reserve 1000 size of heap commit 0 loader flags 10 number of directories 0 [ 0] RVA [size] of Export Directory 24314 [ F0] RVA [size] of Import Directory 2A000 [ 560] RVA [size] of Resource Directory 28000 [ 14D0] RVA [size] of Exception Directory 0 [ 0] RVA [size] of Certificates Directory 2B000 [ 6D8] RVA [size] of Base Relocation Directory 1FE90 [ 54] RVA [size] of Debug Directory 0 [ 0] RVA [size] of Architecture Directory 0 [ 0] RVA [size] of Global Pointer Directory 1FFF0 [ 28] RVA [size] of Thread Storage Directory 1FEF0 [ 100] RVA [size] of Load Configuration Directory 0 [ 0] RVA [size] of Bound Import Directory 17000 [ 430] RVA [size] of Import Address Table Directory 0 [ 0] RVA [size] of Delay Import Directory 0 [ 0] RVA [size] of COM Descriptor Directory 0 [ 0] RVA [size] of Reserved Directory

SECTION HEADER dotnet/core-setup#1 .text name 1560C virtual size 1000 virtual address (0000000140001000 to 000000014001660B) 15800 size of raw data 400 file pointer to raw data (00000400 to 00015BFF) 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers 60000020 flags Code Execute Read

SECTION HEADER dotnet/core-setup#2 .rdata name E202 virtual size 17000 virtual address (0000000140017000 to 0000000140025201) E400 size of raw data 15C00 file pointer to raw data (00015C00 to 00023FFF) 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers 40000040 flags Initialized Data Read Only

Debug Directories

    Time Type        Size      RVA  Pointer
-------- ------- -------- -------- --------
5D29536D cv            72 000211C4    1FDC4    Format: RSDS, {89CC24AF-982E-4D83-B5A2-FEF0CB4828B1}, 1, F:\workspace.2\_work\1\s\bin\obj\win-x64.Release\corehost\cli\apphost\Release\apphost.pdb
5D29536D feat          14 00021238    1FE38    Counts: Pre-VC++ 11.00=0, C/C++=103, /GS=103, /sdl=0, guardN=103
5D29536D coffgrp      374 0002124C    1FE4C

SECTION HEADER dotnet/core-setup#3 .data name 19E8 virtual size 26000 virtual address (0000000140026000 to 00000001400279E7) E00 size of raw data 24000 file pointer to raw data (00024000 to 00024DFF) 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers C0000040 flags Initialized Data Read Write

SECTION HEADER dotnet/core-setup#4 .pdata name 14D0 virtual size 28000 virtual address (0000000140028000 to 00000001400294CF) 1600 size of raw data 24E00 file pointer to raw data (00024E00 to 000263FF) 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers 40000040 flags Initialized Data Read Only

SECTION HEADER dotnet/core-setup#5 .rsrc name 560 virtual size 2A000 virtual address (000000014002A000 to 000000014002A55F) 600 size of raw data 26400 file pointer to raw data (00026400 to 000269FF) 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers 40000040 flags Initialized Data Read Only

SECTION HEADER dotnet/core-setup#6 .reloc name 6D8 virtual size 2B000 virtual address (000000014002B000 to 000000014002B6D7) 800 size of raw data 26A00 file pointer to raw data (00026A00 to 000271FF) 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers 42000040 flags Initialized Data Discardable Read Only

Summary

    2000 .data
    2000 .pdata
    F000 .rdata
    1000 .reloc
    1000 .rsrc
   16000 .text

dasMulli avatar Jul 30 '19 07:07 dasMulli