SlideShare a Scribd company logo
© Blueinfy Solutions
Secure Coding For Android
Applications
© Blueinfy Solutions
Local Storage - Example
• Remember me option – NOT SECURE WAY
© Blueinfy Solutions
Token stored
• On local file – NOT SECURE WAY
© Blueinfy Solutions
Shared Preferences
• SHARED PREFERENCE – NOT SECURE WAY
© Blueinfy Solutions
Writing to file
• When opening file for writing, make sure to
open it in private mode as shown below –
String FILENAME = “temp";
String string = “token”;
FileOutputStream fos = openFileOutput(FILENAME,
Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();
© Blueinfy Solutions
Local Storage – Secure Method
• Encrypt the data using strong encryption,
possibly AES
• Do not decrypt the data at client side
• Send Encrypted Data to the server
• Server decrypts the data before validating it
© Blueinfy Solutions
Securing Secrets
• AES encryption to store secret information
and making secure storage.
• APIs and Libs for it.
• Random cookies and keys.
• Not to open and shared storage.
• Cache and File writing is not enough.
• Design level strategy for it.
© Blueinfy Solutions
Secure Method – Sample Code
© Blueinfy Solutions
Sending Encrypted in JSON
© Blueinfy Solutions
Secure
© Blueinfy Solutions
Cache with WebView
• By default, webView control caches all
request and response
• Some of the filenames are –
– webviewCache.db
– webview.db-shm
– webview.db-wal
– webviewCookiesChromium.db
– webviewCookiesChromiumPrivate.db
– imagecache.db
© Blueinfy Solutions
Sample code to clear the cache
© Blueinfy Solutions
SSL Implementation
• Application sends request to server over SSL
(Secure Way)
• Most application fails to handle SSL certificate
validation error on the client side
• Only certificate from the OWNER server and
sub-domain should be allowed
© Blueinfy Solutions
Verify SSL Server – Sample Code
© Blueinfy Solutions
Copy/Paste in the text fields
• Services are shared between all the
applications
• Attacker can write malicious program to
monitor clipboard to get access to sensitive
data if copy/paste is not disabled
• Copy/Paste must be disabled on the sensitive
fields
© Blueinfy Solutions
Screenshot in temporary files
• Pressing HOME button takes screenshot of the
last screen and saves it in local storage
• To disable this, manifest file needs to be
updated under Activity Tag
© Blueinfy Solutions
Protecting IP
• Unlike iOS, there is no encryption supported
by android platform
• Possible to Decompile binary and get access to
source code
• “ProGuard” can be leveraged to protect
against Decompile
© Blueinfy Solutions
Code Analysis with AppCodeScan
• Semi automated tool
• Ability to expand with custom rules
• Simple tracing utility to verify and track
vulnerabilities
• Simple HTML reporting which can be
converted to PDF
© Blueinfy Solutions
Sample Rules - Android
© Blueinfy Solutions
Conclusion

More Related Content

What's hot (20)

PDF
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Sam Bowne
 
PDF
CNIT 129S - Ch 3: Web Application Technologies
Sam Bowne
 
PDF
CNIT 129S: Securing Web Applications Ch 1-2
Sam Bowne
 
PDF
CNIT 129S: Ch 3: Web Application Technologies
Sam Bowne
 
PPTX
Using & Abusing APIs: An Examination of the API Attack Surface
CA API Management
 
PPTX
Api security
teodorcotruta
 
PDF
CNIT 129: 6. Attacking Authentication
Sam Bowne
 
PDF
Protecting Your APIs Against Attack & Hijack
CA API Management
 
PDF
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
Sam Bowne
 
PDF
Security vulnerabilities decomposition
Katy Anton
 
PPTX
Deep thoughts from the real world of azure
Michele Leroux Bustamante
 
PDF
CNIT 129S: Ch 5: Bypassing Client-Side Controls
Sam Bowne
 
PDF
CNIT 129S: Ch 6: Attacking Authentication
Sam Bowne
 
PDF
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
Sam Bowne
 
PDF
CNIT 129S: Ch 4: Mapping the Application
Sam Bowne
 
PDF
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
Sam Bowne
 
PPTX
Core defense mechanisms against security attacks on web applications
Karan Nagrecha
 
PDF
CNIT 129S: 8: Attacking Access Controls
Sam Bowne
 
PDF
CNIT 129S - Ch 6a: Attacking Authentication
Sam Bowne
 
PPTX
Design Practices for a Secure Azure Solution
Michele Leroux Bustamante
 
Ch 1: Web Application (In)security & Ch 2: Core Defense Mechanisms
Sam Bowne
 
CNIT 129S - Ch 3: Web Application Technologies
Sam Bowne
 
CNIT 129S: Securing Web Applications Ch 1-2
Sam Bowne
 
CNIT 129S: Ch 3: Web Application Technologies
Sam Bowne
 
Using & Abusing APIs: An Examination of the API Attack Surface
CA API Management
 
Api security
teodorcotruta
 
CNIT 129: 6. Attacking Authentication
Sam Bowne
 
Protecting Your APIs Against Attack & Hijack
CA API Management
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
Sam Bowne
 
Security vulnerabilities decomposition
Katy Anton
 
Deep thoughts from the real world of azure
Michele Leroux Bustamante
 
CNIT 129S: Ch 5: Bypassing Client-Side Controls
Sam Bowne
 
CNIT 129S: Ch 6: Attacking Authentication
Sam Bowne
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 1 of 2)
Sam Bowne
 
