mirror of
https://github.com/bitwarden/server.git
synced 2025-04-17 19:18:16 -05:00
Do not request local hosts or ip addresses
This commit is contained in:
parent
68901437ba
commit
3462613f49
@ -280,6 +280,23 @@ namespace Bit.Icons.Services
|
|||||||
|
|
||||||
private async Task<HttpResponseMessage> GetAsync(Uri uri)
|
private async Task<HttpResponseMessage> GetAsync(Uri uri)
|
||||||
{
|
{
|
||||||
|
if (uri == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent non-http(s) and non-default ports
|
||||||
|
if ((uri.Scheme != "http" && uri.Scheme != "https") || !uri.IsDefaultPort)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent local hosts (localhost, bobs-pc, etc), IPv4, and IPv6 (which contain ":" in the host)
|
||||||
|
if (!uri.Host.Contains(".") || _ipRegex.IsMatch(uri.Host) || uri.Host.Contains(":"))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
using (var message = new HttpRequestMessage())
|
using (var message = new HttpRequestMessage())
|
||||||
{
|
{
|
||||||
message.RequestUri = uri;
|
message.RequestUri = uri;
|
||||||
@ -348,13 +365,6 @@ namespace Bit.Icons.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
Cleanup(response);
|
Cleanup(response);
|
||||||
|
|
||||||
if (location == null || (location.Scheme != "http" && location.Scheme != "https") ||
|
|
||||||
!location.IsDefaultPort)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newResponse = await GetAsync(location);
|
var newResponse = await GetAsync(location);
|
||||||
if (newResponse != null)
|
if (newResponse != null)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user