runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Disallow dotnet.exe to load standalone apps and sxs hostfxr

Open schellap opened this issue 10 years ago • 13 comments

Steps to reproduce

md app & cd app
dotnet new
:: edit to make standalone
dotnet restore
dotnet publish
:: replace app.exe with dotnet.exe, i.e., copy /y dotnet.exe app.exe
app.exe

Expected behavior

Using dotnet.exe should produce an error that it cannot load standalone app. Apphost.exe must be used.

Also make sure dotnet.exe doesn't load sxs hostfxr.dll

Actual behavior

dotnet.exe can still load executables under own name.

Environment data

dotnet --info output:

schellap avatar Jul 16 '16 07:07 schellap

See PR dotnet/core-setup#212 and related to https://github.com/dotnet/cli/issues/3850

schellap avatar Jul 16 '16 07:07 schellap

https://github.com/dotnet/core-setup/blob/cc564bd08a1f76be06b5d4a9bfc6dc0eb593d613/src/corehost/cli/fxr/fx_muxer.cpp#L832

Remove the is_dotnet_host

@gkhanna79

schellap avatar Jul 16 '16 09:07 schellap

@ramarag Assigning this to you as part of you looking into the host signing work.

gkhanna79 avatar Feb 22 '17 21:02 gkhanna79

Please see https://github.com/dotnet/core-setup/pull/711 for links to the proposal of the work and outstanding issues.

gkhanna79 avatar Feb 22 '17 21:02 gkhanna79

@ramarag Was this completed as part of the host-split work?

CC @eerhardt

gkhanna79 avatar Mar 22 '17 04:03 gkhanna79

I don't think this was completed. I just tried it with the latest core-setup build 2.0.0-beta-001820-00, and I was able to use the muxer to invoke a published self-contained app.

For my education - are we sure we want to limit this? What is the reasoning/background/priority of this take-away?

eerhardt avatar Mar 22 '17 16:03 eerhardt

Yes, we need to do this. The plan is that, post the host split work, dotnet.exe will be signed and while apphost.exe won't be. As a result, we do not want dotnet.exe to be copied over, renamed to app.exe and be executed with our signature.

gkhanna79 avatar Mar 22 '17 16:03 gkhanna79

But what about using the muxer located at %PROGRAMFILES%\dotnet\dotnet.exe? We want it to fail for invoking self-contained apps as well?

eerhardt avatar Mar 22 '17 16:03 eerhardt

That muxer is the dotnet.exe which is going to be signed and will only support activation of portable apps. For standalone apps, apphost.exe is going to be published in the app that will be unsigned and can only activate standalone apps.

gkhanna79 avatar Mar 22 '17 16:03 gkhanna79

We want it to fail for invoking self-contained apps as well?

This is the change that host-split work is all about.

gkhanna79 avatar Mar 22 '17 16:03 gkhanna79

I don't think dotnet/core-setup#215 is fully fixed. See the expected behavior section in the bug description. dotnet.exe should not load sxs hostfxr, otherwise someone can simply copy over the exe.

Basically, remove this code:

https://github.com/dotnet/core-setup/blob/master/src/corehost/corehost.cpp#L131

This wasn't removed earlier because CLI didn't start using apphost.

On Friday, March 24, 2017, Rama krishnan Raghupathy < [email protected]> wrote:

Closed dotnet/core-setup#215 https://github.com/dotnet/core-setup/issues/215.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/dotnet/core-setup/issues/215#event-1015183334, or mute the thread https://github.com/notifications/unsubscribe-auth/AKJrs4pCUdv4PkcQFZsbpDgXpimUHiXyks5rpGfIgaJpZM4JN9hn .

schellap avatar Mar 26 '17 04:03 schellap

@schellap did you mean that we should move the check for sxs hostfxr to the start of resolve_fxr_path(const pal::string_t& own_dir) ?

ramarag avatar Mar 26 '17 06:03 ramarag

@ramarag I believe @schellap is requesting that the error is more appropriate:

Using dotnet.exe should produce an error that it cannot load standalone app.

Based upon the current implementation, it will also give the error at https://github.com/dotnet/core-setup/blob/master/src/corehost/corehost.cpp#L164, which is incorrect interms of the expected experience.

gkhanna79 avatar Mar 27 '17 18:03 gkhanna79