6. DVIA 앱 진단 (1) - Local Data Storage
[목차]
# Local Data Storage 설명
1. Plist
2. UserDefaults
3. Keychain
4. Core Data
5. Webkit Caching (사라진 취약점)
6. Realm
7. Couchbase Lite
8. YapDatabase
9. 요약
- Local Data Storage 항목별 확인 경로
# Local Data Storage 설명
(내부 데이터 저장소)
: iOS 애플리케이션은
임시 데이터와 영구 데이터를 저장하기 위해
로컬 시스템과 상호작용함
: 애플리케이션이 중요한 정보를 임시/영구 형식으로
안전하지 않은 상태로 저장하면(평문형태) 위험이 발생함
(ex. 자동 로그인 기능이 있어 체크하는 경우
내부 저장소에 로그인 정보가 평문 형태로
저장되는 경우가 있음)
: DVIA 앱에서는 여덟 가지 데이터 저장소에 대해 진단함
내부에 저장하기 위한 형식 종류
• XML & Plist
• SQLite files
• Keychain data
• Core data
• NSUserDefaults class
• Temporary File (data cache)
•...

하나씩 살펴본다.
1.Plist

# 실습

0) Plist 항목에 들어간 후 아이디/비번 저장

어딘가에 저장이 되었고
확인해 봐야하는 저장소는
ㄱ. 번들 컨테이너
Applications(User)
/var/containers/Bundle/Application/진단앱
ㄴ. 데이터 컨테이너
/private/var/mobile/Containers/Data
이상 두 군데이다.
1) 번들 컨테이너 확인
Applications(User)
/var/containers/Bundle/Application/
> 수정된 날짜 가장 최신순으로 정렬 (DVIA-v2)

/DVIA-v2.app 접속

Info.plist 파일 더블클릭

내용 확인이 가능하며
Export 또는 복사 후 노트패드로 옮긴 후
아이디/비번이 저장되어 있는지 확인


없음!
2) 데이터 컨테이너 확인
/private/var/mobile/Containers/Data/Application/
: 수정된 날짜 가장 최신순으로 정렬

이후 /Documents 폴더 내
userInfo.plist 를 열어보면

중요정보가 저장되어 있음

실제 진단 시에는
모든 디렉터리를 하나씩 다 확인해야 한다.
2. UserDefaults

# 실습

0) UserDefaults 항목에 들어간 후 데이터 저장

1) 파일 경로 진입
/private/var/mobile/Containers/Data/Application/UUID/Library/Preferences

UserDefaults 역시 Plist 파일로 저장됨
2) 파일 확인

입력 데이터가 평문으로 저장된다!
3. KeyChain

iOS 키체인은 암호화된 데이터베이스!
키체인은 SQLite DB로 구현되어 있음!
보안상 안전해 보이지만 복호화 도구(keychain_dumper)가
존재함
# KeyChain 덤프 실습
– DVIA-v2 앱의 [Local Data Storage > Keychain] 항목에서 테스트 가능
– /private/var/Keychains/keychain-2.db 에 키체인 데이터가 저장됨
– 키체인 항목을 확인하기 위해 keychain_dumper 도구 사용 (키체인은 암호화된 데이터베이스)
– Keychain_dumper 도구를 사용하면 탈옥된 디바이스의 키체인 내용을 덤프 가능
1) keychain_dumper 다운
https://github.com/ptoomey3/Keychain-Dumper/releases

zip 파일 다운
2) 디바이스에 저장
압축 해제하지 않은 상태로
간단히 드래그&드롭으로
디바이스 내 아무곳에나 던져 넣기

> 압축 해제해서 넣어도 상관 없고
ssh로 붙어서 unzip 후 실행 권한 주고
실행!
3) putty 접속 후 unzip > 권한 주고 실행

* 특정 버전에서는 에러 나서 정상 수행 안됨
4) DVIA 키체인 데이터 입력 후 keychain 덤프 실행

# keychain-2.db 파일을 SQLite 브라우저 설치 후 확인해보기
https://sqlitebrowser.org/dl/


4. Core Data

MVC 모델 : 디자인 패턴
Model View Controller

# 실습
1) 데이터 입력

2) Core Data 경로 접근 후 sqlite 파일 export
/private/var/mobile/Containers/Data/Application/BEE532A2-5DCF-40B3-8C8F-DE3D425103FA/Library/Application Support

3) sqlite 브라우저로 확인

코어 데이터는 테이블 이름 앞에
Z가 붙고 데이터를 확인해보면

입력 데이터 평문 노출 확인!
5. Webkit Caching
**Web View는 2020년 4월 이후로 사라진 취약점!**


# 실습
1) 확인 경로
/priavate//var/mobile/Containers/Data/Application/AppUUID/Library/Caches

사진 설명을 입력하세요.

추출 후 확인 가능!

6. Realm
진단 수행 대상이
realm DB를 사용하는 경우
해당 취약점 확인!


# 실습
1) 데이터 입력

2) 파일 확인 후 export
/private/var/mobile/Containers/Data/Application/APPUUID/Documents/file.realm

3) realm studio 설치 후 파일 확인
https://www.mongodb.com/docs/realm-legacy/kr/products/realm-studio.html

데이터가 출력되지 않지만
실무에서 realm DB를 사용하는 경우
realm studio를 통해 이상없이 데이터 확인 가능
7. Couchbase Lite

# 실습
1) 데이터 입력

2) 파일 경로 확인 후 export
/private/var/mobile/Containers/Data/Application/UUID/Library/Application Support


3) SQLite 브라우저로 확인

8. YapDatabase

# 실습
1) 데이터 입력

2. 파일 경로 확인
/private/var/mobile/Containers/Data/Application/APPUUID/Library/Application Support

3. 파일 확인

데이터가 출력되지 않지만
실무에서 yap DB를 사용하는 경우
이상없이 데이터 확인 가능
10. 요약
Local Data Storage 항목별 확인 경로
(1) plist (file.plist 파일 확인)
ㄱ. 번들 컨테이너 - Applications(User) : /var/containers/Bundle/Application/진단앱
ㄴ. 데이터 컨테이너 - /private/var/mobile/Containers/Data
(2) UserDefault (info.plist 파일 확인)
/private/var/mobile/Containers/Data/Application/UUID/Library/Preferences/파일.plist
(3) Keychain (keycahin_dumper로 확인)
/private/var/Keychains/keychain-2.db
keychain_dumper로 확인
(4) CoreData (sqlite 브라우저로 확인)
/private/var/mobile/Containers/Data/Application/APPUUID/Library/Application Support
(5) Webkit Caching (2020년 4월 이후로 사라진 취약점) (sqlite 브라우저로 확인)
/private/var/mobile/Containers/Data/Application/AppUUID/Library/Caches
(6) Realm (realm DB 사용하는 곳이라면 realm studio로 확인 가능)
/private/var/mobile/Containers/Data/Application/APPUUID/Documents/file.realm
(7) Couchbase Lite (sqlite 브라우저로 확인)
/private/var/mobile/Containers/Data/Application/APPUUID/Library/Application Support
(8) YapDatabase.sqlite (yap DB를 사용하는 곳인지 먼저 확인)
/private/var/mobile/Containers/Data/Application/APPUUID/Library/Application Support
# 대응방안

# 내용 및 일부 이미지 출처
: 보안프로젝트 김태영 팀장 iOS 모바일 앱 모의해킹(기초) 강의 PDF