본문 바로가기

web/Bug Bounty 리포트 리뷰

Bruteforce protection Bypass - hackerone report #2230915

Report Info

  • URL (보고서 URL) : https://hackerone.com/reports/2230915
  • Title (보고서 제목) : Bruteforce protection in password verification can be bypassed
  • Reported to (신고 대상) : Nextcloud
  • Reported date (보고 날짜) : 2023.10.29
  • Severity (취약 정도) : Medium (5.3)
  • Weakness (취약점) : Improper Restriction of Authentication Attempts
  • Bounty (보상금) : $100

Description

Nextcloud에서는 로그인 창의 bruteforce 어택을 막기 위해 ip기반 차단을 사용한다.

해당 사이트에서 사용자의 ip를 얻을 때 다음 함수를 사용한다. getRemoteAddress()

public function getRemoteAddress(): string {
	$remoteAddress = isset($this->server['REMOTE_ADDR']) ? $this->server['REMOTE_ADDR'] : '';
	$trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
	if (\is_array($trustedProxies) && $this->isTrustedProxy($trustedProxies, $remoteAddress)) {
		$forwardedForHeaders = $this->config->getSystemValue('forwarded_for_headers', [
			'HTTP_X_FORWARDED_FOR'
			// only have one default, so we cannot ship an insecure product out of the box
		]);
		foreach ($forwardedForHeaders as $header) {
			if (isset($this->server[$header])) {
				foreach (explode(',', $this->server[$header]) as $IP) {
					$IP = trim($IP);
					// remove brackets from IPv6 addresses
					if (str_starts_with($IP, '[') && str_ends_with($IP, ']')) {
						$IP = substr($IP, 1, -1);
					}
					if (filter_var($IP, FILTER_VALIDATE_IP) !== false) {
						return $IP;
					}
				}
			}
		}
	}

 

해당 함수에서는 요청에 trusted_proxy가 설정되고

'X-Forwarded-For' 헤더의 값으로 ip가 두 개가 전송되었을 경우 첫 번째 값을 반환한다.

 

사용자가 X-Forwarded-For 헤더의 값을 임의로 조작하여 보내면

Proxy Server는 사용자가 임의로 조작한 값 뒤에 실제 ip 주소 값을 붙인다.

원래라면 마지막에 붙여진 ip를 실제 ip로 인식해야 하지만

위 함수에서는 첫 번째 값을 실제 ip로 인식하여 brute force protection을 우회할 수 있다.

 

예를 들어 5번의 로그인 시도 후에 해당 ip를 5분간 잠그는 로직이 있을 경우,

X-Forwarded-For 헤더를 포함한 요청을 보내어 이 로직을 우회하고 제한 없이 brute force 어택을 수행할 수 있다.


느낀 점

계속 ctf나 wargame의 관점에서만 문제를 풀어서, bruteforce protection 우회에 대한 경우는 생각을 해본 적이 없는데

이 리포트를 보니 real world의 취약점을 찾을 때는 시야를 좀 더 넓여야 하는 것을 느꼈다.