SlideShare a Scribd company logo
Safety first
Best practices in app security
ANA BAOTIĆ
TECHNICAL MANAGER, MOBILE BANKING @ INFINUM
We're an independent
design &
development
agency.
Safety first – best practices in app security​
HOW TO INCREASE SECURITY
BUILD INTEGRITY
DATA PRIVACY
NETWORK SECURITY
THINGS TO ADD TO A NEW PROJECT
Release keystore
Obfuscation
KEYSTORE
Should be used for ALL builds
You should NEVER lose it
No one should EVER acquire it
Safety first – best practices in app security​
signingConfigs {
release {
storeFile file("myapp.keystore")
storePassword "password123"
keyAlias "keyAlias"
keyPassword "password789"
}
}
DO NOT!
DO!
gradle.properties
KEYSTORE_PASSWORD=password123
KEY_PASSWORD=password789
try {
storeFile file("myapp.keystore")
storePassword KEYSTORE_PASSWORD
keyAlias "keyAlias"
keyPassword KEY_PASSWORD
} catch (ex) {
throw new InvalidUserDataException(“…”)
}
OBFUSCATION
Proguard
DexGuard
DexProtector
release {


minifyEnabled true
proguardFiles getDefaultProguardFile(
'proguard-android.txt'), ‘proguard-rules.txt'


signingConfig signingConfigs.release

}
public abstract class e {

private int a = -1;

private String b = null;

protected boolean k = false;



public abstract void a(Intent var1);



public void run() {

this.a((Intent)null);

}

protected final void a(String var1) {

this.b = var1;

}

public final void c() {

this.a = -1;

this.b = null;

}

public final boolean d() {

return this.k;

}

}
WILL THIS KEEP THE APK SAFE?
No.
Safety first – best practices in app security​
TAMPERING DETECTION
Verify signing certificate at runtime
Verify the installer
context.getPackageManager()
.getInstallerPackageName(context.getPackageName())
.startsWith("com.android.vending")
Check if app is debuggable (or run on emulator)
DATA PRIVACY
USERS ARE SENSITIVE ABOUT THEIR DATA
WAYS TO STORE (AND RETRIEVE) DATA
Internal storage
External storage
Content providers
INTERNAL STORAGE
Is (generally) sufficiently safe
Private to the your app
EXTERNAL STORAGE
Globally readable and writable
CONTENT PROVIDERS
Structured storage mechanism
Can be exported to allow access by other apps
 
<provider
android:name="com.example.android.datasync.provider.StubProvider" 
android:authorities="com.example.android.datasync.provider"
android:exported="false"/>
android:protectionLevel="signature"
SHARED PREFERENCES
Useful for primitive key-value based data
private readable safe
Internal storage yes yes yes
External
storage
no yes no
Content
providers
depends yes yes
Shared prefs. yes yes yes
SO EVERYTHING IS FINE?
Yes, until you root the device.
Safety first – best practices in app security​
USE LIBRARIES
Bouncy Castle
Spongy Castle
Keyczar
AeroGear Crypto
Conceal
ENCRYPT USING A PIN/PASSWORD
4 digits - 10 000 attempts
No effort to crack or even guess
BCRYPT
Key derivation function
Slow
Cost of the hash function depends on the work factor
CAN DATA REMAIN PRIVATE?
Rooting your device allows access
Not encrypting allows (mis)use
NETWORK SECURITY
Safety first – best practices in app security​
HTTP
Still (frequently) used
MiTM
HTTPS
Encrypts data
Validation of server’s identity
android:usesCleartextTraffic="false"
ANDROID M
StrictMode.setVmPolicy(
new StrictMode.VmPolicy.Builder()
.detectCleartextNetwork()
.penaltyLog().build());
ANDROID N
Network Security Configuration feature
Finer grained control
Safety first – best practices in app security​
CERTIFICATE PINNING
Defines which CAs are trusted
Reduces effectiveness of MiTM
okhttpbuilder

