SlideShare a Scribd company logo
Ch 6: Mobile Services and 

Mobile Web

Part 1
CNIT 128:
Hacking Mobile
Devices
Updated 2-22-17
Ch 6 Part 1
Through OAuth
Part 2 starts with SAML
Server-Side Technologies
• SQL (Structured Query Language)
– Servers that manage databases
– Contain SSNs, credit card numbers,
sometimes passwords, etc.
Server-Side Technologies
• SOAP (Simple Object Access Protocol)
– XML-based middleware to exchange data
between servers and clients
– Can operate over any transport protocol such
as HTTP, SMTP, TCP, UDP, or JMS (link Ch 6a)
– Examples on next slides from link Ch 6l
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
JSON v. XML
• From link Ch 6n
JSON XML
Server-Side Technologies
• ReST (Representational State Transfer)
– Uses HTTP to transfer data between machines
– The World Wide Web can be viewed as a REST-
based architecture (link Ch 6c)
– Send data with PUT, get it with GET (link Ch 6n)
Server-Side Technologies
• JSON (JavaScript
Object Notation)
– Lightweight
data-interchange
format
– An alternative to
XML (link Ch 6b)
– Example from
link Ch 6m
Server-Side Vulnerabilities
• Expose far more data than client-side
vulnerabilities
• Larger attack surface than client
– Server runs services, some for clients, others
for business logic, internal interfaces,
databases, partner interfaces, etc.
General Web Service Security
Guidelines:
OWASP Top Ten Mobile Risks
2016
Link Ch 6k
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)
Attacks Against XML-Based
Web Services
Security Audit of XML-Based Web
Service
• Identify web service endpoints
– By examining source code of client
– Or examining Web traffic while client runs
• Craft legitimate web service requests
– For all endpoints and operations
• Vulnerability Discovery
– By altering structure of contents of XML
documents sent to the web service endpoints
Web Services Description Language
(WSDL)
• An XML-based
interface
description language
– Used to describe
functionality offered
by a Web service
– Image from
Wikipedia (link Ch
6f)
SoapUI
• SoapUI can build a set of base test cases given a
URL to an identified WDSL
– Link Ch 6g
XML Injection Example
• Client sends
<?xml version="1.0"?>
<ProductRequest>
<Id>584654</Id>
</ProductRequest>
• Sever replies, echoing Id from client
<?xml version="1.0"?>
<ProductResponse>
<Id>584654</Id>
<Price>199.99</Price>
</ProductResponse>
XML Injection Example
• Client sends an Id of
584654</Id><Price>0.99</Price>
</ProductResponse>
<ProductResponse><Id>123
• Sever reply becomes
<?xml version="1.0"?>
<ProductResponse>
<Id>584654</Id><Price>0.99</Price>
</ProductResponse>
<ProductResponse><Id>123
</Id>
<Price>199.99</Price>
</ProductResponse>
Effect of XML Injection
• Depends on how server handles a strange
response like that
• Most would accept the first XML portion
with the modified price
XML Injection Countermeasures
• Input validation
– Best done with whitelisting (allowing only
known-good characters)
• Output encoding
– Change "<" to "&lt;"
• Use encoding functions from a trusted
source, such as OWASP
XML Entity Expansion
• A Denial-of-Service (DoS) attack using XML
entities that expand greatly at process
time
• The example sends a 662-byte request
that expands to 20 MB at the server
• Enough of these requests can stop a
server by RAM exhaustion
XML Entity Expansion
<?xml version="1.0"?>
<!DOCTYPE root [ <ENTITY a1 "I've often
seen a cat without a grin..."> ]>
<someElement1><someElement2>&a1;

</someElement2></someElement1>
Expands to
<?xml version="1.0"?>
<someElement1><someElement2>
I've often seen a cat without a grin...</
someElement2></someElement1>
XML Entity Expansion Example
POST /SomeWebServiceEndpoint HTTP/1.1
Host: www.example.com
Content-Length: 662
<?xml version="1.0"?>
<!DOCTYPE root [
<ENTITY a1 "I've often seen a cat without a grin...">
<ENTITY a2 "&a1;&a1;"><ENTITY a3 "&a2;&a2;">
<ENTITY a4 "&a3;&a3;"><ENTITY a5 "&a4;&a4;">
...
<ENTITY a20 "&a19;&a19;">
]>
<someElement1><someElement2>&a20;</someElement2></
someElement1>
XML Entity Expansion Countermeasures
• Disable Document Type Definitions (DTDs)
in the XML parser
• Set a limit on the depth of entity
expansions in the parser
• Note: phones have XML parsers too, and
can be attacked the same way
– The iOS NSXMLParser parser is protected
– But not Android's SAXParser
XML Entity Reference
• Abuse XML entities to acquire the
contents of files on the Web server
• The example on the next page defines an
external entity reference "fileContents"
that points to the hosts file on Windows
and uses it
XML Entity Reference Example
POST /SomeWebServiceEndpoint HTTP/1.1
Host: www.example.com
Content-Length: 196
<?xml version="1.0"?>
<!DOCTYPE fileDocType = [
<ENTITY fileContents SYSTEM "C:Windows
System32driversetchosts">
]>
<someElement1><someElement2>&fileContents;</
someElement2></someElement1>
XML Entity Reference
• If the XML parser supports DTDs with
external entities
– Many parsers do by default
– The parser will fetch the host file and may
display the file in the XML response to the
attacker
– It's limited only by file permissions
– If the Web service runs as root, it can read
any file
XML Entity Reference
• Can be used for DoS by
– Requesting a special device file, or
– Forcing the parser to make many HTTP
requests to remote resources, exhausting the
network connection pool
XML Entity Reference Countermeasures
• Disable DTDs altogether if you don't need
them
• Allow DTDs that contain general entities,
but
– Prevent the processing of external entities
• Set up an EntityResolver object to limit
access to a whitelist of resources
XML Entity Reference
• Can attack phones too
– Android is vulnerable and the same
countermeasures apply
– The iOS NSXMLParser class does not handle
external entities by default, but a developer
can enable this dangerous functionality
Common Authentication and
Authorization Frameworks
Authentication Issues
• Web apps typically authenticate with
passwords
– So do mobile apps
• Users don't want to type in the password
every time they use an app
– Storing user's credentials in plaintext is
unwise
Credential Storage Options
• Secure Element (SE)
– A special tamper-resistant hardware component
– Not present in all phones, although some have
one for NFC payment (link Ch 6h)
• Authorization Framework
– Such as OAuth
– First authenticates a user with a password
– Creates a token to be stored on the phone
– Less valuable than a password to an attacker
Recommendations
• Token can be made less dangerous
– Set reasonable expiration dates
– Restrict token's scope
– Revoke tokens that are known to be
compromised
• For financial apps
– Don't store any token at all on client-side
– Force the user to authenticate each time the
app is used
OAuth 2 

Open Authorization
• Popular
– Used by Google, Facebook, Yahoo!, LinkedIn,
and PayPal
• Allows one app to access protected
resources in another app without knowing
the user's credentials
– Like Microsoft's Federated Identity
Management
Main Actors in OAuth 2
• Resource owner
– End-user with access to credentials, who
owns the protected resources
• Resource server
– Server hosting protected resources
– Allows client access to the protected
resources when provided a valid access token
Main Actors in OAuth 2
• Client
– App seeking to access protected resources
– Typically a mobile app or web app
• Authorization Server
– Server that provides the client application
with access tokens
• After the resource owner has provided valid
credentials
OAuth 2 has Four Grant Types
• Client Credentials Grant
• Resource Owner Password Credentials Grant
• Authorization Code Grant
• Implicit Grant
• "User Agent" in these diagrams is either your
mobile browser or a WebView component
embedded within the application
OAuth Client Credentials Grant
• Stores password on client
• Should only be used for confidential clients
– That can maintain the confidentiality of their credentials
• Not usually appropriate for mobile devices because
of device theft
OAuth Client Credentials Grant
• OK if mobile app has access to a Secure
Element (SE)
– But most mobile apps cannot interface with a SE
• This grant type should be avoided
– Unless app takes additional steps to protect
authentication info
– Such as forcing user to enter a complex password
every time the app launches
– Password used to encrypt/decrypt authentication
info
OAuth Resource Owner Password
Credentials Grant Type
• App is trusted with credentials, but need not
save them
• It can save the token instead
OAuth Resource Owner Password
Credentials Grant Type
• OK if
– Client app is trusted not to leak credentials
to a third party
– Same entity controls authorization server,
resource server, and client app
• Better than storing credentials in
plaintext on the mobile device and
submitting them in every HTTP request
OAuth Authorization Code Grant Type
OAuth Authorization Code Grant Type
• 1. Client directs user-agent (browser or
WebView component) to authorization
endpoint
• Request includes
– Client identifier
– Requested scope
– Local state
– Redirection URI
Using Mobile WebView to Steal
Credentials
• In theory, client app cannot access resource
owner's credentials
– Because resource owner types credentials on
the authorization server's web page
– Via user-agent, typically a browser
• If a mobile app uses a WebView component
instead of an external mobile browser
– Client app can steal credentials with malicious
JavaScript
URL Redirection Attacks
• The URI in steps 1 and 4 could be
malicious, sending the client to a
dangerous website
– This could phish users, or steal tokens
• URIs should be validated, and enforced to
be equal in steps 1 and 4
OAuth Implicit Grant Type
https://samsclass.info/128/128_S15.shtml#projects
• The "#projects" is a fragment
• Not sent to server in HTTP request
– Used only by the browser to display the specified
potion of the page
– Link Ch 6i
OAuth Implicit Grant Type
• Token not sent to server in step 4
• In step 5, server sends JavaScript to get the
token
• Intermediate servers cannot see data
stored in the fragment
• Fragment does not appear in an
unencrypted form in client or web server
logs
– Limits some information leakage vulnerabilities
General OAuth Threats
Lack of TLS Enforcement
• OAuth does not support message-level
confidentiality or integrity
• Must use TLS to prevent sniffing of
– Authorization tokens
– Refresh tokens
– Access tokens
– Resource owner credentials
Cross-Site Request Forgery (CSRF)
• Attacker can steal a token by tricking the
user into visiting a malicious URL like
<img src="http://www.example.com/
oauth_endpoint?code=attacker_code">
• Will steal token
• Tokens can be re-used, unless optional
"state" parameter is enabled in OAuth 2
Improper Storage of Sensitive Data
• Server-side has many tokens and
credentials
• Must be secured against attack with
cryptographic controls
Overly Scoped Access Tokens
• Scope: level of access a token grants
• Token may enable
– Sending social networking messages on your
behalf, or
– Merely viewing portions of your social
messaging profile
• Follow principle of least privilege
Lack of Token Expiration
• Tokens that don't expire and are overly
scoped are almost as good as stealing
credentials
– Sometimes even better
– A password reset may not cause old tokens to
expire

More Related Content

What's hot (20)

PDF
CNIT 129S: Ch 6: Attacking Authentication
Sam Bowne
 
PPT
Android secure coding
Blueinfy Solutions
 
PDF
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
Sam Bowne
 
PDF
Mobile Application Scan and Testing
Blueinfy Solutions
 
PPTX
Core defense mechanisms against security attacks on web applications
Karan Nagrecha
 
PDF
Mobile Authentication - Moving Towards a Passwordless Future
ForgeRock Identity Tech Talks
 
PDF
Defcon 22-alex zacharis-nikolaos-tsagkarakis-po s-attacking-t
Priyanka Aash
 
PPTX
Securing Microservices with Spring Cloud Security
Will Tran
 
PPT
iOS Application Security Testing
Blueinfy Solutions
 
PDF
CNIT 129S - Ch 6a: Attacking Authentication
Sam Bowne
 
PDF
Two-factor Authentication
PortalGuard dba PistolStar, Inc.
 
PPT
Mobile Application Security – Effective methodology, efficient testing!
espheresecurity
 
PDF
Two Factor Authentication and You
Chris Stone
 
PDF
CNIT 129S: 8: Attacking Access Controls
Sam Bowne
 
PDF
Mobile security chess board - attacks & defense
Blueinfy Solutions
 
PPT
Applciation footprinting, discovery and enumeration
Blueinfy Solutions
 
PDF
CNIT 128 7. Attacking Android Applications (Part 3)
Sam Bowne
 
PDF
Secure Elements in Web Applications
Olivier Potonniée
 
PPTX
The presentation on my "Shadow Admins" research
Asaf Hecht
 
PDF
Security testing in mobile applications
Jose Manuel Ortega Candel
 
CNIT 129S: Ch 6: Attacking Authentication
Sam Bowne
 
Android secure coding
Blueinfy Solutions
 
CNIT 129S: 13: Attacking Users: Other Techniques (Part 2 of 2)
Sam Bowne
 
Mobile Application Scan and Testing
Blueinfy Solutions
 
Core defense mechanisms against security attacks on web applications
Karan Nagrecha
 
Mobile Authentication - Moving Towards a Passwordless Future
ForgeRock Identity Tech Talks
 
Defcon 22-alex zacharis-nikolaos-tsagkarakis-po s-attacking-t
Priyanka Aash
 
Securing Microservices with Spring Cloud Security
Will Tran
 
iOS Application Security Testing
Blueinfy Solutions
 
CNIT 129S - Ch 6a: Attacking Authentication
Sam Bowne
 
Two-factor Authentication
PortalGuard dba PistolStar, Inc.
 
Mobile Application Security – Effective methodology, efficient testing!
espheresecurity
 
Two Factor Authentication and You
Chris Stone
 
CNIT 129S: 8: Attacking Access Controls
Sam Bowne
 
Mobile security chess board - attacks & defense
Blueinfy Solutions
 
Applciation footprinting, discovery and enumeration
Blueinfy Solutions
 
CNIT 128 7. Attacking Android Applications (Part 3)
Sam Bowne
 
Secure Elements in Web Applications
Olivier Potonniée
 
The presentation on my "Shadow Admins" research
Asaf Hecht
 
Security testing in mobile applications
Jose Manuel Ortega Candel
 

Viewers also liked (20)

PDF
CNIT 127 Lecture 7: Intro to 64-Bit Assembler (not in book)
Sam Bowne
 
PDF
CNIT 128 5: Mobile malware
Sam Bowne
 
PDF
Ch 4: Footprinting and Social Engineering
Sam Bowne
 
PDF
CNIT 127 Ch 2: Stack overflows on Linux
Sam Bowne
 
PDF
CNIT 123 Ch 1: Ethical Hacking Overview
Sam Bowne
 
PDF
Ch 8: Desktop and Server OS Vulnerabilites
Sam Bowne
 
PDF
Ch 9: Embedded Operating Systems: The Hidden Threat
Sam Bowne
 
PDF
Ch 3: Network and Computer Attacks
Sam Bowne
 
PDF
Ch 2: TCP/IP Concepts Review
Sam Bowne
 
PDF
CNIT 127 Ch 5: Introduction to heap overflows
Sam Bowne
 
PDF
Ch 6: Enumeration
Sam Bowne
 
PDF
Ch 7: Programming for Security Professionals
Sam Bowne
 
PDF
Ch 12: Cryptography
Sam Bowne
 
PDF
Ch 13: Network Protection Systems
Sam Bowne
 
PDF
Ch 10: Hacking Web Servers
Sam Bowne
 
PDF
Practical Malware Analysis: Ch 15: Anti-Disassembly
Sam Bowne
 
PDF
Ch 5: Port Scanning
Sam Bowne
 
PDF
CNIT 127: Ch 8: Windows overflows (Part 1)
Sam Bowne
 
KEY
Mobile Services on a Shoestring
Sarah Houghton
 
PDF
mobile online services
Roche Labtang
 
CNIT 127 Lecture 7: Intro to 64-Bit Assembler (not in book)
Sam Bowne
 
CNIT 128 5: Mobile malware
Sam Bowne
 
Ch 4: Footprinting and Social Engineering
Sam Bowne
 
CNIT 127 Ch 2: Stack overflows on Linux
Sam Bowne
 
CNIT 123 Ch 1: Ethical Hacking Overview
Sam Bowne
 
Ch 8: Desktop and Server OS Vulnerabilites
Sam Bowne
 
Ch 9: Embedded Operating Systems: The Hidden Threat
Sam Bowne
 
Ch 3: Network and Computer Attacks
Sam Bowne
 
Ch 2: TCP/IP Concepts Review
Sam Bowne
 
CNIT 127 Ch 5: Introduction to heap overflows
Sam Bowne
 
Ch 6: Enumeration
Sam Bowne
 
Ch 7: Programming for Security Professionals
Sam Bowne
 
Ch 12: Cryptography
Sam Bowne
 
Ch 13: Network Protection Systems
Sam Bowne
 
Ch 10: Hacking Web Servers
Sam Bowne
 
Practical Malware Analysis: Ch 15: Anti-Disassembly
Sam Bowne
 
Ch 5: Port Scanning
Sam Bowne
 
CNIT 127: Ch 8: Windows overflows (Part 1)
Sam Bowne
 
Mobile Services on a Shoestring
Sarah Houghton
 
mobile online services
Roche Labtang
 
Ad

Similar to CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth) (20)