CNIT 129S: Ch 4: Mapping the Application
Sam Bowne
 
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
Sam Bowne
 
Core defense mechanisms against security attacks on web applications
Karan Nagrecha
 
CNIT 129S: 8: Attacking Access Controls
Sam Bowne
 
CNIT 129S - Ch 6a: Attacking Authentication
Sam Bowne
 
Design Practices for a Secure Azure Solution
Michele Leroux Bustamante
 

Similar to Android secure coding (20)

PPTX
Hacking Samsung's Tizen: The OS of Everything - Hack In the Box 2015
Ajin Abraham
 
PPTX
Covert Attack Mystery Box: A few novel techniques for exploiting Microsoft “f...
Beau Bullock
 
PDF
Pentesting Mobile Applications (Prashant Verma)
ClubHack
 
PDF
Evaluating iOS Applications
iphonepentest
 
PPTX
iOS application (in)security
iphonepentest
 
PPTX
Securing Sensitive Data with Azure Key Vault (Tom Kerkhove @ ITProceed)
Codit
 
PPTX
ITProceed 2015 - Securing Sensitive Data with Azure Key Vault
Tom Kerkhove
 
PDF
9 Writing Secure Android Applications
Sam Bowne
 
PPTX
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 4
Qualcomm Developer Network
 
PPTX
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Ajin Abraham
 
PPSX
Arcanum - Client side encryption based file storage service.
Yashin Mehaboobe
 
PPTX
Application security meetup - cloud security best practices 24062021
lior mazor
 
PPTX
What Does a Full Featured Security Strategy Look Like?
Precisely
 
PPTX
Securing private keys
Ahsan Habib
 
PDF
Zero Knowledge - End-to-end encryption in the browser with OpenPGP.js
Dane Schneider
 
PPTX
Encrypting and Protecting Your Data in Neo4j(Jeff_Tallman).pptx
Neo4j
 
PPT
iOS Application Pentesting
n|u - The Open Security Community
 
PPTX
Going outside the application
Matthew Saltzman
 
PDF
Information Security Whitepaper
run_frictionless
 
PDF
Securing .NET Core, ASP.NET Core applications
NETUserGroupBern
 
Hacking Samsung's Tizen: The OS of Everything - Hack In the Box 2015
Ajin Abraham
 
Covert Attack Mystery Box: A few novel techniques for exploiting Microsoft “f...
Beau Bullock
 
Pentesting Mobile Applications (Prashant Verma)
ClubHack
 
Evaluating iOS Applications
iphonepentest
 
iOS application (in)security
iphonepentest
 
Securing Sensitive Data with Azure Key Vault (Tom Kerkhove @ ITProceed)
Codit
 
ITProceed 2015 - Securing Sensitive Data with Azure Key Vault
Tom Kerkhove
 
9 Writing Secure Android Applications
Sam Bowne
 
Developing for Industrial IoT with Linux OS on DragonBoard™ 410c: Session 4
Qualcomm Developer Network
 
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Ajin Abraham
 
Arcanum - Client side encryption based file storage service.
Yashin Mehaboobe
 
Application security meetup - cloud security best practices 24062021
lior mazor
 
What Does a Full Featured Security Strategy Look Like?
Precisely
 
Securing private keys
Ahsan Habib
 
Zero Knowledge - End-to-end encryption in the browser with OpenPGP.js
Dane Schneider
 
Encrypting and Protecting Your Data in Neo4j(Jeff_Tallman).pptx
Neo4j
 
iOS Application Pentesting
n|u - The Open Security Community
 
Going outside the application
Matthew Saltzman
 
Information Security Whitepaper
run_frictionless
 
Securing .NET Core, ASP.NET Core applications
NETUserGroupBern
 
Ad

More from Blueinfy Solutions (13)