.pinClientCertificate(resources,
R.raw.client_cert, "pass".toCharArray(), “PKCS12”)
.pinServerCertificates(resources, 

R.raw.server_cert, "pass".toCharArray(), "BKS")

.build();
return new OkClient(client);

WHAT IF THE CERTIFICATES CHANGE?
INFORM THE USERS
Implement a mechanism for notifying users
(GCM) and forcing updates
PLAN AHEAD
Check server security’s impact on Android
devices
https://www.ssllabs.com/
Safety first – best practices in app security​
INCLUDE THE CLIENT IN THE PROCESS
Keep them up-to-date
Help them understand risks and advise them
Insist on updates and security patches
RECAP
ANDROID IS NOT SECURE
But you can make it less easy to abuse
THINGS TO REMEMBER
Use internal storage if applicable
Encrypt data
Use HTTPS
Pin certificates
Be aware of the update cycle
Safety first – best practices in app security​
REFERENCES
• Gradle configuration
• http://developer.android.com/guide/topics/data/data-
storage.html#db
• https://codahale.com/how-to-safely-store-a-password/
• http://www.developereconomics.com/android-
cryptography-tools-for-beginners/
• https://www.airpair.com/android/posts/adding-tampering-
detection-to-your-android-app
REFERENCES
• https://www.ssllabs.com/
• http://developer.android.com/preview/features/security-
config.html
• https://www.ionic.com/mitm-attacks-ssl-pinning-what-is-it-
and-why-you-should-care/
Thank you!

Questions?
Visit www.infinum.co or find us on social networks:
infinum.co infinumco infinumco infinum
ANA@INFINUM.CO
@ABAOTIC

More Related Content