PDF
- Webexpo 2010
Petr Dvorak
 
PDF
Petr Dvořák: Mobilní webové služby pohledem iPhone developera
WebExpo
 
PDF
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...
CA API Management
 
PDF
JDD2015: Security in the era of modern applications and services - Bolesław D...
PROIDEA
 
PDF
Implementing Microservices Security Patterns & Protocols with Spring
VMware Tanzu
 
PPTX
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
Brian Campbell
 
PPTX
Api security
teodorcotruta
 
PPT
Open Id, O Auth And Webservices
Myles Eftos
 
PDF
Api security with OAuth
thariyarox
 
PDF
Analyzing OAuth
Oliver Pfaff
 
PDF
OAuth and OEmbed
leahculver
 
PPTX
OAuth
Adi Challa
 
PPT
Web Services Presentation - Introduction, Vulnerabilities, & Countermeasures
Praetorian
 
PPTX
API Management and Mobile App Enablement
CA API Management
 
PPTX
Saas webinar-dec6-01
Paul Madsen
 
PDF
API SECURITY
Tubagus Rizky Dharmawan
 
PDF
API Security Best Practices & Guidelines
Prabath Siriwardena
 
PPTX
Security Avalanche
Michele Leroux Bustamante
 
PPTX
Enterprise Access Control Patterns for REST and Web APIs Gluecon 2011, Franco...
CA API Management
 
