# iOS Local Storage Checks

The user password can be found unencrypted in an Sqlite Write-Ahead Log in the applications Data Container on the device:

```normal
/var/mobile/Containers/Data/Application/[UUID]/Documents/MyAPPLICATION.sqlite-wal
```

Based on the frame history in the Write-Ahead Log, the password is inserted temporarily in the `ZUSER` table in plaintext and later gets overwritten by a bcrypt hashed password, but the WAL journal keeps the original commit until it grows to over 1000 pages (which could take some time, depending on user activity) or the user logs out of the application, which deletes data from the database, but until then the password can be read from this file.

Although mandatory 3rd party application sandboxing prevents applications from directly accessing other applications containers, the contents of that directory can be read by the following methods:

* jailbreaking the device
* connecting the phone to a computer and downloading the applications Documents folder with `ios-deploy --download=/Documents --bundle_id com.my.app --to ./myAPP_dumps`

### Remediation:

Always use the iOS Keychain to store sensitive information such as credentials.

Review the code to find where it sets this plaintext password and remove the offending code.

{% embed url="<https://developer.apple.com/documentation/security/keychain_services/keychain_items/using_the_keychain_to_manage_user_secrets>" %}

## Downloading iOS Local Storage Directory of Application Package from Device to Local Machine

We use `-r` for recursively dowloading the whole directory.

```
  scp -r root@192.168.1.18:/private/var/mobile/Containers/Data/Application/<IDENTIFIER> /home/kali/Downloads

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.smhuda.com/pentesting/application-security/mobile-security/ios/ios-local-storage-checks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
