> For the complete documentation index, see [llms.txt](https://riteshs4hu.gitbook.io/infosec-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://riteshs4hu.gitbook.io/infosec-notes/android-appsec/fundamenteals/file-system-and-permissions.md).

# File System & Permissions

## **Android file system** structure <a href="#id-7d96" id="id-7d96"></a>

The Android file system structure can vary slightly depending on the device manufacturer and Android version, but it generally follows a similar layout.

* **Root Directory (/):** The top-level directory that contains all other directories and files.
* **/boot:** This folder contains files related to the Android device's boot process, including the bootloader and kernel image.&#x20;
* **/system:** This directory contains the Android operating system files, including the **system** **libraries** and **system apps**. It is read-only on most devices to prevent the modification of system-critical files.
* **/data:** Contains user data, app data, and installed apps. Each app typically has its own directory under **/data/data**, where it stores its private data. User-generated content like photos, videos, and documents is also stored here.
* **/cache:** Holds temporary files and cached data used by the system and apps. These files can be safely deleted to free up storage space, but doing so may affect the performance of certain apps until the cache is regenerated.
* **/misc:** This partition contains system settings like carrier or region IDs, USB configurations, and hardware settings. It’s crucial for device features and can cause malfunctions if corrupted or missing. Recovery also uses it to communicate with the bootloader, store information during updates, and manage the boot process.
* **/sdcard:** The */sdcard* partition, also known as the internal storage or primary storage, is where user-generated content and downloaded files are typically stored on an Android device. This includes items such as photos, videos, music, documents, and app data that users create or save.

## Common Folders in Android Internal Storage <a href="#id-710f" id="id-710f"></a>

The internal storage `/sdcard/`  Android device contains several common folders used for storing various types of data.&#x20;

* **Android:** The Android folder contains system files and data related to the Android operating system, including system settings and cached data.
* **DCIM (Digital Camera Images):** The DCIM folder is where photos and videos captured by the device’s camera are typically stored. It stands for “Digital Camera Images.”
* **Downloads:** The Downloads folder is used to store files that have been downloaded from the internet or received through apps like email or messaging.
* **Movies:** Some devices have a folder specifically for storing movie or video files.
* **Music:** Similar to the Movies folder, the Music folder is used for storing music files.
* **Pictures:** In addition to the DCIM folder, some devices have a separate Pictures folder for storing images.

## App Sandboxing and the Permission Model <a href="#c1de" id="c1de"></a>

**Sandboxing** is a **security technique** in which each app is run in an **isolated environment,** keeping it separate from other apps and system resources. This helps ***protect an app’s data and processes from other apps***. In the Android operating system, each app runs in its own process, known as an “app sandbox.” This process is assigned a unique user ID ***during installation***. This user ID also provides the app with a separate storage area that it uses for its data. When an Android app is launched, it utilizes sandboxing to prevent it from accessing data or processes of other apps. Sandboxing also helps protect against malware and malicious apps because if an app becomes infected, its access to other apps is restricted.

**Permission Model** in Android is closely related to app sandboxing. Android apps ***require permission*** to **access certain resources or perform certain actions on the device.** These *permissions are declared* in the app’s **manifest file** and are granted to the app by the user at the time of installation or runtime. The permission model helps ensure that apps only have access to the resources they need to function properly and that they cannot access sensitive information or perform malicious actions without the user’s consent. By combining app sandboxing with a robust permission model, Android provides a secure environment for running apps while protecting user data and privacy.