PPTX
Oauth2 and OWSM OAuth2 support
Gaurav Sharma
 
- Webexpo 2010
Petr Dvorak
 
Petr Dvořák: Mobilní webové služby pohledem iPhone developera
WebExpo
 
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...
CA API Management
 
JDD2015: Security in the era of modern applications and services - Bolesław D...
PROIDEA
 
Implementing Microservices Security Patterns & Protocols with Spring
VMware Tanzu
 
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
Brian Campbell
 
Api security
teodorcotruta
 
Open Id, O Auth And Webservices
Myles Eftos
 
Api security with OAuth
thariyarox
 
Analyzing OAuth
Oliver Pfaff
 
OAuth and OEmbed
leahculver
 
OAuth
Adi Challa
 
Web Services Presentation - Introduction, Vulnerabilities, & Countermeasures
Praetorian
 
API Management and Mobile App Enablement
CA API Management
 
Saas webinar-dec6-01
Paul Madsen
 
API Security Best Practices & Guidelines
Prabath Siriwardena
 
Security Avalanche
Michele Leroux Bustamante
 
Enterprise Access Control Patterns for REST and Web APIs Gluecon 2011, Franco...
CA API Management
 
Oauth2 and OWSM OAuth2 support
Gaurav Sharma
 
Ad

