외로운 Nova의 작업실

insecurebankv2 - 안드로이드 키보드 캐시 이슈 본문

Mobile App Penetesting/Android App Vulnerability

insecurebankv2 - 안드로이드 키보드 캐시 이슈

Nova_ 2023. 5. 21. 13:05

- 취약점 소개

키보드 캐시이슈는 사용자가 중요 정보를 클립보드에 저장하면 제삼자가 이러한 정보를 획득할 수 있는 취약점 입니다. 이 취약점을 악용하면 이전에 중요 정보를 복사하여 인증에 성공한 다른 사용자의 인증 정보를 활용해서 별다른 인증 절차없이 제삼자도 인증에 성공할 수 있습니다. 이러한 취약점이 있는 이유는 클립보드 접근 권한이 따로 없어서 아무나 클립보드에 접근할 수 있기때문입니다.

 

- 취약점 진단

clipper 앱을 다운받아줍니다.

https://m.apkpure.com/kr/clipper-clipboard-manager/org.rojekti.clipper/download/78-APK

이후 nox 에 설치해줍니다. 그런 다음 인시큐어 뱅크에서 계좌번호를 복사해줍니다.

이제 clipper에 가보겠습니다.

계좌번호 복사되었던 것이 클리퍼를 통해 알 수 있습니다. 악성앱은 이러한 정보를 획득한후 공격자의 서버로 보낼 수 있습니다.

 

- 취약점 대응 방안

중요 정보는 마스킹 처리를 통해 사용자가 복사하지 못하도록 하거나 복사할 수 없도록 해야합니다. 이러한 기능은 EditText 뷰에서 android:textIsSelectable 속성에 false 값을 입력하는 것입니다. 관련 소스를 보겠습니다. 아래는 activity_do_transfer.xml 파일입니다.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:stretchColumns="1">

    <TableRow android:layout_marginTop="20dip" >
        <FrameLayout
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:layout_weight="1">

        <TextView android:id="@+id/textView_FromAccount"
            android:layout_width="wrap_content"
            android:text="From Account:"
            android:textSize="20sp"
            android:textColor="#000000"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"></TextView>
        </FrameLayout>
        <FrameLayout
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:layout_weight="1">
        <EditText android:layout_width="fill_parent"
            android:id="@+id/editText_from"
            android:layout_height="wrap_content"
            android:layout_marginLeft="00dip"
            android:layout_marginRight="20dip"
            android:layout_weight="1"
            android:singleLine="true">
        </EditText>
        </FrameLayout>
    </TableRow>

    <TableRow android:layout_marginTop="20dip" >
        <FrameLayout
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:layout_weight="1">

        <TextView android:id="@+id/textView_ToAccount"
            android:layout_width="wrap_content"
            android:text="To Account:"
            android:layout_marginRight="20dip"
            android:textSize="20sp"
            android:textColor="#000000"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"></TextView>
        </FrameLayout>
        <FrameLayout
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:layout_weight="1">
        <EditText android:layout_width="fill_parent"
            android:id="@+id/editText_to"
            android:layout_height="wrap_content"
            android:layout_marginLeft="00dip"
            android:layout_marginRight="20dip"
            android:layout_weight="1"
            android:singleLine="true">
        </EditText>
        </FrameLayout>
    </TableRow>


    <TableRow   android:paddingTop="10px" android:gravity="center"
        android:layout_width="match_parent"
        android:paddingLeft="5dp" android:paddingRight="5dp">
        <Button
            android:id="@+id/button_CreateUser"
            android:text="Get Accounts"
            android:layout_weight="1"
            android:padding="20dp"
            android:textColor="@color/wallet_bright_foreground_holo_dark"
            android:textSize="30sp"
            android:textStyle="bold"
            android:background="@drawable/roundbutton"
            />
    </TableRow>

    <TableRow android:layout_marginTop="20dip" >
        <FrameLayout
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:layout_weight="1">

        <TextView android:id="@+id/textView_Amount"
            android:text="Amount:"
            android:layout_width="wrap_content"
            android:textSize="20sp"
            android:textColor="#000000"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"></TextView>
        </FrameLayout>
        <FrameLayout
            android:layout_height="wrap_content"
            android:layout_width="0dp"
            android:layout_weight="1">
        <EditText
            android:id="@+id/editText_amount"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="00dip"
            android:layout_marginRight="20dip"
            android:layout_weight="1"
            android:singleLine="true">
        </EditText>
        </FrameLayout>
    </TableRow>

    <TableRow android:paddingTop="10px" android:gravity="center"
        android:layout_width="match_parent"
        android:paddingLeft="5dp" android:paddingRight="5dp">
         <Button
            android:id="@+id/button_Transfer"
            android:text="Transfer"
            android:layout_weight="1"
            android:padding="20dp"
            android:textColor="@color/wallet_bright_foreground_holo_dark"
            android:textSize="30sp"
            android:textStyle="bold"
            android:background="@drawable/roundbutton" />
    </TableRow>

    <!--<TableRow android:layout_marginTop="20dip" >-->
        <!--<EditText-->
            <!--android:layout_width="match_parent"-->
            <!--android:layout_height="wrap_content"-->
            <!--android:id="@+id/editText_Phone"-->
            <!--android:padding="20dp"-->
            <!--android:layout_marginLeft="20dip"-->
            <!--android:layout_marginRight="20dip"-->
            <!--android:hint="  Phone Number"-->
            <!--android:textColorHint="#cccccc"-->
            <!--android:background="@android:drawable/editbox_background"-->
            <!--android:drawableLeft="@android:drawable/sym_action_call"-->
            <!--android:layout_weight="1" >-->
        <!--</EditText>-->
    <!--</TableRow>-->

</TableLayout>
    </LinearLayout>

</ScrollView>

예시로 From Account 태그부분을 고쳐보겠습니다.

 <TextView android:id="@+id/textView_FromAccount"
            android:layout_width="wrap_content"
            android:text="From Account:"
            android:textSize="20sp"
            android:textColor="#000000"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"></TextView>

위 코드에다가 editable 속성에 false값을 줍니다.

 <TextView android:id="@+id/textView_FromAccount"
            android:layout_width="wrap_content"
            android:text="From Account:"
            android:textSize="20sp"
            android:textIsSelectable="false"
            android:textColor="#000000"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"></TextView>

이러면 값을 쓰고 지울 수 는 있지만 텍스트를 선택하지못하여 복사할 수 는 없습니다. 

 

중요정보를 꼭 복사해야한다면, 클립보드에 존재하는 데이터를 제한된 시간 동안만 유지하도록 설정하고, 설정한 시간이 지나면 삭제하도록 하는 것이 일반적인 대응 방법입니다.

Comments