-
Notifications
You must be signed in to change notification settings - Fork 328
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
Proposal: Loosen Import Redirection (1809+) restrictions for Desktop Application use #126
Comments
Thanks @riverar . Import Redirection was designed to be applicable for Win32 apps as well; the original implementation was scoped to MSIX (and focused on UWP) as a prioritization / simplification choice, but there is nothing technically stopping it working for other apps. Finding a "home" for the redirection metadata is the biggest missing piece. One caveat: API Redirection does not work for everything; DLLs loaded early in process startup (like NTDLL) cannot be redirected since they are resolved before the redirection tables are loaded. And as currently implemented, redirection does not apply to system binaries; only binaries inside the app's package graph are subject to having their imports redirected. Without a package to consult, we'd need a way to explicitly specify which DLLs to redirect (possibly with wild-cards etc.). Initial response to your questions:
For packaged apps (the current scenario) the answer is "no," since you can't tamper with the manifest or any of the DLLs without breaking the signature. For unpackaged apps, it's a new feature that would need a thorough threat analysis but my initial (brief) thinking is that it's no worse than existing attacks against unpackaged apps (exploiting weak ACLs, etc.).
Should they? Yes, since all DLLs should be signed :-). See below for related questions...
Right now it's considered fatal because it's part of a package where presumably you're in complete control of everything and the redirection is assumed to be mandatory (there are no decent diagnostics for this failure, which something we should improve...). For unpackaged apps, where you might not be in control of everything (eg, due to plugins, different SKU options, etc.) it might be reasonable to have an "optional" flag in the manifest. Is this necessary for a "v1" version, or is it something we could add later if we see the need?
Is there a reason why you call this out specifically? In a vacuum, the answer should be "yes."
It does today for .NET Native (since that uses IATs) but not for .NET Core (or CoreCLR, used for UWP debug builds) which rely on There are a few other things to think about; we would like the community's feedback on them.
|
Just thinking users may want to provide a CHPE Redirection DLL for ARM users. Edge case for sure.
Actually, was thinking of the former case which you covered 👍 I think hooking .NET is out of scope and can be handled with CLR profiling.
What's a "system binary" here? Are we talking about known DLLs (e.g. kernel32), apps (e.g. svchost), both/neither?
Interesting indeed, would need to be wired into
Hm. It's my understanding users could roll out similar behavior via the existing
Hm, on second pass, I don't see a lot of value to be had with signing. Perhaps we toss that out. (Currently listed as a
I don't think that'll ever truly work. Microsoft (e.g. PowerToys), NVIDIA (e.g. nvapi), and others inject all sorts of hooks into processes on the system for all sorts of valid reasons. |
In the current context, "system binary" meant anything not in the package. For unpackaged apps, since nothing is in a package :) the definition would need to be updated (eg, maybe everything in
Redirection doesn't / can't affect the sandbox. It's basically just switching a pointer.
That wouldn't let you do a different remapping though. (I was going to say "that's not documented" but then again none of this is very well documented...).
Anyone who opts into this likely knows what they are doing and will test appropriately; whatever PowerToys is trying to inject isn't that essential (sorry Clint :)). Anyway, good to know you're not specifically interested in it. |
I'm still struggling with the write up on this point so I'll try to restate it and we'll bang away on that.
If I understand correctly, the question is whether users want to redirect APIs at module-granularity or process-granularity. That's an interesting question. So presumably, the metadata could appear as such: <?xml version="1.0" encoding="utf-8"?>
<Identity Name="DesktopApplication1" ... />
<ImportRedirectionTables architecture="x86">
<Module name="app.exe">
<File>ContosoAppRedirections.dll</File>
<File>NorthwindAppRedirections.dll</File>
</Module>
<Module name="dependency.dll">
<File>ADatumAppRedirections.dll</File>
</Module>
</ImportRedirectionTables>
... Module-level granularity sounds like a great stretch goal, I'd consider it a candidate for addition to proposal's scope as a Could item. Administrative question: How/When do we go about revising the proposal as we continue the discussion? |
Shameless bump. Can we bang on this some more @ptorr-msft? |
@ptorr-msft has limited availability right now. @jonwis, is there anyone else who can engage? |
@riverar can you update the original proposal with context from the discussion, including proposed manifest changes (Win32 and MSIX)? Then we can generate internal work-item to track it. I also think you can drop a lot of the "rationale" if you like. |
Updated the proposal and example with what we've discussed so far. I've also pared down the rationale as well. Strongly recommend App Lifecycle #111 (currently in spec loop) at least carefully consider the design of their manifest to accommodate extensibility such as the one proposed here. cc: @ptorr-msft |
Ping to renew interest for 2023+ |
Understand everyone is busy and resources are, well, less than before. @AdamBraden Is your assignment here still valid? Or can we hot potato this to another person? I still think this feature would be very well received! cc: @jonwis |
Thanks for the ping, Rafael. Let me work with @jonwis and others to see if we can find the right owner and find a way to prioritize it. |
Just my yearly reminder that it's always a great time to consider making import redirection available to desktop apps. Completing this feature would look great in your annual reviews too. Here's what you're missing out on:
Happy holidays. 🎅 |
Proposal: Loosen Import Redirection (1809+) restrictions for Desktop Application use
Summary
Import Redirection, a feature introduced in Windows 10 version 1809, enables packaged application developers to "redirect" API imports to other implementations (whether they be private or elsewhere in the OS) without modifications to the application, its dependencies, or any related source code.
Use of this feature is currently restricted to packaged applications. This proposal seeks to loosen this restriction and allow this feature to be used with desktop applications.
Rationale
Allowing unpackaged desktop applications to utilize Import Redirection has several benefits, for example:
Puts the responsibility of loading redirection DLLs and the act of redirecting APIs onto the Windows Loader, eliminating the need for injectors and/or loaders.
Provides a simple (and documented) model for redirecting APIs, bringing a level of order to chaos.
Shortens the hook development/test loop considerably as all the hooking logic is automatically handled by Windows.
Aligns the features more closely with LD_PRELOAD, a popular feature used on other platforms.
Additional rationale was pared out per request but can be found in this item's edit history.
Scope
Important Notes
Recommend syncing with App Lifecycle proposal due to its desktop application manifestation proposal. If implemented, the aforementioned desktop application manfiest could be extended to contain Import Redirection configuration parameters as well.
Sample usage
User creates a msix manifest for a desktop app (fabrikam.exe)
This manifest is saved to disk as
fabrikam.exe.msixmanifest
, located side-by-side withfabrikam.exe
.The text was updated successfully, but these errors were encountered: