콘텐츠로 건너뛰기

[1day] CVE-2026-20614?: Remote Management(ARDAgent): 부적절한 경로 처리 문제에 의한 Root 권한 획득

개요

해당 취약점은 다음 버전에서 패치되었다.

  • macOS Tahoe 26.3
  • macOS Sequoia 15.7.4
  • macOS Sonoma 14.8.4

사실 이게 아니라 CVE-2026-20615일 가능성도 없지 않아있다.

취약점이 패치된 바이너리는 다음과 같다.

/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/MacOS/ARDAgent

발생 원인

따라서 Tahoe 26.2 버전과 26.3 버전에서의 두 바이너리를 Bindiff로 디핑해보았다.

제일 변화가 큰 26.2버전에서의 sub_100048F18, 26.3버전에서의 sub_100048F84 함수 코드를 살펴보자.

  • 26.2 / sub_100048F18
__int64 sub_100048F18()
{
  group *v0; // x0
  int v1; // w7

  sub_100003C38((__int64)"Admin_InitSettings");
  if ( !stat("/Library/Application Support/Apple/Remote Desktop/Shared Settings/Settings.plist", (stat *)&unk_1000E6AB0) )
  {
    chmod("/Library/Application Support/Apple/Remote Desktop/Shared Settings/Settings.plist", 0664u);
    v0 = getgrnam("admin");
    if ( v0 )
    {
      chown("/Library/Application Support/Apple/Remote Desktop/Shared Settings/Settings.plist", 0, v0->gr_gid);
    }
    else
    {
      if ( (unsigned int)((__int64 (*)(void))sub_10009ED28)()
        && os_log_type_enabled((os_log_t)&_os_log_default, OS_LOG_TYPE_ERROR) )
      {
        sub_1000A021C();
      }
      sub_10009F010(
        (int)"/AppleInternal/Library/BuildRoots/4~CB4uugDVALYNFmA7vPXdlfDg9XRwX_mhurALBPo/Library/Caches/com.apple.xbs/So"
             "urces/RemoteDesktop/common/CommonUtilities.m",
        152,
        367,
        (int)"Admin_InitSettings",
        3,
        0,
        "Unable to set group ownership to admin for %s.",
        v1,
        (char)"/Library/Application Support/Apple/Remote Desktop/Shared Settings/Settings.plist");
    }
  }
  return sub_100004EFC("Admin_InitSettings");
}
  • 26.3 / sub_100048F18