PDF
Mobile security chess board - attacks & defense
Blueinfy Solutions
 
PPT
Source Code Analysis with SAST
Blueinfy Solutions
 
PPT
HTML5 hacking
Blueinfy Solutions
 
PDF
CSRF, ClickJacking & Open Redirect
Blueinfy Solutions
 
PPT
XSS - Attacks & Defense
Blueinfy Solutions
 
PPT
Defending against Injections
Blueinfy Solutions
 
PPT
XPATH, LDAP and Path Traversal Injection
Blueinfy Solutions
 
PPT
Blind SQL Injection
Blueinfy Solutions
 
PPT
Application fuzzing
Blueinfy Solutions
 
PPT
SQL injection basics
Blueinfy Solutions
 
PPT
Assessment methodology and approach
Blueinfy Solutions
 
PPT
HTTP protocol and Streams Security
Blueinfy Solutions
 
PPT
Advanced applications-architecture-threats
Blueinfy Solutions
 
Mobile security chess board - attacks & defense
Blueinfy Solutions
 
Source Code Analysis with SAST
Blueinfy Solutions
 
HTML5 hacking
Blueinfy Solutions
 
CSRF, ClickJacking & Open Redirect
Blueinfy Solutions
 
XSS - Attacks & Defense
Blueinfy Solutions
 
Defending against Injections
Blueinfy Solutions
 
XPATH, LDAP and Path Traversal Injection
Blueinfy Solutions
 
Blind SQL Injection
Blueinfy Solutions
 
Application fuzzing
Blueinfy Solutions
 
SQL injection basics
Blueinfy Solutions
 
Assessment methodology and approach
Blueinfy Solutions
 
HTTP protocol and Streams Security
Blueinfy Solutions
 
Advanced applications-architecture-threats
Blueinfy Solutions
 
Ad

Recently uploaded (20)

PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 

Android secure coding

  • 1. © Blueinfy Solutions Secure Coding For Android Applications
  • 2. © Blueinfy Solutions Local Storage - Example • Remember me option – NOT SECURE WAY
  • 3. © Blueinfy Solutions Token stored • On local file – NOT SECURE WAY
  • 4. © Blueinfy Solutions Shared Preferences • SHARED PREFERENCE – NOT SECURE WAY
  • 5. © Blueinfy Solutions Writing to file • When opening file for writing, make sure to open it in private mode as shown below – String FILENAME = “temp"; String string = “token”; FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE); fos.write(string.getBytes()); fos.close();
  • 6. © Blueinfy Solutions Local Storage – Secure Method • Encrypt the data using strong encryption, possibly AES • Do not decrypt the data at client side • Send Encrypted Data to the server • Server decrypts the data before validating it
  • 7. © Blueinfy Solutions Securing Secrets • AES encryption to store secret information and making secure storage. • APIs and Libs for it. • Random cookies and keys. • Not to open and shared storage. • Cache and File writing is not enough. • Design level strategy for it.
  • 8. © Blueinfy Solutions Secure Method – Sample Code
  • 9. © Blueinfy Solutions Sending Encrypted in JSON
  • 11. © Blueinfy Solutions Cache with WebView • By default, webView control caches all request and response • Some of the filenames are – – webviewCache.db – webview.db-shm – webview.db-wal – webviewCookiesChromium.db – webviewCookiesChromiumPrivate.db – imagecache.db
  • 12. © Blueinfy Solutions Sample code to clear the cache
  • 13. © Blueinfy Solutions SSL Implementation • Application sends request to server over SSL (Secure Way) • Most application fails to handle SSL certificate validation error on the client side • Only certificate from the OWNER server and sub-domain should be allowed
  • 14. © Blueinfy Solutions Verify SSL Server – Sample Code
  • 15. © Blueinfy Solutions Copy/Paste in the text fields • Services are shared between all the applications • Attacker can write malicious program to monitor clipboard to get access to sensitive data if copy/paste is not disabled • Copy/Paste must be disabled on the sensitive fields
  • 16. © Blueinfy Solutions Screenshot in temporary files • Pressing HOME button takes screenshot of the last screen and saves it in local storage • To disable this, manifest file needs to be updated under Activity Tag
  • 17. © Blueinfy Solutions Protecting IP • Unlike iOS, there is no encryption supported by android platform • Possible to Decompile binary and get access to source code • “ProGuard” can be leveraged to protect against Decompile
  • 18. © Blueinfy Solutions Code Analysis with AppCodeScan • Semi automated tool • Ability to expand with custom rules • Simple tracing utility to verify and track vulnerabilities • Simple HTML reporting which can be converted to PDF
  • 19. © Blueinfy Solutions Sample Rules - Android