kcve.ai취약점 정보 · 내 자산 확인

CVE-2022-46169 Unauthenticated Command Injection

인증되지 않은 명령 주입

실제 악용 확인(KEV)

설명

Cacti is an open source platform which provides a robust and extensible operational monitoring and fault management framework for users. In affected versions a command injection vulnerability allows an unauthenticated user to execute arbitrary code on a server running Cacti, if a specific data source was selected for any monitored device. The vulnerability resides in the `remote_agent.php` file. This file can be accessed without authentication. This function retrieves the IP address of the client via `get_client_addr` and resolves this IP address to the corresponding hostname via `gethostbyaddr`. After this, it is verified that an entry within the `poller` table exists, where the hostname corresponds to the resolved hostname. If such an entry was found, the function returns `true` and the client is authorized. This authorization can be bypassed due to the implementation of the `get_client_addr` function. The function is defined in the file `lib/functions.php` and checks serval `$_SERVER` variables to determine the IP address of the client. The variables beginning with `HTTP_` can be arbitrarily set by an attacker. Since there is a default entry in the `poller` table with the hostname of the server running Cacti, an attacker can bypass the authentication e.g. by providing the header `Forwarded-For: <TARGETIP>`. This way the function `get_client_addr` returns the IP address of the server running Cacti. The following call to `gethostbyaddr` will resolve this IP address to the hostname of the server, which will pass the `poller` hostname check because of the default entry. After the authorization of the `remote_agent.php` file is bypassed, an attacker can trigger different actions. One of these actions is called `polldata`. The called function `poll_for_data` retrieves a few request parameters and loads the corresponding `poller_item` entries from the database. If the `action` of a `poller_item` equals `POLLER_ACTION_SCRIPT_PHP`, the function `proc_open` is used to execute a PHP script. The attacker-controlled parameter `$poller_id` is retrieved via the function `get_nfilter_request_var`, which allows arbitrary strings. This variable is later inserted into the string passed to `proc_open`, which leads to a command injection vulnerability. By e.g. providing the `poller_id=;id` the `id` command is executed. In order to reach the vulnerable call, the attacker must provide a `host_id` and `local_data_id`, where the `action` of the corresponding `poller_item` is set to `POLLER_ACTION_SCRIPT_PHP`. Both of these ids (`host_id` and `local_data_id`) can easily be bruteforced. The only requirement is that a `poller_item` with an `POLLER_ACTION_SCRIPT_PHP` action exists. This is very likely on a productive instance because this action is added by some predefined templates like `Device - Uptime` or `Device - Polling Time`. This command injection vulnerability allows an unauthenticated user to execute arbitrary commands if a `poller_item` with the `action` type `POLLER_ACTION_SCRIPT_PHP` (`2`) is configured. The authorization bypass should be prevented by not allowing an attacker to make `get_client_addr` (file `lib/functions.php`) return an arbitrary IP address. This could be done by not honoring the `HTTP_...` `$_SERVER` variables. If these should be kept for compatibility reasons it should at least be prevented to fake the IP address of the server running Cacti. This vulnerability has been addressed in both the 1.2.x and 1.3.x release branches with `1.2.23` being the first release containing the patch.

