ASP.NET Core Elevation Of Privilege Vulnerability
github.com
github.com
.Net Core is definitely half baked but it is a pretty ambitious undertaking. They're completely re-developing .Net from the ground up to be cross platform, no small task.
> <...>an elevation of privilege vulnerability exists when a ASP.NET Core web application fails to validate web requests correctly.
Fails to mention what "validating a request correctly" means. Recommends to limit allowed Host header values as a mitigation, but does not say what values are safe to accept. Example.com? localhost? 127.0.0.1? covfefe?
[0] https://www.acunetix.com/blog/articles/automated-detection-o...
[1] https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-0787
Click one link, the first one in the main page text, scroll down, and you're here (1)
> Q: Are there any more details on what "fails to validate web requests correctly" means and/or a PoC for this?
> A: No. We don’t publish more details or PoCs.
This seems entirely deliberate and unsurprising on day 1 when few have applied the patch yet, and is therefore not "awful".
1) https://github.com/aspnet/Home/issues/2954#issuecomment-3728...
There's slightly more info here, which makes it sound somewhat less severe:
https://securitytracker.com/id/1040525
"ASP.NET Kestrel Web Application HTML Injection Flaw Lets Remote Users Reset the Target User's Password
A vulnerability was reported in ASP.NET. A remote user can inject HTML to reset the target user's password.
Kestrel web applications do not properly validate web input. A remote user can supply a specially crafted request to inject HTML and cause a 'password reset' email to be sent to the target user. The password reset may be triggered when the target user opens the email."
(edit) So I guess the host header somehow ends up in the password reset email without any filtering/escaping? Maybe you could abuse that by turning the password reset link into an <img> link to a server you control, with the password reset secret at the end. Once the image is loaded you get the password reset secret and can use that to get into the account. Something like that?
Not sure if I would classify that as a Kestrel issue.
[1]: http://www.skeletonscribe.net/2013/05/practical-http-host-he....
This is quite alarming. Does this mean I'll have to continuously upgrade my applications (and all third-party libraries) to the newest .NET Core version to receive security updates? Upgrading from 1.1 to 2.0, when you reference dozens of external packages isn't too pleasant, even for small applications.
Here is the current version of the docs that mention this: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/se...
The warning was repeated all over the place - you can search the web dig through the git history of the docs and see the warning to use a reverse proxy all over.
They probably should have made Kestrel complain loudly if it detected it was exposed and "force" everyone to be successful, but it's only partially their fault if people ignored the documentation.
In the past they had vulnerabilities covered in multiple versions at the same time. But keep in mind LTS support versions. Some of the 1.x will soon run out of their lifecycle (when I remember right).
Just had a very quick look over the relevant code bits... it does look like it would just be an attacker-specified domain.. i.e. the following code is used for the default (new mvc app) uses:
var callbackUrl = Url.ResetPasswordCallbackLink(user.Id, code, Request.Scheme);
await _emailSender.SendEmailAsync(model.Email, "Reset Password",
$"Please reset your password by clicking here: <a href='{callbackUrl}'>link</a>");
which alllll the way down buried within the mvc or kestrel codebase (i forget which) is plucked directly from the host header. As kestrel listens globally, then i'd guess that the attacker would just sub out the regular domain with mynastydomain.com, and it would send someone an email with mynastydomain.com/reset?link=xxx. To fix this as they've recommended you'd wanna validate the domain via middleware (or just regex the password reset link before sending it out) or just not use the inbuilt authentication functionality/helpers whatsoever to reset passwords (and/or hardcode your domain).looking at the actual code fix itself, is quite interesting. Apparently the following special characters are allowed in valid domains:
// Matches Http.Sys
// Matches RFC 3986 except "*" / "+" / "," / ";" / "=" and "%" HEXDIG HEXDIG which are not allowed by Http.Sys
HostCharValidity['!'] = true;
HostCharValidity['$'] = true;
HostCharValidity['&'] = true;
HostCharValidity['\''] = true;
HostCharValidity['('] = true;
HostCharValidity[')'] = true;
HostCharValidity['-'] = true;
HostCharValidity['.'] = true;
HostCharValidity['_'] = true;
HostCharValidity['~'] = true;
looking at the link generated, it is possible to close off the <a href='{callbackUrl}' by adding in a single quote on a specified domain (even after the fix)... before the fix i'd imagine you could cause potential XSS or something as "=" would have been valid, meaning that you can add an event handler. All of these would get stripped off anyway from all major email clients so ¯\_(ツ)_/¯* edit * reason i wrote this and went into so much detail is that looking at the (imo pretty poor) advisory, i'd be vulnerable to this. Whereas in reality i am not. Others using their own authentication schemes or hard-coding values everywhere (as opposed to using the helper functions to generate URLs) would also be ok, i think.