mirror of
https://github.com/webmin/webmin.git
synced 2026-08-23 07:20:28 +01:00
Compare commits
1 Commits
2.652
...
dev/req-tr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
463fcea730 |
25
miniserv.pl
25
miniserv.pl
@@ -1542,16 +1542,25 @@ if ($headerhost) {
|
|||||||
$headerhost = undef if (!&check_ipaddress($headerhost) &&
|
$headerhost = undef if (!&check_ipaddress($headerhost) &&
|
||||||
!&check_ip6address($headerhost));
|
!&check_ip6address($headerhost));
|
||||||
}
|
}
|
||||||
# If trusted_proxies is configured, header-supplied client IP and SSL
|
# If trusted_proxies is configured, header-supplied client IP is only
|
||||||
# client info are only honored when the direct TCP peer is in that list.
|
# honored when the direct TCP peer is in that list. Proxied SSL client
|
||||||
# Otherwise drop them so an attacker reaching miniserv directly cannot
|
# cert headers carry authentication identity, so only honor those from
|
||||||
# spoof X-Forwarded-For or X-SSL-Client-* to bypass auth.
|
# an explicitly trusted proxy.
|
||||||
if ($config{'trust_real_ip'} && $config{'trusted_proxies'} ne '' &&
|
my @trusted_proxies = split(/\s+/, $config{'trusted_proxies'} || "");
|
||||||
!&ip_match($acptip, $localip,
|
my $trusted_proxy = @trusted_proxies &&
|
||||||
split(/\s+/, $config{'trusted_proxies'}))) {
|
&ip_match($acptip, $localip, @trusted_proxies);
|
||||||
|
my $trust_ssl_client_headers = $config{'trust_real_ip'} &&
|
||||||
|
!$config{'no_trust_ssl'} && $trusted_proxy;
|
||||||
|
if ($config{'trust_real_ip'} && @trusted_proxies && !$trusted_proxy) {
|
||||||
print DEBUG "handle_request: peer $acptip not in trusted_proxies; ".
|
print DEBUG "handle_request: peer $acptip not in trusted_proxies; ".
|
||||||
"ignoring forwarding and SSL client headers\n";
|
"ignoring forwarding headers\n";
|
||||||
$headerhost = undef;
|
$headerhost = undef;
|
||||||
|
}
|
||||||
|
if (!$trust_ssl_client_headers) {
|
||||||
|
print DEBUG "handle_request: ignoring SSL client headers from ".
|
||||||
|
"peer $acptip\n"
|
||||||
|
if ($header{'x-ssl-client-dn'} ||
|
||||||
|
$header{'x-ssl-client-verify'});
|
||||||
delete $header{'x-ssl-client-dn'};
|
delete $header{'x-ssl-client-dn'};
|
||||||
delete $header{'x-ssl-client-verify'};
|
delete $header{'x-ssl-client-verify'};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,8 +60,12 @@ if (!-r $first_install_file || $miniserv{'login_script'} eq $record_login_cmd) {
|
|||||||
$miniserv{'failed_script'} = $record_failed_cmd;
|
$miniserv{'failed_script'} = $record_failed_cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Disable trusting SSL certs unless already enabled
|
# Disable trusting SSL certs unless already enabled. Legacy configs with
|
||||||
if (!$miniserv{'trust_real_ip'} && !defined($miniserv{'no_trust_ssl'})) {
|
# trust_real_ip but no trusted proxy cannot safely authenticate from
|
||||||
|
# proxied SSL client cert headers.
|
||||||
|
my @trusted_proxies = split(/\s+/, $miniserv{'trusted_proxies'} || "");
|
||||||
|
if ((!$miniserv{'trust_real_ip'} || !@trusted_proxies) &&
|
||||||
|
!defined($miniserv{'no_trust_ssl'})) {
|
||||||
$miniserv{'no_trust_ssl'} = 1;
|
$miniserv{'no_trust_ssl'} = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user