# Check this app against App Store Review Guideline 1.6: Data Security

Protect the user data you collect from leaks and unauthorized access.

Go through this codebase for each problem below. For each one that applies, fix it on a new git branch with the steps for this app's stack (React Native and Expo, Swift, or Flutter). If none apply, say so and why.

## Anyone can read your Firebase database

Usually a rejection.

**What Apple wants:** Your Firebase Realtime Database answered a request that carried no sign-in, so its rules let anyone read it: the data stored there is open to whoever finds the address, and the address ships inside the app. Guideline 1.6 asks apps to keep the data they collect safe, and a database open to everyone is how most leaks of user data start.

**How to fix it:** Change the database rules so reading needs a signed-in user, and each user reads only their own data.

Steps:

1. In the Firebase console, open Realtime Database, then Rules.
2. Replace ".read": true (and any rule open to everyone) with rules that check auth, for example ".read": "auth != null" at the top and "$uid === auth.uid" under each user's data.
3. Publish the rules, then scan again: your Mac asks the database the same way, and it should refuse.

## The build allows plain http to any server

Delays review.

**What Apple wants:** App Transport Security is off for every server in this build (NSAllowsArbitraryLoads), so anything the app sends over http can be read on the network. Apple asks apps to protect personal data in transit (Guideline 1.6), and App Review can ask why it is off; AppScend raises this when it also finds personal data sent over http.

**How to fix it:** Turn NSAllowsArbitraryLoads off, and allow plain http only for the domains that need it.

Steps for React Native and Expo:

1. In app.json, remove NSAllowsArbitraryLoads from expo.ios.infoPlist.NSAppTransportSecurity.
2. If one server still needs http, add only that domain under NSExceptionDomains with NSExceptionAllowsInsecureHTTPLoads, and move it to https when you can.

Steps for Swift:

1. Remove NSAllowsArbitraryLoads from NSAppTransportSecurity in the app target's Info.plist.
2. If one server still needs http, add only that domain under NSExceptionDomains with NSExceptionAllowsInsecureHTTPLoads, and move it to https when you can.

Steps for Flutter:

1. Remove NSAllowsArbitraryLoads from NSAppTransportSecurity in Info.plist.
2. If one server still needs http, add only that domain under NSExceptionDomains with NSExceptionAllowsInsecureHTTPLoads, and move it to https when you can.

## Weaker encryption allowed for some servers

Delays review.

**What Apple wants:** These App Transport Security exceptions accept TLS older than 1.2 or connections without forward secrecy, which attackers on the network can break more easily. Nothing is refused for it; it weakens how personal data is protected in transit (Guideline 1.6).

**How to fix it:** Upgrade those servers to TLS 1.2 or later, then remove the exceptions.

Steps:

1. Check each domain named here with the server owner (or your hosting) and turn on TLS 1.2 or 1.3.
2. Remove NSExceptionMinimumTLSVersion and NSExceptionRequiresForwardSecrecy for it.

## Key files ship inside the app

Often a rejection.

**What Apple wants:** Private keys, certificates or .env files are in the app bundle: anyone can unzip the app and read them, and use what they unlock. Apps must keep the data they handle secure (Guideline 1.6).

**How to fix it:** Take the key files out of the app target, then replace the keys they hold.

Steps for React Native, Expo and Flutter:

1. Find what copies each file named here into the app and leave it out.
2. Replace any key that shipped: once an app with it is out, treat it as public.
3. Build again: the next test run reads the bundle.

Steps for Swift:

1. In Xcode, remove each file named here from the target's Build Phases → Copy Bundle Resources (or the folder reference that brings it in).
2. Replace any key that shipped: once an app with it is out, treat it as public.
3. Build again: the next test run reads the bundle.

## A secret key is inside the app: a server key

Often a rejection.

**What Apple wants:** The built app holds a server's secret key (found in the JavaScript bundle or a bundled file). Anyone can pull it out of the downloaded app and use it at your expense, or reach your data with it. Keys added at build time (public environment variables) end up in the bundle the same way. Apps must keep the data they handle secure (Guideline 1.6). Only the key's kind and length left your Mac.

**How to fix it:** Move the call that needs the key to your server, then replace the key.

Steps for React Native and Expo:

1. Find where the key enters the app (an environment variable marked public, a config file) and remove it.
2. Call the service from your own backend (or a serverless function) that keeps the key, and have the app call that.
3. Replace the key in the service's dashboard: the old one is public once a build with it is out.

Steps for Swift and Flutter:

1. Find where the key enters the app (an environment variable marked public, a config file) and remove it.
2. Call the service from your own backend that keeps the key, and have the app call that.
3. Replace the key in the service's dashboard: the old one is public once a build with it is out.

## Personal data may be sent without encryption

Often a rejection.

**What Apple wants:** Apps must protect the personal data they collect from unauthorized access (Guideline 1.6). Sending sign-in details or personal data over plain http lets anyone on the network read them.

**How to fix it:** Send everything over https.

Steps:

1. Change every http:// API address to https:// (and enable TLS on the server if needed).
2. Remove App Transport Security exceptions that allow plain http.

## A secret AI key may ship inside the app

Often a rejection.

**What Apple wants:** Anything in the app bundle can be extracted. A leaked AI key lets others run up your bill and read what users sent, which is the unauthorized access Guideline 1.6 asks you to prevent.

**How to fix it:** Move the AI key to your server and call the AI through it.

Steps:

1. Create a small server endpoint (or serverless function) that holds the key and calls the AI service.
2. Have the app call that endpoint, with the user's session for authentication.
3. Revoke the old key, since it has already shipped.

## A server secret may ship inside the app

Often a rejection.

**What Apple wants:** Secrets like a Supabase service_role key or a Stripe secret key give full access to your data and payments. In the app, anyone can extract them, which breaks the data protection Guideline 1.6 asks for.

**How to fix it:** Remove the secret from the app, rotate it, and do the privileged work on your server.

Steps:

1. Move the work that needs the secret to a server endpoint.
2. Use only publishable or public keys in the app.
3. Rotate the leaked secret right away.

## Passwords may be stored on the device unencrypted

Delays review.

**What Apple wants:** Guideline 1.6 asks for appropriate security for user data. Passwords and card numbers in plain storage can be read from backups or a lost device.

**How to fix it:** Don't store passwords; keep any secret in the Keychain.

Steps for React Native, Expo and Flutter:

1. Stop saving passwords; keep a session token instead.
2. Put anything sensitive in the Keychain: expo-secure-store in Expo, or react-native-keychain.

Steps for Swift:

1. Stop saving passwords; keep a session token instead.
2. Put anything sensitive in the Keychain, through the Security framework or a small Keychain wrapper.

## Other people's private data may be exposed

Often a rejection.

**What Apple wants:** Guideline 1.6 asks apps to keep user data from unauthorized disclosure or access. If the app can fetch everyone's emails or phone numbers, or private files sit at public links, anyone can extract them.

**How to fix it:** Fetch only the fields each screen shows, and keep private files in private storage.

Steps:

1. Select only public fields (such as name and photo) when loading other users.
2. Lock the database so other users' private fields can't be read (Supabase row level security, Firestore security rules).
3. Store private uploads in private buckets and open them with short-lived signed links.

---

AppScend checks an app against every guideline at once, on the developer's Mac: `npx appscend scan --json` in the app's root folder (docs: https://appscend.ai/docs).

Source: https://appscend.ai/guidelines/1-6
