Skip to content

Conversation

serek8
Copy link
Collaborator

@serek8 serek8 commented Sep 2, 2025

This PR closes OWASP/mastg#2931.

Description

It updates mitigations for Port MASTG-TEST-0058: Testing Backups for Sensitive Data

@serek8 serek8 requested a review from cpholguera September 2, 2025 07:36
@cpholguera cpholguera requested a review from Diolor September 26, 2025 10:01
Copy link
Collaborator

@Diolor Diolor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the mitigation suggestion @serek8! I left you a comment, which, I think, can help you bring it WE closer to the contribution guidelines!

Comment on lines 37 to 43
## Mitigations

- Exclude sensitive files from backups using platform-specific attributes, such as `android:allowBackup` or `BackupAgent` with `excludeFromBackup` for Android. On iOS, API such as `NSURLIsExcludedFromBackupKey` [doesn't guarantee](https://developer.apple.com/documentation/foundation/optimizing_your_app_s_data_for_icloud_backup/#3928527) exclusion from the backup. Therefore, you should encrypt your data instead.
- Store sensitive data in locations excluded from backups by default, like the Keychain or `Library/Caches` on iOS.
- On Android, exclude sensitive files from backups using platform-specific attributes, such as `android:allowBackup` or `BackupAgent` with `excludeFromBackup` for Android.
- On iOS, API such as `NSURLIsExcludedFromBackupKey` [doesn't guarantee](https://developer.apple.com/documentation/foundation/optimizing_your_app_s_data_for_icloud_backup/#3928527) exclusion from the backup. Therefore, you should encrypt your data instead.
- On iOS, you can store data inside the Keychain with [kSecAttrAccessibleWhenUnlockedThisDeviceOnly](https://developer.apple.com/documentation/security/ksecattraccessiblewhenunlockedthisdeviceonly) flag. This flag restricts data access to the current device only. However, if you back up and restore on the same device, this data will also be restored. Therefore, it only prevents the data from being transferred to another device. Apple discourages storing large amounts of data in the Keychain, so it's best to store only an encryption key there and keep the rest of the files in the filesystem
- On iOS, you can store files at `Library/Caches`. This directory is excluded from the backup but the system may delete content of this directory when low on disk space.
- Encrypt sensitive data before storage to ensure confidentiality, even if it gets backed up.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the contribution guidelines, the mitigations should be brief and generic. Therefore, we should rather keep it even more brief than it is. 😄

Suggested change
## Mitigations
- Exclude sensitive files from backups using platform-specific attributes, such as `android:allowBackup` or `BackupAgent` with `excludeFromBackup` for Android. On iOS, API such as `NSURLIsExcludedFromBackupKey` [doesn't guarantee](https://developer.apple.com/documentation/foundation/optimizing_your_app_s_data_for_icloud_backup/#3928527) exclusion from the backup. Therefore, you should encrypt your data instead.
- Store sensitive data in locations excluded from backups by default, like the Keychain or `Library/Caches` on iOS.
- On Android, exclude sensitive files from backups using platform-specific attributes, such as `android:allowBackup` or `BackupAgent` with `excludeFromBackup` for Android.
- On iOS, API such as `NSURLIsExcludedFromBackupKey` [doesn't guarantee](https://developer.apple.com/documentation/foundation/optimizing_your_app_s_data_for_icloud_backup/#3928527) exclusion from the backup. Therefore, you should encrypt your data instead.
- On iOS, you can store data inside the Keychain with [kSecAttrAccessibleWhenUnlockedThisDeviceOnly](https://developer.apple.com/documentation/security/ksecattraccessiblewhenunlockedthisdeviceonly) flag. This flag restricts data access to the current device only. However, if you back up and restore on the same device, this data will also be restored. Therefore, it only prevents the data from being transferred to another device. Apple discourages storing large amounts of data in the Keychain, so it's best to store only an encryption key there and keep the rest of the files in the filesystem
- On iOS, you can store files at `Library/Caches`. This directory is excluded from the backup but the system may delete content of this directory when low on disk space.
- Encrypt sensitive data before storage to ensure confidentiality, even if it gets backed up.
## Mitigations
- Exclude sensitive information, files, and key material from backups.
- If you have to include sensitive data in backups, ensure it is encrypted with an algorithm strong enough to protect the data for its entire required lifetime, even if the backup is later compromised.

These new points are valid and would be more fitting in the best practices

If you could add those under best practices, it would be awesome, so we don't lose knowledge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MASTG v1->v2 MASTG-TEST-0058: Testing Backups for Sensitive Data (ios)
2 participants