highCWE-295A05:2021

Certificate Pinning Missing

Without certificate pinning, attackers on the same network can intercept your app's HTTPS traffic with a rogue certificate authority.

How It Works

TLS normally trusts any certificate signed by a system-trusted CA. On a corporate or public network, a proxy with a custom CA cert can intercept all HTTPS traffic. Certificate pinning makes your app accept only your specific certificate or public key, blocking any MITM proxy regardless of its CA.

Vulnerable Code
// BAD: standard fetch — trusts any system-trusted certificate
const response = await fetch('https://api.myapp.com/user', {
  headers: { Authorization: `Bearer ${token}` }
  // no pinning — interceptable by corporate proxies or malicious APs
});
Secure Code
// GOOD: use react-native-ssl-pinning for certificate pinning
import { fetch } from 'react-native-ssl-pinning';

const response = await fetch('https://api.myapp.com/user', {
  method: 'GET',
  sslPinning: { certs: ['cert_sha256_fingerprint'] }, // rejects other certs
  headers: { Authorization: `Bearer ${token}` }
});

Real-World Example

Pen testers routinely bypass mobile app security by setting up a Burp Suite proxy on a shared WiFi network. Apps without certificate pinning expose all their API calls, tokens, and user data to this attack.

How to Prevent It

  • Implement certificate pinning using react-native-ssl-pinning (RN) or TrustKit (iOS/Android native)
  • Pin the public key (SPKI) rather than the full certificate to survive cert renewals
  • Always provide at least one backup pin in case your primary certificate needs to be rotated
  • Test certificate pinning with a proxy tool (Charles, Burp Suite) to verify it works before release

Affected Technologies

React Nativeiosandroid

Data Hogo detects this vulnerability automatically.

Scan Your Repo Free

Related Vulnerabilities