Skip to content

[release/5.0] make async name resolution working from impersonificated context#46897

Merged
Anipik merged 1 commit into
dotnet:release/5.0from
wfurt:50_dns
Jan 14, 2021
Merged

[release/5.0] make async name resolution working from impersonificated context#46897
Anipik merged 1 commit into
dotnet:release/5.0from
wfurt:50_dns

Conversation

@wfurt
Copy link
Copy Markdown
Member

@wfurt wfurt commented Jan 13, 2021

This is port of #45816 to fix #29935
cc: @karelz @samsp-msft

Customer Impact

Asynchronous name resolution and services depending on that (like HttpClient) do not work when running from impersonate context on Windows (ie . user other than owner of the process)
At least 4 customers reported this in #29351
The issue has been present for some time, but is now blocking several large customers from migrating from Framework to .NET Core.

Regression?

Yes. This works in .NET Framework and was broken in 2.1 by dotnet/corefx#26850 when we began supporting async name resolution. As part of this we changed to use GetAddrInfoExW which has a bug in that it does not flow the impersonated token. The fix we made is to fall back to the sync API if it fails.

Testing

Tested manually (we lack infrastructure for automated tests using enterprise authentication)
All existing automated tests are still passing.

Performance

There may be some small impact for cases when running in impersonated context as we first will try async resolution and we will fall back to old method if that fails. However that's an improvement over not working. This seems like a problem with underlying OS and it was brought to attention of responsible team. If this is ever fixed in Windows, this will basically become noop.

Risk

Small. The fix is to retry synchronous API on thread pool if async resolution fails with certain error code.

@wfurt wfurt added the Servicing-consider Issue for next servicing release review label Jan 13, 2021
@wfurt wfurt added this to the 5.0.x milestone Jan 13, 2021
@wfurt wfurt requested review from a team and stephentoub January 13, 2021 01:34
@wfurt wfurt self-assigned this Jan 13, 2021
@ghost ghost added the area-System.Net label Jan 13, 2021
@ghost
Copy link
Copy Markdown

ghost commented Jan 13, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

This is port of #45816 to fix #29935
cc: @karelz @samsp-msft

Customer Impact

This is pretty old issue where asynchronous name resolution and services depending on that (like HttpClient) do not work when running from impersonificated context on Windows e.g. user other than owner of the process.

This is blocking several large customers from migrating from Framework to .NET Core

Regression?

Yes. This works in .NET Framework and got broken 2.1 by dotnet/corefx#26850

Testing

Testing was manual as we lack infrastructure for enterprise authentication.
All automated tests Arte still passing.

Performance

There may be some small impact for cases when running in imperonificated context as we will try async resolution and we will fall back to old method if that fails. This seems like a problem with underlying OS and it was brought to attention of responsible team. If this is ever fixed in Windows, this will basically become noop.

Risk

Small. The fix is to retry synchronous API on thread pool if async resolution fails with certain error code.

Author: wfurt
Assignees: wfurt
Labels:

Servicing-consider, area-System.Net

Milestone: 5.0.x

GetAddrInfoExContext.FreeContext(context);
return null;
}
else if (errorCode != SocketError.IOPending)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we / could we add any tests that validate name resolution in an impersonated context?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not easily as it would require separate account on the machine and password for it. So it is going to be problematic from security prospective. I was thinking about it and it seems like it would be best to address this as part of the "Enterprise authentication testing" project - if we ever decide to fund it. for that, we will need special setup and we will need to work out the password management.

I could also add test conditional on environment variables (e.g. run if user & password is provided via environment) but that will not run during regular CI.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I think this should work. I will explore that and create PR for master.

@leecow leecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Jan 14, 2021
@leecow leecow modified the milestones: 5.0.x, 5.0.3 Jan 14, 2021
@Anipik
Copy link
Copy Markdown
Contributor

Anipik commented Jan 14, 2021

cc @dotnet/ncl for review

Copy link
Copy Markdown
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The product change LGTM. But I would feel better about it, especially for servicing, if we had some tests.

@wfurt
Copy link
Copy Markdown
Member Author

wfurt commented Jan 14, 2021

I will work that out in master @stephentoub and I'll port it here once ready. I think test-only changes are TELL mode, right?

@Anipik
Copy link
Copy Markdown
Contributor

Anipik commented Jan 14, 2021

I will work that out in master @stephentoub and I'll port it here once ready. I think test-only changes are TELL mode, right?

correct

@Anipik Anipik merged commit a179256 into dotnet:release/5.0 Jan 14, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Feb 14, 2021
@wfurt wfurt deleted the 50_dns branch January 7, 2026 20:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Net Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants