πŸ” How It Works

How ProtectMyAPI Works

ProtectMyAPI is a secure API proxy that protects your mobile app’s API keys using hardware-backed device attestation. Your API keys never touch the device, and every request is cryptographically verified to come from your legitimate app.

πŸ”’

The Problem We Solve: Mobile apps can be decompiled to steal API keys. ProtectMyAPI keeps your keys safe on our servers and verifies every request comes from a real, uncompromised device running your actual app.


The Security Problem

When you embed API keys in your mobile app:

❌ Your App Code
β”œβ”€β”€ Contains: API_KEY = "sk-abc123..."
β”œβ”€β”€ Hackers decompile your app β†’ Find the key
β”œβ”€β”€ Bots use your key β†’ Run up your bill
└── You get banned from OpenAI/Stripe/etc.

This happens constantly. Even obfuscation and encryption can be defeated by determined attackers.


The ProtectMyAPI Solution

βœ… With ProtectMyAPI
β”œβ”€β”€ Your App Code β†’ Contains only App Token (not secret)
β”œβ”€β”€ API keys stored on ProtectMyAPI servers (encrypted)
β”œβ”€β”€ Every request verified with Apple/Google
└── Only YOUR app on REAL devices can use your keys

How Requests Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Your App      β”‚         β”‚   ProtectMyAPI  β”‚         β”‚   API Provider  β”‚
β”‚  (iOS/Android)  β”‚         β”‚     Servers     β”‚         β”‚ (OpenAI, etc.)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                           β”‚                           β”‚
         β”‚ 1. Request + Attestation  β”‚                           β”‚
         β”‚ ─────────────────────────>β”‚                           β”‚
         β”‚                           β”‚                           β”‚
         β”‚                           β”‚ 2. Verify with Apple/Google
         β”‚                           β”‚ ◄────────────────────────►│
         β”‚                           β”‚                           β”‚
         β”‚                           β”‚ 3. Inject API key         β”‚
         β”‚                           β”‚ ─────────────────────────>β”‚
         β”‚                           β”‚                           β”‚
         β”‚                           β”‚ 4. Receive response       β”‚
         β”‚                           β”‚ <─────────────────────────│
         β”‚                           β”‚                           β”‚
         β”‚ 5. Return to app          β”‚                           β”‚
         β”‚ <─────────────────────────│                           β”‚

Step by Step:

  1. Your app makes a request β†’ SDK adds cryptographic proof from the device’s secure hardware
  2. ProtectMyAPI verifies the attestation β†’ Apple (App Attest) or Google (Play Integrity) confirms:
    • βœ… This is YOUR app (not a fake)
    • βœ… Running on a REAL device (not emulator)
    • βœ… Device is NOT jailbroken/rooted
    • βœ… App hasn’t been tampered with
  3. API key injected server-side β†’ Your secret key is added to the request
  4. Request forwarded β†’ ProtectMyAPI calls OpenAI/Stripe/etc. on your behalf
  5. Response returned β†’ Your app gets the result (key never exposed)

Device Attestation Explained

iOS: Apple App Attest

App Attest uses the Secure Enclave β€” a dedicated security chip in every iPhone/iPad that:

  • Generates cryptographic keys that can’t be extracted
  • Signs requests proving they came from your legitimate app
  • Apple validates these signatures on their servers
// What happens behind the scenes:
let attestation = SecureEnclave.generateAttestation(
    bundleId: "com.yourcompany.app",
    teamId: "ABCD1234",
    challenge: serverChallenge
)
// Apple cryptographically signs this, proving authenticity

Android: Google Play Integrity

Play Integrity uses TEE (Trusted Execution Environment) or StrongBox hardware to:

  • Verify the device hasn’t been tampered with
  • Confirm your app was installed from Google Play
  • Sign requests with hardware-backed keys
// What happens behind the scenes:
val integrityToken = PlayIntegrity.requestIntegrityToken(
    packageName = "com.yourcompany.app",
    nonce = serverChallenge
)
// Google validates device integrity and app authenticity

What Gets Blocked

ThreatProtection
Decompiled appsAttestation fails β€” no valid signature
Emulators/SimulatorsNo secure hardware β€” blocked
Jailbroken/Rooted devicesIntegrity check fails β€” blocked
Man-in-the-middle attacksCertificate pinning + signed requests
Replay attacksUnique nonces + timestamps
Bot trafficNo valid attestation β€” blocked
Modified app binariesCode signing verification fails

Security Layers

ProtectMyAPI uses defense in depth with multiple security layers:

Layer 1: Device Attestation

  • Apple App Attest (iOS)
  • Google Play Integrity (Android)
  • Hardware-backed cryptographic proof

Layer 2: Request Signing

  • Every request signed with device-specific key
  • Timestamps prevent replay attacks
  • HMAC-SHA256 signatures

Layer 3: Transport Security

  • TLS 1.3 encryption
  • Certificate pinning
  • No downgrade attacks

Layer 4: Server-Side Protection

  • API keys encrypted at rest (AES-256)
  • Rate limiting per device
  • Anomaly detection
  • Audit logging

Why Trust ProtectMyAPI?


Performance Impact

OperationOverhead
First request (attestation setup)~200-300ms
Subsequent requests~20-30ms
Request proxying~10-15ms
⚑

Total overhead for typical request: Under 50ms β€” imperceptible to users.


Comparison: With vs Without ProtectMyAPI

AspectWithout ProtectMyAPIWith ProtectMyAPI
API keys in app❌ Exposedβœ… Never in app
Key theft risk❌ Highβœ… Eliminated
Bot protection❌ Noneβœ… Hardware-verified
Emulator abuse❌ Possibleβœ… Blocked
Jailbreak abuse❌ Possibleβœ… Blocked
Backend required⚠️ Yes, for securityβœ… No, we handle it
Time to implement⚠️ Days/weeksβœ… Minutes

Next Steps