Cacti는 강력하고 확장 가능한 운영 모니터링 및 오류 관리 프레임워크를 사용자에게 제공하는 오픈 소스 플랫폼입니다. 영향을 받는 버전에서 명령 주입 취약점은 인증되지 않은 사용자가 특정 데이터 소스를 모니터링되는 장치에 대해 선택한 경우 Cacti를 실행하는 서버에서 임의 코드를 실행할 수 있도록 합니다. 이 취약점은 `remote_agent.php` 파일에 있습니다. 이 파일은 인증 없이도 접근할 수 있습니다. 이 함수는 `get_client_addr`를 통해 클라이언트의 IP 주소를 검색하고 이 IP 주소를 `gethostbyaddr`를 통해 해당 호스트명으로 해결합니다. 그 후, `poller` 테이블 내의 엔트리가 존재하는지 확인되며, 여기서 호스트명은 해결된 호스트명에 대응한다. 이러한 항목이 발견되면 함수는 `true`를 반환하고 클라이언트는 권한이 부여됩니다. 이 권한은 `get_client_addr` 함수의 구현으로 인해 우회될 수 있습니다. 이 함수는 `lib/functions.php` 파일에 정의되어 있으며 클라이언트의 IP 주소를 결정하기 위해 serval `$_SERVER` 변수를 검사합니다. 'HTTP_'로 시작하는 변수는 공격자가 임의로 설정할 수 있습니다. Cacti를 실행하는 서버의 호스트명을 가진 `poller` 테이블의 기본 엔트리가 있기 때문에, 공격자는 헤더 `Forwarded-For: <TARGETIP>`를 제공하여 인증의 우회를 할 수 있다. 이렇게 하면 함수 `get_client_addr`가 Cacti를 실행하는 서버의 IP 주소를 반환합니다. 다음 `gethostbyaddr` 호출은 이 IP 주소를 서버의 호스트명으로 해결하며, 이 IP 주소는 기본 항목으로 인해 `poller` 호스트 이름 검사를 통과한다. `remote_agent.php` 파일의 승인이 우회된 후, 공격자는 다른 동작을 트리거할 수 있습니다. 이러한 작업 중 하나는 'polldata'라고합니다. 호출된 함수 `poll_for_data`는 몇 개의 요청 파라미터를 검색하고 데이터베이스로부터 해당 `poller_item` 엔트리를 로드한다. 만약 `poller_item`의 `action`이 `POLER_ACTION_SCRIPT_PHP`와 같다면, 함수 `proc_open`은 PHP 스크립트를 실행하는데 사용됩니다. 공격자가 제어하는 매개변수 `$poller_id`는 임의의 문자열을 허용하는 `get_nfilter_request_var` 함수를 통해 검색됩니다. 이 변수는 나중에 `proc_open`에 전달된 문자열에 삽입되어 명령 주입 취약점으로 이어진다. 예를 들어, `poller_id=;id` 명령을 제공하는 것이 실행된다. 취약한 호출에 도달하기 위해서는 공격자가 `host_id`와 `local_data_id`를 제공해야 하며, 이때 해당 `poller_item`의 `action`은 `POLLER_ACTION_SCRIPT_PHP`로 설정된다. 이 두 ID(`host_id`와 `local_data_id`) 모두 쉽게 무력화될 수 있습니다. 유일한 요구 사항은 `POLLER_ACTION_SCRIPT_PHP` 액션이 있는 `poller_item`이 존재한다는 것입니다. 이 작업은 `Device - Uptime` 또는 `Device - Polling Time`과 같은 미리 정의된 템플릿에 의해 추가되기 때문에 생산적인 인스턴스에서 매우 가능성이 높습니다. 이 명령 주입 취약점은 인증되지 않은 사용자가 `action` 유형 `Poller_ACTION_SCRIPT_PHP` (`2`)가 구성된 `poller_item`을 실행하도록 허용한다. 공격자가 `get_client_addr` (`lib/functions.php` 파일)을 임의의 IP 주소를 반환하지 않도록 하여 권한 부여 우회를 방지해야 합니다. 이것은 `HTTP_...` `$_SERVER` 변수를 존중하지 않음으로써 수행될 수 있다. 만약 호환성을 위해 이러한 것들을 유지해야 한다면, 최소한 Cacti를 실행하는 서버의 IP 주소를 위조하는 것을 막아야 합니다. 이 취약점은 1.2.x 및 1.3.x 릴리스 브랜치에서 해결되었으며 `1.2.23`이 패치를 포함하는 첫 번째 릴리스입니다.

영향 받는 제품 제품 1개

  • Cacti

    cacti

    해결 버전 있음

    영향 받는 버전

    • 1.2.23 미만

    해결 버전

    • 1.2.23 이상

참고 자료 4건

‹ 목록

점검 지원 범위 문의

도입 문의