high · M1 · MASVS-STORAGE-1 · PTKD-LEFTOVER-EXPO-EXTRA-SECRET
Secret in the Expo app config `extra`, which ships inside the app
A secret (an AI, payment, database or admin key) is put in `extra` in app.json or app.config.js. Expo copies `extra` into the app at build time, so the value is inside every build and any user can read it with a few lines of code or by unpacking the app. Filling it from an environment variable in app.config.js does not help: the value is still copied in.
How it is exploited
app.config.js sets `extra.openaiApiKey` from the OPENAI_API_KEY environment variable and the app reads it with Constants.expoConfig.extra.openaiApiKey. The developer thinks the key stays on the build machine, but Expo writes it into the manifest inside the IPA and APK. Someone unzips the app, finds the key in the embedded app config and runs up the OpenAI bill.
Why it matters
The key is public for as long as any old build is installed: provider bills, data access or admin actions in your name.
How to fix it
- Remove the secret from `extra` in app.json / app.config.js.
- Move the call that needs it to a server or Supabase Edge Function / Cloud Function that checks the user and holds the key in its own environment.
- Rotate the key at the provider: every shipped build still contains the old one.
- Keep only public values in `extra` (API base URL, Supabase anon key, feature flags).
Does your app have this?
PTKD checks your build or your source project for PTKD-LEFTOVER-EXPO-EXTRA-SECRET and every other check in this knowledge base.
Scan your app