Skip to main content

SSL Pinning

Android VAPT Notes — Cleartext Traffic & SSL/TLS Pinning

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.

Simple explanation: 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:

  1. The user enters their username and password.
  2. The app sends the request over HTTP.
  3. An attacker positioned on the same network may intercept the traffic.
  4. 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 / issuePotential impact
Packet sniffingRead unencrypted HTTP requests and responses.
Credential exposureCapture credentials if they are transmitted over HTTP.
Session-token exposureCapture tokens if they are transmitted without encryption.
Man-in-the-Middle (MITM)Intercept communication and potentially modify it.
Data leakageExpose 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

HTTPHTTPS
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.
Interview one-liner: “Cleartext traffic enabled means the application is permitted to communicate without TLS encryption over HTTP, which can expose sensitive data to interception and MITM attacks.”

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.

Remember: TLS validation checks whether the server certificate is valid and trusted. It does not, by itself, mean the app has pinned one particular certificate or key.

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

Server sends TLS certificate→App receives certificate→Compare with configured certificate / fingerprint→Pass or fail

Public-key pinning flow

Server sends TLS certificate→App extracts public key (SPKI)→App calculates SHA-256 hash→Compare with stored hash→Pass or fail

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

PointCertificate pinningPublic-key pinning
What is pinned?Expected certificate or certificate fingerprintExpected public key or public-key hash
What does the app compare?Presented certificate / its fingerprint against the configured certificate pinHash 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 changesCan 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

  1. Inspect AndroidManifest.xml and any Network Security Configuration.
  2. Run the app and observe network requests using an authorized test setup, such as Burp Suite.
  3. Identify whether any requests use HTTP rather than HTTPS.
  4. Review whether credentials, tokens, personal information or other sensitive data are sent over HTTP.

Testing certificate/public-key pinning

  1. Configure Burp Suite as the proxy in an authorized test environment.
  2. Install the Burp CA certificate where appropriate for the test device and app trust configuration.
  3. Exercise the app's network functionality and observe whether HTTPS requests can be intercepted.
  4. If requests fail, investigate whether pinning is responsible; also consider other causes such as proxy restrictions, custom trust logic or network errors.
  5. 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

Q1

What happens when cleartext traffic is enabled in Android?

“When cleartext traffic is enabled, the Android application is allowed to communicate over unencrypted HTTP. If sensitive information such as credentials or session tokens is sent over HTTP, an attacker positioned on the network may intercept it or potentially modify the communication.”
Q2

Does enabling cleartext traffic encrypt network traffic?

“No. cleartextTrafficPermitted=true permits unencrypted HTTP communication. HTTPS with TLS provides encryption in transit.”
Q3

What is SSL/TLS validation?

“TLS validation checks whether the server's certificate is trusted, valid and matches the hostname the application is connecting to before the secure connection is accepted.”
Q4

What is SSL/TLS pinning?

“SSL/TLS pinning is a security mechanism used to add protection against MITM attacks. The application is configured with an expected server certificate or public-key pin. During a connection, it checks the server's certificate or public key against that predefined value and rejects the connection if the pin does not match.”
Q5

What are the common types of SSL/TLS pinning?

“Two common approaches are certificate pinning and public-key pinning. Certificate pinning checks the expected certificate or its fingerprint. Public-key pinning extracts the public key, commonly calculates its SHA-256 SPKI hash, and compares it with the stored pin.”
Q6

Is a pin a hash?

“Not always. A pin can be a certificate, certificate fingerprint, public key or public-key hash. Public-key pinning commonly uses a SHA-256 hash of the public key's SPKI.”
Q7

What value does the app compare in public-key pinning?

“The server sends its TLS certificate. The app extracts the public key, calculates its SHA-256 SPKI hash locally and compares that calculated hash with the predefined hash stored in the app.”
Q8

What value does the app compare in certificate pinning?

“The app compares the server's presented TLS certificate, or a fingerprint of it, against the expected certificate pin configured in the application.”
Q9

Are SSL pinning and certificate pinning the same?

“They are commonly used interchangeably in industry conversations, but certificate pinning is a specific pinning approach, while SSL pinning is a broad informal term.”
Q10

What is the difference between SSL pinning and TLS pinning?