More from Sam Bowne (20)

PDF
Introduction to the Class & CISSP Certification
Sam Bowne
 
PDF
Cyberwar
Sam Bowne
 
PDF
3: DNS vulnerabilities
Sam Bowne
 
PDF
8. Software Development Security
Sam Bowne
 
PDF
4 Mapping the Application
Sam Bowne
 
PDF
3. Attacking iOS Applications (Part 2)
Sam Bowne
 
PDF
12 Elliptic Curves
Sam Bowne
 
PDF
11. Diffie-Hellman
Sam Bowne
 
PDF
2a Analyzing iOS Apps Part 1
Sam Bowne
 
PDF
9 Writing Secure Android Applications
Sam Bowne
 
PDF
12 Investigating Windows Systems (Part 2 of 3)
Sam Bowne
 
PDF
10 RSA
Sam Bowne
 
PDF
12 Investigating Windows Systems (Part 1 of 3
Sam Bowne
 
PDF
9. Hard Problems
Sam Bowne
 
PDF
8 Android Implementation Issues (Part 1)
Sam Bowne
 
PDF
11 Analysis Methodology
Sam Bowne
 
PDF
8. Authenticated Encryption
Sam Bowne
 
PDF
7. Attacking Android Applications (Part 2)
Sam Bowne
 
PDF
7. Attacking Android Applications (Part 1)
Sam Bowne
 
PDF
5. Stream Ciphers
Sam Bowne
 
Introduction to the Class & CISSP Certification
Sam Bowne
 
Cyberwar
Sam Bowne
 
3: DNS vulnerabilities
Sam Bowne
 
8. Software Development Security
Sam Bowne
 
4 Mapping the Application
Sam Bowne
 
3. Attacking iOS Applications (Part 2)
Sam Bowne
 
12 Elliptic Curves
Sam Bowne
 
11. Diffie-Hellman
Sam Bowne
 
2a Analyzing iOS Apps Part 1
Sam Bowne
 
9 Writing Secure Android Applications
Sam Bowne
 
12 Investigating Windows Systems (Part 2 of 3)
Sam Bowne
 
10 RSA
Sam Bowne
 
12 Investigating Windows Systems (Part 1 of 3
Sam Bowne
 
9. Hard Problems
Sam Bowne
 
8 Android Implementation Issues (Part 1)
Sam Bowne
 
11 Analysis Methodology
Sam Bowne
 
8. Authenticated Encryption
Sam Bowne
 
7. Attacking Android Applications (Part 2)
Sam Bowne
 
7. Attacking Android Applications (Part 1)
Sam Bowne
 
5. Stream Ciphers
Sam Bowne
 

Recently uploaded (20)

PDF
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
PDF
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PPTX
How to Configure Storno Accounting in Odoo 18 Accounting
Celine George
 
PPTX
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PPTX
How to Define Translation to Custom Module And Add a new language in Odoo 18
Celine George
 
PDF
Federal dollars withheld by district, charter, grant recipient
Mebane Rash
 
PPTX
Accounting Skills Paper-I, Preparation of Vouchers
Dr. Sushil Bansode
 
PPTX
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
PPTX
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
PPTX
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
ROLE OF ANTIOXIDANT IN EYE HEALTH MANAGEMENT.pptx
Subham Panja
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
SCHOOL-BASED SEXUAL HARASSMENT PREVENTION AND RESPONSE WORKSHOP
komlalokoe
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
How to Configure Storno Accounting in Odoo 18 Accounting
Celine George
 
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
How to Define Translation to Custom Module And Add a new language in Odoo 18
Celine George
 
Federal dollars withheld by district, charter, grant recipient
Mebane Rash
 
Accounting Skills Paper-I, Preparation of Vouchers
Dr. Sushil Bansode
 
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
ROLE OF ANTIOXIDANT IN EYE HEALTH MANAGEMENT.pptx
Subham Panja
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
SCHOOL-BASED SEXUAL HARASSMENT PREVENTION AND RESPONSE WORKSHOP
komlalokoe
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 

CNIT 128: 6: Mobile services and mobile Web (part 1: Beginning Through OAuth)

  • 1. Ch 6: Mobile Services and 
 Mobile Web
 Part 1 CNIT 128: Hacking Mobile Devices Updated 2-22-17
  • 2. Ch 6 Part 1 Through OAuth Part 2 starts with SAML
  • 3. Server-Side Technologies • SQL (Structured Query Language) – Servers that manage databases – Contain SSNs, credit card numbers, sometimes passwords, etc.
  • 4. Server-Side Technologies • SOAP (Simple Object Access Protocol) – XML-based middleware to exchange data between servers and clients – Can operate over any transport protocol such as HTTP, SMTP, TCP, UDP, or JMS (link Ch 6a) – Examples on next slides from link Ch 6l
  • 7. JSON v. XML • From link Ch 6n JSON XML
  • 8. Server-Side Technologies • ReST (Representational State Transfer) – Uses HTTP to transfer data between machines – The World Wide Web can be viewed as a REST- based architecture (link Ch 6c) – Send data with PUT, get it with GET (link Ch 6n)
  • 9. Server-Side Technologies • JSON (JavaScript Object Notation) – Lightweight data-interchange format – An alternative to XML (link Ch 6b) – Example from link Ch 6m
  • 10. Server-Side Vulnerabilities • Expose far more data than client-side vulnerabilities • Larger attack surface than client – Server runs services, some for clients, others for business logic, internal interfaces, databases, partner interfaces, etc.
  • 11. General Web Service Security Guidelines: OWASP Top Ten Mobile Risks 2016 Link Ch 6k
  • 15. Security Audit of XML-Based Web Service • Identify web service endpoints – By examining source code of client – Or examining Web traffic while client runs • Craft legitimate web service requests – For all endpoints and operations • Vulnerability Discovery – By altering structure of contents of XML documents sent to the web service endpoints
  • 16. Web Services Description Language (WSDL) • An XML-based interface description language – Used to describe functionality offered by a Web service – Image from Wikipedia (link Ch 6f)
  • 17. SoapUI • SoapUI can build a set of base test cases given a URL to an identified WDSL – Link Ch 6g
  • 18. XML Injection Example • Client sends <?xml version="1.0"?> <ProductRequest> <Id>584654</Id> </ProductRequest> • Sever replies, echoing Id from client <?xml version="1.0"?> <ProductResponse> <Id>584654</Id> <Price>199.99</Price> </ProductResponse>
  • 19. XML Injection Example • Client sends an Id of 584654</Id><Price>0.99</Price> </ProductResponse> <ProductResponse><Id>123 • Sever reply becomes <?xml version="1.0"?> <ProductResponse> <Id>584654</Id><Price>0.99</Price> </ProductResponse> <ProductResponse><Id>123 </Id> <Price>199.99</Price> </ProductResponse>
  • 20. Effect of XML Injection • Depends on how server handles a strange response like that • Most would accept the first XML portion with the modified price
  • 21. XML Injection Countermeasures • Input validation – Best done with whitelisting (allowing only known-good characters) • Output encoding – Change "<" to "&lt;" • Use encoding functions from a trusted source, such as OWASP
  • 22. XML Entity Expansion • A Denial-of-Service (DoS) attack using XML entities that expand greatly at process time • The example sends a 662-byte request that expands to 20 MB at the server • Enough of these requests can stop a server by RAM exhaustion
  • 23. XML Entity Expansion <?xml version="1.0"?> <!DOCTYPE root [ <ENTITY a1 "I've often seen a cat without a grin..."> ]> <someElement1><someElement2>&a1;
 </someElement2></someElement1> Expands to <?xml version="1.0"?> <someElement1><someElement2> I've often seen a cat without a grin...</ someElement2></someElement1>
  • 24. XML Entity Expansion Example POST /SomeWebServiceEndpoint HTTP/1.1 Host: www.example.com Content-Length: 662 <?xml version="1.0"?> <!DOCTYPE root [ <ENTITY a1 "I've often seen a cat without a grin..."> <ENTITY a2 "&a1;&a1;"><ENTITY a3 "&a2;&a2;"> <ENTITY a4 "&a3;&a3;"><ENTITY a5 "&a4;&a4;"> ... <ENTITY a20 "&a19;&a19;"> ]> <someElement1><someElement2>&a20;</someElement2></ someElement1>
  • 25. XML Entity Expansion Countermeasures • Disable Document Type Definitions (DTDs) in the XML parser • Set a limit on the depth of entity expansions in the parser • Note: phones have XML parsers too, and can be attacked the same way – The iOS NSXMLParser parser is protected – But not Android's SAXParser
  • 26. XML Entity Reference • Abuse XML entities to acquire the contents of files on the Web server • The example on the next page defines an external entity reference "fileContents" that points to the hosts file on Windows and uses it
  • 27. XML Entity Reference Example POST /SomeWebServiceEndpoint HTTP/1.1 Host: www.example.com Content-Length: 196 <?xml version="1.0"?> <!DOCTYPE fileDocType = [ <ENTITY fileContents SYSTEM "C:Windows System32driversetchosts"> ]> <someElement1><someElement2>&fileContents;</ someElement2></someElement1>
  • 28. XML Entity Reference • If the XML parser supports DTDs with external entities – Many parsers do by default – The parser will fetch the host file and may display the file in the XML response to the attacker – It's limited only by file permissions – If the Web service runs as root, it can read any file
  • 29. XML Entity Reference • Can be used for DoS by – Requesting a special device file, or – Forcing the parser to make many HTTP requests to remote resources, exhausting the network connection pool
  • 30. XML Entity Reference Countermeasures • Disable DTDs altogether if you don't need them • Allow DTDs that contain general entities, but – Prevent the processing of external entities • Set up an EntityResolver object to limit access to a whitelist of resources
  • 31. XML Entity Reference • Can attack phones too – Android is vulnerable and the same countermeasures apply – The iOS NSXMLParser class does not handle external entities by default, but a developer can enable this dangerous functionality
  • 33. Authentication Issues • Web apps typically authenticate with passwords – So do mobile apps • Users don't want to type in the password every time they use an app – Storing user's credentials in plaintext is unwise
  • 34. Credential Storage Options • Secure Element (SE) – A special tamper-resistant hardware component – Not present in all phones, although some have one for NFC payment (link Ch 6h) • Authorization Framework – Such as OAuth – First authenticates a user with a password – Creates a token to be stored on the phone – Less valuable than a password to an attacker
  • 35. Recommendations • Token can be made less dangerous – Set reasonable expiration dates – Restrict token's scope – Revoke tokens that are known to be compromised • For financial apps – Don't store any token at all on client-side – Force the user to authenticate each time the app is used
  • 36. OAuth 2 
 Open Authorization • Popular – Used by Google, Facebook, Yahoo!, LinkedIn, and PayPal • Allows one app to access protected resources in another app without knowing the user's credentials – Like Microsoft's Federated Identity Management
  • 37. Main Actors in OAuth 2 • Resource owner – End-user with access to credentials, who owns the protected resources • Resource server – Server hosting protected resources – Allows client access to the protected resources when provided a valid access token
  • 38. Main Actors in OAuth 2 • Client – App seeking to access protected resources – Typically a mobile app or web app • Authorization Server – Server that provides the client application with access tokens • After the resource owner has provided valid credentials
  • 39. OAuth 2 has Four Grant Types • Client Credentials Grant • Resource Owner Password Credentials Grant • Authorization Code Grant • Implicit Grant • "User Agent" in these diagrams is either your mobile browser or a WebView component embedded within the application
  • 40. OAuth Client Credentials Grant • Stores password on client • Should only be used for confidential clients – That can maintain the confidentiality of their credentials • Not usually appropriate for mobile devices because of device theft
  • 41. OAuth Client Credentials Grant • OK if mobile app has access to a Secure Element (SE) – But most mobile apps cannot interface with a SE • This grant type should be avoided – Unless app takes additional steps to protect authentication info – Such as forcing user to enter a complex password every time the app launches – Password used to encrypt/decrypt authentication info
  • 42. OAuth Resource Owner Password Credentials Grant Type • App is trusted with credentials, but need not save them • It can save the token instead
  • 43. OAuth Resource Owner Password Credentials Grant Type • OK if – Client app is trusted not to leak credentials to a third party – Same entity controls authorization server, resource server, and client app • Better than storing credentials in plaintext on the mobile device and submitting them in every HTTP request
  • 45. OAuth Authorization Code Grant Type • 1. Client directs user-agent (browser or WebView component) to authorization endpoint • Request includes – Client identifier – Requested scope – Local state – Redirection URI
  • 46. Using Mobile WebView to Steal Credentials • In theory, client app cannot access resource owner's credentials – Because resource owner types credentials on the authorization server's web page – Via user-agent, typically a browser • If a mobile app uses a WebView component instead of an external mobile browser – Client app can steal credentials with malicious JavaScript
  • 47. URL Redirection Attacks • The URI in steps 1 and 4 could be malicious, sending the client to a dangerous website – This could phish users, or steal tokens • URIs should be validated, and enforced to be equal in steps 1 and 4
  • 49. https://samsclass.info/128/128_S15.shtml#projects • The "#projects" is a fragment • Not sent to server in HTTP request – Used only by the browser to display the specified potion of the page – Link Ch 6i
  • 50. OAuth Implicit Grant Type • Token not sent to server in step 4 • In step 5, server sends JavaScript to get the token • Intermediate servers cannot see data stored in the fragment • Fragment does not appear in an unencrypted form in client or web server logs – Limits some information leakage vulnerabilities
  • 52. Lack of TLS Enforcement • OAuth does not support message-level confidentiality or integrity • Must use TLS to prevent sniffing of – Authorization tokens – Refresh tokens – Access tokens – Resource owner credentials
  • 53. Cross-Site Request Forgery (CSRF) • Attacker can steal a token by tricking the user into visiting a malicious URL like <img src="http://www.example.com/ oauth_endpoint?code=attacker_code"> • Will steal token • Tokens can be re-used, unless optional "state" parameter is enabled in OAuth 2
  • 54. Improper Storage of Sensitive Data • Server-side has many tokens and credentials • Must be secured against attack with cryptographic controls
  • 55. Overly Scoped Access Tokens • Scope: level of access a token grants • Token may enable – Sending social networking messages on your behalf, or – Merely viewing portions of your social messaging profile • Follow principle of least privilege
  • 56. Lack of Token Expiration • Tokens that don't expire and are overly scoped are almost as good as stealing credentials – Sometimes even better – A password reset may not cause old tokens to expire