본문 바로가기

Security Study/Android

[InsecureBankv2] 루팅 탐지 및 우회

취약점 개요

취약점 설명

안드로이드 애플리케이션은 보안상의 이유로 루트 권한을 막아 놓았다. 루팅 탐지 및 우회는 루트 탐지를 우회하는 취약점을 의미한다.

보안 위협

관리자 권한을 획득할 수 있으며, 민감한 정보에 접근할 수 있다.

발생 위치

/system/bin/su, /system/xbin/su, /system/app/superuser.apk, /data/data/com.noshufou/android.su

 

취약점 진단 과정

Step 1) 루팅 확인

루팅 확인이 필수적인 금융 및 게임 애플리케이션에서는 다음의 4가지 항목을 필수적으로 점검한다.

/system/bin/su
/system/xbin/su
/system/app/superuser.apk
/data/data/com.noshufou/android.su

로그인을 하면 하단에 “Rooted Device!!” 문구가 표시 되는데, 이는 현재의 기기가 루팅되었음을 뜻한다.

Step 2) PostLogin.java 소스 코드 확인

아래의 코드는 루팅을 확인하는 부분으로, 2개의 로직으로 구성되어 있다.

doesSUexist() 함수는 su 프로세스가 존재하는지 확인하고, showRootStatus(), doesSuperuserApkExist() 함수는 /system/app/Superuser.apk 파일이 존재하는지 확인한다.

doesSuperuserApkExist() 함수의 if문을 확인해 보면, Superuser.apk 파일의 존재 여부에 따라 루팅 여부를 판단하는 것을 확인할 수 있다.

void showRootStatus() {

    boolean isrooted = doesSuperuserApkExist("/system/app/Superuser.apk")||doesSUexist();
    if(isrooted==true)
    {
        root_status.setText("Rooted Device!!");
    }
    else
    {
        root_status.setText("Device not Rooted!!");
    }

}

private boolean doesSUexist() {

    Process process = null;
    try {
        process = Runtime.getRuntime().exec(new String[] { "/system/bin/which", "su" });
        BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
        if (in.readLine() != null) return true;
        return false;
    } catch (Throwable t) {
        return false;
    } finally {
        if (process != null) process.destroy();
    }

}

private boolean doesSuperuserApkExist(String s) {

    File rootFile = new File("/system/app/Superuser.apk");
    Boolean doesexist = rootFile.exists();
    if(doesexist == true)
    {
        return(true);
    }
    else
    {
        return(false);
    }

}

Step 3) 디바이스 루팅 확인

su 명령어로 확인

루팅된 디바이스를 사용하면 오류가 발생하지 않는다.

루팅되지 않은 디바이스를 사용하면 오류가 발생한다.

/system/bin/su, /system/xbin/su 파일 확인

su 파일이 존재하므로 루팅된 디바이스임을 확인할 수 있다.

/system/app/superuser.apk 파일 확인

Nox player에는 superuser.apk 파일이 없는 것으로 확인된다.

Step 4) 루팅 우회

/system 디렉터리에 존재하는 파일 수정하기 위해선 only-read 상태로 마운트되므로 시스템 파일을 수정할 수 없으므로, 다시 마운트 해야 한다.

su 명령어로 관리자 권한을 상승 시킨 후, 리마운트를 진행하면 마운트 상태에서 w 권한을 추가해 파일을 수정할 수 있다.

su
mount -o remount,rw /system
mv /system/xbin/su /system/xbin/sx

루팅이 해제되었음을 확인할 수 있다.

 

대응 방안

  • 루팅된 디바이스로 접근하면 경고창을 띄우고 애플리케이션을 사용할 수 없도록 즉시 종료하도록 한다.
  • 무결성 검증, 디컴파일 방지 솔루션 등을 적용하여 소스 코드 노출 및 파일 변경을 방지하도록 한다.
반응형