“SSL is the older deprecated protocol and TLS is its modern replacement. The pinning concept is essentially the same, but TLS pinning is the technically accurate term for modern HTTPS connections.”
Q11

When is the certificate or public key pinned?

“During development, developers configure the expected certificate or public-key pin in the app. At runtime, the app checks the server's presented certificate or public key against that configured pin.”
Q12

Why is pinning used?

“Pinning adds protection against MITM attacks by restricting the app to an expected certificate or public key, rather than relying only on the device's general trusted CA store.”

9. Final revision sheet

TermRemember this
cleartextTrafficPermitted=trueAllows cleartext HTTP; it does not encrypt traffic.
HTTPSHTTP protected by TLS.
TLS validationChecks certificate trust, validity and hostname.
SSL pinningCommon informal term for pinning in SSL/TLS connections.
TLS pinningMore technically accurate modern term.
Certificate pinningChecks the expected certificate or certificate fingerprint.
Public-key pinningChecks the public key or commonly its SHA-256 SPKI hash.
Public-key hash flowServer sends certificate → app extracts public key → app hashes it → app compares with stored pin.
Pin mismatchPinning check fails; the app should reject the connection.
Most important distinction: TLS validation asks, “Is this server certificate valid and trusted?” Pinning asks, “Is this the specific certificate or public key this app expects?”
Android VAPT study notes • Prepared from the questions and explanations in this conversation

Comments

Popular posts from this blog

Top 16 open source intelligence tools (OSINT) to find anyone online

Top 16 open source intelligence tools  (OSINT) to find anyone online What are the top 16, open source tools (OSINT) to find anyone online? What a great question! and a huge one. We spend time talking to OSINT experts and private investigators to find out. Here we cover their good and bad points (not many bad points!), giving our review, link and advice. This document will increase your knowledge and add 16 amazing investigation tools, leading you deeper into the dark and quite often secret cave, of online investigations. As I’m sure you know, Open source intelligence (OSINT) is the application of utilising data that is publicly available, to achieve your aim. Open source may give the impression of publicly available information only. OSINT could also utilise human intelligence (such as social engineering). But, there are many methods of gathering and sifting this intelligence, not all, but most, include using computer systems. Why is OSINT so important? OSINT is making sense of the...

GPCSSI (Gurugram Police Cyber Security Summer Internship)

NOTES  USEFULL WEBSITES:- 1)cybercrime.gov.in 2)csk.gov.in 3)nciip.gov.in 4)ceir.gov.in 5)consumerhelpline.gov.in 6)bprd.nic.in 7)meity.gov.in  1. All About Web Our heist has come to a position where we are stuck with the web interfaces but we need your help Visit https://chall.hackershala.com Site: https://chall.hackershala.com/ SQLi was bypassed with ' or 1=1-- in both fields CTF{YOUGOTTHEFLAG} is the flag The other part was just robots.txt CTF{YOUAREHACKER} is the flag. 2. Not Just SQL There have been a breakthrough in our heist but we still cant access chall2.hackingbrawl.com as a privileged user. As usual, there is a login page: https://chall2.hackingbrawl.com/newlogin.php (This challenge was the next in the sequel to the basic sqli one) At first few SQL injection methods were attempted, but these went in vain. Upon using sqlmap, it was discovered that the site was vulnerable to time-based-blind injection. So manual attempts were done, the site see...

Official (ISC)2 Certified in Cybersecurity (CC) Self-Paced Training. (Course Introduction and Chapter 1: Security Principles)

Course Introduction Welcome to the Official (ISC)² Certified in Cybersecurity (CC) Self-Paced Training course! Congratulations on your interest in pursuing a career in cybersecurity. The Certified in Cybersecurity (CC) certification will demonstrate to employers that you have foundational knowledge of industry terminology, network security, security operations and policies and procedures that are necessary for an entry- or junior-level cybersecurity role. It will signal your understanding of fundamental security best practices, policies and procedures, as well as your willingness and ability to learn more and grow on the job.       Introduction from the (ISC)² CEO Dear Future Cybersecurity Leader: Congratulations! You are taking the first steps along the pathway to becoming a part of the global cybersecurity community and an (ISC) 2 member. Cybersecurity is in high demand by organizations and governments globally and we need your talents to help defend ...