Android VAPT Interview Notes
Cleartext Traffic, HTTP/HTTPS, SSL/TLS Validation, Certificate Pinning & Public-Key Pinning
1. What happens when cleartext traffic is enabled?
When an Android app allows cleartext traffic, it is permitted to communicate using unencrypted protocols such as HTTP. The traffic is not protected by TLS encryption.
cleartextTrafficPermitted="true" allows cleartext HTTP communication. It does not encrypt traffic.Real-life example
Imagine a banking app sending a login request over HTTP while the user is connected to public airport Wi-Fi:
- The user enters their username and password.
- The app sends the request over HTTP.
- An attacker positioned on the same network may intercept the traffic.
- If credentials, session tokens or personal data are sent in cleartext, the attacker may be able to read them. Depending on the connection and attack position, traffic may also be modified.
Analogy: HTTP is like a postcard that can be read while it is being delivered. HTTPS is like a locked container that protects the contents in transit.
What can an attacker potentially do?
| Attack / issue | Potential impact |
|---|---|
| Packet sniffing | Read unencrypted HTTP requests and responses. |
| Credential exposure | Capture credentials if they are transmitted over HTTP. |
| Session-token exposure | Capture tokens if they are transmitted without encryption. |
| Man-in-the-Middle (MITM) | Intercept communication and potentially modify it. |
| Data leakage | Expose personal or sensitive information sent in cleartext. |
Important: Enabling cleartext traffic does not by itself prove that sensitive data is exposed. Verify whether the app actually makes HTTP requests and what data those requests contain.
2. How do you identify cleartext traffic settings?
AndroidManifest.xml
<application
android:usesCleartextTraffic="true">
</application>
This setting allows cleartext traffic, subject to Android version, target SDK and network security configuration behavior.
Network Security Configuration
<base-config cleartextTrafficPermitted="true" />
This configuration also permits cleartext traffic for the applicable configuration scope.
What is the secure configuration?
<application
android:usesCleartextTraffic="false">
</application>
<base-config cleartextTrafficPermitted="false" />
Use HTTPS/TLS for network communication and verify that the app does not send sensitive information over HTTP.
HTTP vs HTTPS
| HTTP | HTTPS |
|---|---|
| Does not provide TLS encryption. | Uses TLS to encrypt data in transit. |
| Traffic can be read if intercepted. | Traffic contents are protected by TLS in transit. |
| Does not provide TLS server authentication. | Uses certificate validation to authenticate the server. |
3. What is SSL/TLS validation?
TLS validation is the process of checking the server's identity and certificate before the app trusts the HTTPS connection.
Typical checks include:
- Whether the certificate chains to a trusted Certificate Authority (CA).
- Whether the certificate is within its validity period.
- Whether the certificate is valid for the hostname the app contacted.
- Whether the certificate chain and signatures validate correctly.
Real-life example
An app connects to https://bank.com. The TLS stack checks that the server presents a trusted, valid certificate for bank.com. If validation fails, the connection should normally be rejected.
4. What is SSL pinning / certificate pinning?
“SSL pinning” is a common industry term for pinning in an HTTPS connection. Technically, modern apps use TLS, so “TLS pinning” is more accurate.
Pinning is an additional check: the app is configured to trust a particular expected server certificate or public key (often represented by a hash), rather than relying only on the normal platform trust store.
Certificate pinning
The app is configured with an expected certificate or certificate fingerprint. During the connection, it checks the server's presented certificate against that expected value. The exact comparison depends on the implementation.
Public-key pinning
The app is configured with an expected public key or, commonly, a SHA-256 hash of the public key's Subject Public Key Info (SPKI). The app obtains the public key from the server's certificate, calculates the hash locally, and compares it with the stored pin.
Are SSL pinning and certificate pinning the same?
They are often used interchangeably in everyday Android VAPT discussions, but the terms are not perfectly precise. “SSL pinning” is a broad, commonly used label; certificate pinning is one specific pinning approach.
Are certificate pinning and public-key pinning types of SSL pinning?
Yes, you can describe them as two common approaches under the general industry term “SSL pinning” (more technically, TLS pinning):
- Certificate pinning: pin the certificate or its fingerprint.
- Public-key pinning: pin the public key, commonly using its SHA-256 SPKI hash.
5. What does “pin” mean? Is a pin always a hash?
No. A pin is the expected value that the app uses for comparison. Depending on the implementation, it may be a certificate, a certificate fingerprint, a public key, or a public-key hash.
Certificate pinning flow
Public-key pinning flow
Critical clarification: In the common public-key hash pinning flow, the server sends its TLS certificate. It does not send the precomputed pin hash for the app to compare. The Android app extracts the public key and calculates the hash locally.
Quick comparison
| Point | Certificate pinning | Public-key pinning |
|---|---|---|
| What is pinned? | Expected certificate or certificate fingerprint | Expected public key or public-key hash |
| What does the app compare? | Presented certificate / its fingerprint against the configured certificate pin | Hash calculated from the presented certificate's public key against the configured public-key pin |
| Can the pin survive certificate renewal? | Usually requires updating the pin if the certificate changes | Can survive certificate renewal if the same public key is retained |
What happens if the pin does not match?
The pinning check fails and the app should reject the connection. Normal TLS certificate validation must also succeed; pinning is an additional check, not a replacement for TLS validation.
6. When and how is the pin configured?
During development, the developers configure the expected certificate or public-key pin in the app's networking/security configuration or code. The app then performs the pin check at runtime when connecting to the server.
For example, an app connecting to https://api.bank.com may have the expected public-key hash configured. When the server presents its certificate, the app extracts the public key, computes its hash and checks it against the configured pin.
Operational note: Pins must be managed carefully. Certificate/key rotation can break app connectivity if the app does not include an appropriate updated or backup pin strategy.
7. How do you test these controls during Android VAPT?
Testing cleartext traffic
- Inspect
AndroidManifest.xmland any Network Security Configuration. - Run the app and observe network requests using an authorized test setup, such as Burp Suite.
- Identify whether any requests use HTTP rather than HTTPS.
- Review whether credentials, tokens, personal information or other sensitive data are sent over HTTP.
Testing certificate/public-key pinning
- Configure Burp Suite as the proxy in an authorized test environment.
- Install the Burp CA certificate where appropriate for the test device and app trust configuration.
- Exercise the app's network functionality and observe whether HTTPS requests can be intercepted.
- If requests fail, investigate whether pinning is responsible; also consider other causes such as proxy restrictions, custom trust logic or network errors.
- Confirm the implementation through static analysis and controlled dynamic testing.
Tools: JADX for code review, MobSF for static analysis, Frida for authorized dynamic testing, and Burp Suite for observing HTTP/HTTPS traffic.
A failed Burp interception alone is not conclusive proof of certificate pinning. Corroborate it with code/configuration analysis and controlled testing.
8. Interview-ready answers
What happens when cleartext traffic is enabled in Android?
Does enabling cleartext traffic encrypt network traffic?
cleartextTrafficPermitted=true permits unencrypted HTTP communication. HTTPS with TLS provides encryption in transit.”What is SSL/TLS validation?
What is SSL/TLS pinning?
What are the common types of SSL/TLS pinning?
Is a pin a hash?
What value does the app compare in public-key pinning?
What value does the app compare in certificate pinning?
Are SSL pinning and certificate pinning the same?
What is the difference between SSL pinning and TLS pinning?
When is the certificate or public key pinned?
Why is pinning used?
9. Final revision sheet
| Term | Remember this |
|---|---|
cleartextTrafficPermitted=true | Allows cleartext HTTP; it does not encrypt traffic. |
| HTTPS | HTTP protected by TLS. |
| TLS validation | Checks certificate trust, validity and hostname. |
| SSL pinning | Common informal term for pinning in SSL/TLS connections. |
| TLS pinning | More technically accurate modern term. |
| Certificate pinning | Checks the expected certificate or certificate fingerprint. |
| Public-key pinning | Checks the public key or commonly its SHA-256 SPKI hash. |
| Public-key hash flow | Server sends certificate → app extracts public key → app hashes it → app compares with stored pin. |
| Pin mismatch | Pinning check fails; the app should reject the connection. |
Comments
Post a Comment