PDF
Avoiding damage, shame and regrets data protection for mobile client-server a...
PDF
Abusing & Securing XPC in macOS apps
PDF
[Wroclaw #9] The purge - dealing with secrets in Opera Software
PDF
Certificate Pinning: Not as Simple as It Sounds
PDF
Testing Android Security Codemotion Amsterdam edition
PDF
OWASP Poland Day 2018 - Amir Shladovsky - Crypto-mining
PPTX
Techorama 2019 - Azure Security Center Unleashed
PDF
Secrets as Code
Avoiding damage, shame and regrets data protection for mobile client-server a...
Abusing & Securing XPC in macOS apps
[Wroclaw #9] The purge - dealing with secrets in Opera Software
Certificate Pinning: Not as Simple as It Sounds
Testing Android Security Codemotion Amsterdam edition
OWASP Poland Day 2018 - Amir Shladovsky - Crypto-mining
Techorama 2019 - Azure Security Center Unleashed
Secrets as Code

What's hot (20)

PPTX
TechEvent Data Encryption in Azure
PPTX
Don't get stung - an introduction to the OWASP Top 10
PDF
Secure Secret Management on a Budget: Reasoning about Scalable SM with Vault ...
PDF
Automation Patterns for Scalable Secret Management
PDF
Kubernetes Secrets - The Good, The Bad, and The Ugly - Akeyless
PPTX
The Key to Strong Cloud Security
PPTX
[OPD 2019] Side-Channels on the Web:
Attacks and Defenses
PDF
Nodevember 2015
PPTX
Secret Management with Hashicorp Vault and Consul on Kubernetes
PDF
Hardening Kubernetes Cluster
PDF
Node Day - Node.js Security in the Enterprise
PDF
Recipe for good secrets management
PPT
Node.JS security
PDF
SecOps Workshop (Gregory Pickett)
PPTX
Microservices docker-security
PPTX
Nodejs Security
PPT
Mule security - pgp
PDF
Spring Security
PPT
Mule security - pgp
PPTX
Pgp security mule
TechEvent Data Encryption in Azure
Don't get stung - an introduction to the OWASP Top 10
Secure Secret Management on a Budget: Reasoning about Scalable SM with Vault ...
Automation Patterns for Scalable Secret Management
Kubernetes Secrets - The Good, The Bad, and The Ugly - Akeyless
The Key to Strong Cloud Security
[OPD 2019] Side-Channels on the Web:
Attacks and Defenses
Nodevember 2015
Secret Management with Hashicorp Vault and Consul on Kubernetes
Hardening Kubernetes Cluster
Node Day - Node.js Security in the Enterprise
Recipe for good secrets management
Node.JS security
SecOps Workshop (Gregory Pickett)
Microservices docker-security
Nodejs Security
Mule security - pgp
Spring Security
Mule security - pgp
Pgp security mule
Ad

Similar to Safety first – best practices in app security​ (20)

PDF
Android N Security Overview - Mobile Security Saturday at Ciklum
ODP
Dos and Don'ts of Android Application Security (Security Professional Perspec...
PDF
CNIT 128 9. Writing Secure Android Applications
PDF
MCE^3 - Scott Alexander-Bown - Android App Security on a Budget
PPTX
Building secure android apps
PDF
9 Writing Secure Android Applications
PDF
Consulthink @ GDG Meets U - L'Aquila2014 - Codelab: Android Security -Il ke...
PDF
(ISC)2 Kamprianis - Mobile Security
PPTX
Android security
PDF
Security testing in mobile applications
PDF
Top 6 Android Security Best Practices for App Development
PDF
2015.04.24 Updated > Android Security Development - Part 1: App Development
PDF
Security in Android Applications / Александр Смирнов (RedMadRobot)
PDF
Android security and penetration testing | DIVA | Yogesh Ojha
PPTX
Security Tips for Android App - iTrobes
PDF
CNIT 128 9. Writing Secure Android Applications
PPTX
Android Security
PDF
2018 android-security-udacity-morrison chang
PPTX
Volodymyr Kimak "Security Tips for Android App"
PDF
Android App Hacking - Erez Metula, AppSec
Android N Security Overview - Mobile Security Saturday at Ciklum
Dos and Don'ts of Android Application Security (Security Professional Perspec...
CNIT 128 9. Writing Secure Android Applications
MCE^3 - Scott Alexander-Bown - Android App Security on a Budget
Building secure android apps
9 Writing Secure Android Applications
Consulthink @ GDG Meets U - L'Aquila2014 - Codelab: Android Security -Il ke...
(ISC)2 Kamprianis - Mobile Security
Android security
Security testing in mobile applications
Top 6 Android Security Best Practices for App Development
2015.04.24 Updated > Android Security Development - Part 1: App Development
Security in Android Applications / Александр Смирнов (RedMadRobot)
Android security and penetration testing | DIVA | Yogesh Ojha
Security Tips for Android App - iTrobes
CNIT 128 9. Writing Secure Android Applications
Android Security
2018 android-security-udacity-morrison chang
Volodymyr Kimak "Security Tips for Android App"
Android App Hacking - Erez Metula, AppSec
Ad

Recently uploaded (20)

PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Hybrid model detection and classification of lung cancer
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Getting Started with Data Integration: FME Form 101
PDF
WOOl fibre morphology and structure.pdf for textiles
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
August Patch Tuesday
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
A comparative analysis of optical character recognition models for extracting...
SOPHOS-XG Firewall Administrator PPT.pptx
OMC Textile Division Presentation 2021.pptx
Hybrid model detection and classification of lung cancer
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Group 1 Presentation -Planning and Decision Making .pptx
Getting Started with Data Integration: FME Form 101
WOOl fibre morphology and structure.pdf for textiles
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
August Patch Tuesday
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
cloud_computing_Infrastucture_as_cloud_p
Zenith AI: Advanced Artificial Intelligence
Unlocking AI with Model Context Protocol (MCP)
Univ-Connecticut-ChatGPT-Presentaion.pdf
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf

Safety first – best practices in app security​