__int64 sub_100048F84()
{
  int v0; // w20
  int v2; // w7
  const char *v3; // x8
  int v4; // w19
  int v5; // w0
  int v6; // w7
  char *v7; // x6
  int v8; // w2
  int v9; // w4
  group *v10; // x0
  const char *v12; // [xsp+0h] [xbp-30h]
  uint8_t buf[16]; // [xsp+10h] [xbp-20h] BYREF

  sub_100003C38("Admin_InitSettings");
  if ( !lstat(
          "/Library/Application Support/Apple/Remote Desktop/Shared Settings/Settings.plist",
          (stat *)&unk_1000EAAB0) )
  {
    v0 = word_1000EAAB4 & 0xF000;
    if ( v0 == 40960 || (unsigned __int16)word_1000EAAB6 >= 2u )
    {
      if ( (unsigned int)sub_10009EFC4() && os_log_type_enabled((os_log_t)&_os_log_default, OS_LOG_TYPE_ERROR) )
        sub_1000A05C0(v0 == 40960);
      v3 = "hard link";
      if ( v0 == 40960 )
        v3 = "symlink";
      sub_10009F2AC(
        (int)"/AppleInternal/Library/BuildRoots/4~CG6DugCdiGk2hvwxVloHVl8uLLmzT3VOZ_dq4gs/Library/Caches/com.apple.xbs/So"
             "urces/RemoteDesktop/common/CommonUtilities.m",
        152,
        362,
        (int)"Admin_InitSettings",
        3,
        0,
        "WARNING: suspicious settings file. Attempting to remove %s found at %s",
        v2,
        (char)v3);
      unlink("/Library/Application Support/Apple/Remote Desktop/Shared Settings/Settings.plist");
      v4 = lstat(
             "/Library/Application Support/Apple/Remote Desktop/Shared Settings/Settings.plist",
             (stat *)&unk_1000EAAB0);
      v5 = sub_10009EFC4();
      if ( v4 )
      {
        if ( v5 && os_log_type_enabled((os_log_t)&_os_log_default, OS_LOG_TYPE_DEFAULT) )
        {
          *(_WORD *)buf = 0;
          _os_log_impl(
            (void *)&_mh_execute_header,
            (os_log_t)&_os_log_default,
            OS_LOG_TYPE_DEFAULT,
            "suspicious settings file removed",
            buf,
            2u);
        }
        v7 = "suspicious settings file removed";
        v8 = 369;
        v9 = 7;
        goto LABEL_33;
      }
      if ( v5 && os_log_type_enabled((os_log_t)&_os_log_default, OS_LOG_TYPE_ERROR) )
        sub_1000A0668();
      v7 = "FATAL: unable to remove symlink or hard link";
      v8 = 365;
LABEL_32:
      v9 = 3;
LABEL_33:
      sub_10009F2AC(
        (int)"/AppleInternal/Library/BuildRoots/4~CG6DugCdiGk2hvwxVloHVl8uLLmzT3VOZ_dq4gs/Library/Caches/com.apple.xbs/So"
             "urces/RemoteDesktop/common/CommonUtilities.m",
        152,
        v8,
        (int)"Admin_InitSettings",
        v9,
        0,
        v7,
        v6,
        (char)v12);
      return sub_100004EFC("Admin_InitSettings");
    }
    if ( fchmodat(-2, "/Library/Application Support/Apple/Remote Desktop/Shared Settings/Settings.plist", 0x1B4u, 34816) )
    {
      if ( (unsigned int)sub_10009EFC4() && os_log_type_enabled((os_log_t)&_os_log_default, OS_LOG_TYPE_ERROR) )
        sub_1000A04B8();
      LOBYTE(v12) = *__error();
      v7 = "fchmodat errno %d";
      v8 = 375;
      goto LABEL_32;
    }
    v10 = getgrnam("admin");
    if ( !v10 )
    {
      if ( (unsigned int)sub_10009EFC4() && os_log_type_enabled((os_log_t)&_os_log_default, OS_LOG_TYPE_ERROR) )
        sub_1000A053C();
      v12 = "/Library/Application Support/Apple/Remote Desktop/Shared Settings/Settings.plist";
      v7 = "Unable to set group ownership to admin for %s.";
      v8 = 384;
      goto LABEL_32;
    }
    lchown("/Library/Application Support/Apple/Remote Desktop/Shared Settings/Settings.plist", 0, v10->gr_gid);
  }
  return sub_100004EFC("Admin_InitSettings");
}

취약점을 찾는것은 그렇게 어렵지 않았다.

설명하자면, "/Library/Application Support/Apple/Remote Desktop/Shared Settings/Settings.plist" 경로에 파일이 있을 경우, chmod 함수로 0664로 변화시킨다.

  • 첫 번째 6 (소유자 권한): 4(읽기) + 2(쓰기) = 읽고 수정 가능
  • 두 번째 6 (그룹 권한): 4(읽기) + 2(쓰기) = 읽고 수정 가능
  • 세 번째 4 (나머지 권한): 4(읽기) = 읽기만 가능

그리고 chown 함수로 소유자는 root, 그룹은 admin으로 변화시키며,
중요한 점은 맥에서 일반 사용자인 경우 admin 그룹을 포함하고 있기 때문에 파일 수정이 가능하다.

seo@seos-Virtual-Machine Desktop % id
uid=501(seo) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),701(com.apple.sharepoint.group.1),33(_appstore),98(_lpadmin),100(_lpoperator),204(_developer),250(_analyticsusers),395(com.apple.access_ftp),398(com.apple.access_screensharing),399(com.apple.access_ssh),400(com.apple.access_remote_ae)

악용 가능성

Settings.plist 위치를 제어할 수 있는 비권한 사용자가 그 자리에 심링크나 하드링크를 심어두면,
일반 사용자도 루트 권한 사용자만 수정할 수 있는 특정 파일 수정이 가능해질 것이다.

MacDirtyCow에서 파일 변조를 통해 루트권한을 얻는 아이디어를 떠올랐다.
/etc/pam.d/su 파일 수정만 하면 su 명령어로 비번없이 루트권한을 가질 수 있을 것이다.

Demo

태그: