AS UNIT - 3 Complete Rishi
AS UNIT - 3 Complete Rishi
AS UNIT - 3 Complete Rishi
UNIT-3
Introduction to Android Application Security:
Android, developed by Google, is the most widely used mobile operating system in the world, powering
billions of smartphones and tablets. With its popularity, Android has become a prime target for cyber
threats, making Android application security a critical concern for developers, businesses, and users
alike. This introduction will provide an overview of the importance of application security on the
Android platform and discuss the current state of mobile application security in this ecosystem.
Application Security:
Application security, in the context of Android, refers to the measures and practices aimed at
safeguarding the confidentiality, integrity, and availability of mobile applications and the data they
handle. This encompasses various aspects, including code vulnerabilities, data protection, user
authentication, and network communication security. Failing to secure Android applications adequately
can lead to a wide range of risks, such as data breaches, unauthorized access, malware infections, and
more.
2. Vulnerabilities: Mobile applications often contain vulnerabilities that can be exploited by attackers.
These vulnerabilities may result from poor coding practices, outdated libraries, and insufficient security
testing. Common vulnerabilities include SQL injection, cross-site scripting (XSS), insecure data storage,
and more.
3. App Markets and Side-Loading: The open nature of the Android ecosystem allows for the installation
of apps from various sources, not just the official Google Play Store. While this flexibility can be
beneficial, it also poses security risks as users might unknowingly install malicious apps from unofficial
sources.
4. User Data Privacy: Android applications frequently collect and store sensitive user data. The
mishandling of this data, including inadequate encryption and permissions, poses significant privacy
risks. Regulatory bodies, such as GDPR in Europe, have imposed stringent requirements for data
protection, making it crucial for app developers to comply with these regulations.
5. Security Patching: The Android ecosystem consists of numerous device manufacturers and carriers,
leading to fragmentation in terms of software updates. This fragmentation often results in delayed or
incomplete security patches, leaving devices and applications vulnerable to known threats.
8. Security Testing: Regular security testing, such as penetration testing and code reviews, is essential to
identify vulnerabilities in Android applications. Automated tools and manual testing can help discover
and address security flaws.
9. User Education: Users play a critical role in mobile application security. They should be educated on
how to identify and avoid potentially harmful applications and be cautious about granting excessive
permissions to apps.
- Threat: Threats are potential dangers or harmful events that can exploit vulnerabilities and cause
harm to an organization's assets. Threats can be natural, like earthquakes, or human-made, like
cyberattacks. Understanding the threat landscape helps organizations anticipate and defend against
specific risks.
- Consequences: Consequences refer to the potential impact or harm that may result from a
successful exploitation of vulnerabilities by threats. Consequences can include financial losses, damage
to reputation, legal consequences, data breaches, and more.
1. Physical Security: Information security initially focused on physical security measures like locked
doors, guards, and safes to protect paper records and physical assets.
2. Digital Security: With the advent of computers, information security extended to digital assets. This
involved user authentication, access controls, and encryption to safeguard data stored on early
computer systems.
3. Network Security: The growth of computer networks led to the development of network security
measures, including firewalls and intrusion detection systems, to protect data in transit.
4. Internet Era: The expansion of the internet introduced new security challenges. Cyber threats, such
as viruses, worms, and denial-of-service attacks, became more prominent. Antivirus software and secure
network protocols were developed to mitigate these threats.
5. Information Security Frameworks: Frameworks and standards like ISO 27001 and NIST were
established to provide organizations with structured approaches to information security. These
frameworks guide risk assessment, policy development, and security best practices.
6. Cybersecurity: As technology advanced, so did the threats. The term "cybersecurity" emerged to
encompass a broader range of security concerns, including protection against cyberattacks, data
breaches, and advanced persistent threats (APTs).
7. Cloud Security: With the adoption of cloud computing, new challenges emerged in securing data and
services hosted on remote servers. Cloud security solutions and best practices were developed to
address these concerns.
8. Mobile Security: The proliferation of smartphones and mobile apps brought mobile security into
focus. Mobile device management (MDM) and mobile application security became essential
components of information security.
9. IoT Security: The rise of the Internet of Things (IoT) introduced a vast array of connected devices.
Securing IoT devices and networks became a priority to prevent vulnerabilities and threats in this
expanding ecosystem.
10. AI and Machine Learning in Security: Artificial intelligence (AI) and machine learning (ML) are now
being used to detect and respond to security threats. These technologies help analyze vast amounts of
data to identify anomalous behavior and potential risks.
11. Zero Trust Security: Zero Trust is a modern security approach that assumes no trust, even inside the
network perimeter. It requires rigorous identity verification and continuous monitoring to protect
against insider threats and external attackers.
Secure software development is a set of practices and techniques aimed at designing and building
applications with security in mind from the very beginning. Here are some key techniques used in secure
software development:
1. Threat Modeling: This technique involves identifying potential threats and vulnerabilities in the early
stages of the software development life cycle. It helps in understanding the security risks and prioritizing
security measures accordingly.
2. Secure Coding Practices: Writing code with security in mind is crucial. This includes practices like
input validation, output encoding, proper error handling, and using secure coding libraries to prevent
common vulnerabilities like SQL injection, cross-site scripting (XSS), and buffer overflows.
3. Code Reviews and Static Analysis: Regular code reviews by peers and automated static code analysis
tools can help identify security issues in the codebase. This process ensures that vulnerabilities are
spotted and corrected early.
4. Security Testing: Security testing encompasses various practices such as penetration testing,
vulnerability scanning, and fuzz testing to discover and address security weaknesses and vulnerabilities
in the application.
6. Data Encryption: Protect sensitive data by using encryption methods for data at rest and data in
transit. This includes using HTTPS for web communication and encrypting stored data with strong
encryption algorithms.
7. Access Control: Enforce proper access controls to limit user permissions and restrict access to
sensitive data and functionality based on roles and responsibilities.
8. Secure APIs: When developing APIs, ensure they are designed with security in mind. Implement
authentication, authorization, and input validation for API endpoints.
9. Secure Development Frameworks: Utilize secure development frameworks and libraries that have
built-in security features, which can help reduce the likelihood of vulnerabilities.
10. Security Awareness Training: Train developers and the entire development team on security best
practices and keep them updated on emerging security threats and techniques.
1. Open Source: Android is based on open-source Linux. While open source promotes transparency and
innovation, it can also make it easier for attackers to study the code and identify vulnerabilities.
Application Security
UNIT-3
2. Fragmentation: Android is highly fragmented due to the multitude of device manufacturers and
carriers, each with its own variations of the OS. This can result in inconsistent security patching, leaving
many devices vulnerable to known threats.
3. App Ecosystem: The Android ecosystem allows for app installation from multiple sources, including
unofficial sources. This flexibility can lead to the installation of malicious apps, making app security a
significant concern.
4. Permissions Model: Android uses a permissions model where apps must request access to various
device resources (e.g., camera, location). Users often grant these permissions without fully
understanding the implications, which can lead to privacy and security issues.
5. Rooting and Jailbreaking: Android devices can be rooted (equivalent to jailbreaking on iOS), which
can bypass security mechanisms and grant users elevated privileges. While this is often done for
customization, it can be a security risk if not done carefully.
6. Google Play Protect: Google Play Store employs security measures, such as app scanning and
malware detection. However, some malicious apps still manage to slip through the cracks.
7. Security Updates: The timely distribution of security updates is often delayed due to the complex
ecosystem. This results in some older devices running outdated and vulnerable versions of Android.
Strong screen lock methods could include passphrase-based authentication for high-security
environments.
Enforce policies for auto-lock and password change intervals.
- Biometric Authentication:
Ensure the biometric data is stored securely and not in a format that can be easily reverse-
engineered.
Consider the inclusion of liveness detection to prevent spoofing.
Implement time-based one-time passwords (TOTP) or hardware tokens for 2FA to enhance
security.
Encourage the use of hardware security keys for 2FA, which are highly resistant to phishing.
- Data Wiping:
Implement secure data wiping procedures to ensure that data is irrecoverable when a device is
decommissioned or repurposed.
- Secure Keypad:
Integrate secure input methods that obscure characters as they are typed, making it harder for
attackers to capture keystrokes.
Implement keystroke dynamics analysis to identify legitimate users based on their typing
patterns.
Containerization:
Explore containerization solutions that not only separate user profiles but also add an extra layer
of security by isolating each profile's resources further.
- Root Detection:
Employ advanced root detection techniques like integrity checking and device attestation.
Forbid the execution of critical apps on rooted or jailbroken devices.
7. Application Isolation:
- Containerization:
Utilize containerization technologies like Docker or Kubernetes for isolating apps, especially in
corporate environments.
Employ container orchestration solutions to manage and secure containers at scale.
- App Permissions:
Develop apps with granular permission models that allow users to customize access, even within
an app. For instance, permit users to choose specific data items to share.
11 . Location Privacy/Security:
Fine-Grained Location Permissions: Only request and access the specific location information
necessary for the app's functionality.
User Consent: Clearly explain to users why an app needs their location data and ask for their
explicit consent before collecting it.
Anonymization: Implement techniques like data anonymization to protect user privacy, making
it harder to track individuals based on location data.
2. Hardware Abstraction Layer (HAL): This layer provides a standardized interface between the
Android framework and hardware-specific drivers. It allows Android to run on various hardware
platforms with minimal modification.
3. Android Runtime: Android uses a runtime environment that includes the Dalvik Virtual Machine
(DVM) or, in more recent versions, the Android Runtime (ART). These runtimes execute Android
application code, such as APK files containing Java bytecode.
4. Native C/C++ Libraries: Android includes a set of native libraries written in C/C++ that provide
essential functionalities, including multimedia support, graphics rendering, and low-level system
operations.
5. Java API Framework: This layer provides a rich set of APIs for app development using the Java
programming language. It includes components like activities, services, content providers, and broadcast
receivers, which are used to build Android applications.
6. System Applications: Android comes with a set of pre-installed system applications, such as the
phone dialer, contacts, messaging, and settings. These applications serve as examples and can be
customized or replaced by device manufacturers.
7. Application Framework: The application framework handles various essential tasks, including user
interface management, resource management, and data storage. It provides a consistent development
framework for app developers.
8. Application Layer: This is where Android applications reside. Developers create apps that use the
Android framework's APIs and interact with system services and hardware.
1. User-Based Permissions: Linux uses a user-based permission model. Each process, including Android
applications, runs under a specific user and group, allowing for user-level access controls.
2. File Permissions: File-level permissions are implemented through traditional Unix-style file
permissions (read, write, execute) and access control lists (ACLs), allowing fine-grained control over file
access.
3. Process Isolation: Linux enforces strong process isolation, ensuring that one process cannot directly
interfere with the memory or resources of another process.
Application Security
UNIT-3
4. Secure IPC: Inter-Process Communication (IPC) mechanisms like sockets and pipes are secured to
prevent unauthorized access between processes.
5. Firewalls and IPTables: Linux's built-in firewall capabilities (e.g., IPTables) enable network security
controls to restrict network access to and from the device.
6. Security Modules: Linux supports security modules like SELinux (Security-Enhanced Linux) and
AppArmor, which provide mandatory access control policies to further enhance security.
1. Application Sandboxing: Each Android app runs in its own sandboxed environment, isolated from
other apps. This prevents unauthorized access to an app's data or resources.
2. Permissions Model: Android apps must request and be granted permissions by users to access
specific device features and data. Users have the ability to grant or deny these permissions, enhancing
user control.
3. Package Signing: Android requires apps to be digitally signed by developers, ensuring the integrity
and authenticity of the app.
4. Secure IPC: Android's Binder mechanism facilitates secure IPC between app components, enforcing
inter-process communication rules and preventing unauthorized access.
5. Secure Boot and Verified Boot: Android devices often implement secure boot processes and verified
boot mechanisms to ensure the integrity of the OS and prevent the installation of malicious firmware.
6. Application Whitelisting: Google Play Store and other app distribution channels employ stringent
review processes to prevent the distribution of malicious apps. Users can also choose to install apps
from third-party sources, but this is discouraged due to security risks.
7. Over-the-Air (OTA) Updates: Android provides the ability to receive over-the-air updates directly
from manufacturers or carriers to patch vulnerabilities and improve security.
8. Secure Data Transmission: The use of HTTPS for secure data transmission and encrypted data
storage is encouraged, protecting data during transmission and at rest.
5. Application Signing:
Digital Signatures: Application signing is the process of attaching a digital signature to Android
apps (APK files) by the developer. The digital signature serves as proof of the app's authenticity
and integrity.
Key Management: Developers use cryptographic key pairs to create signatures. The private key
is kept secret, while the public key is included in the APK. Developers should securely manage
private keys to prevent unauthorized signing.
Application Security
UNIT-3
Verification: Android OS and app stores verify the digital signatures to ensure that apps have not
been tampered with or altered by malicious actors. This helps maintain the integrity of the app
ecosystem.
App Updates: If an app is updated, the new version's signature must match the old one to
prevent unauthorized modifications.
o Attribution: Attribution in Android security refers to identifying the source of actions or events within
the operating system. For example, it helps determine which app initiated a particular action or
access request.
o Attestation: Attestation involves confirming the authenticity of a device's software or configuration.
It helps establish the trustworthiness of a device's environment.
o SafetyNet API: Android's SafetyNet API provides attestation services for Android devices. It checks
device integrity, verifies the presence of essential security features, and assesses device compatibility
with certain security standards.
7. Process Design:
o Process Isolation: Android uses process isolation to ensure that each app runs in its own separate
process, enhancing security. If one process is compromised, it should not affect other processes.
o Permissions and Access Control: Process design in Android involves controlling the interactions
between processes. Permissions and access control mechanisms are used to regulate inter-process
communication (IPC) and data sharing.
o Binder Mechanism: Android uses the Binder IPC mechanism, allowing apps to securely communicate
with each other while maintaining process isolation. The Binder mechanism enforces inter-process
communication rules to prevent unauthorized access.
o Filesystem Sandboxing: Android employs a filesystem sandboxing model where each app
operates in its own isolated directory structure, restricting access to its files and resources.
o Linux User Permissions: Each app is assigned its own Linux user ID, which provides individual file
permissions, limiting access to other apps' data and resources.
Application Security
UNIT-3
o Secure File Access: Android enforces strict file access controls, ensuring that apps cannot access
data from other apps without proper permissions. Content providers are used to share data
between apps securely.
9. Android Preferences:
o Shared Preferences: Android provides a way for apps to store small amounts of data in a key-value
pair format using Shared Preferences. These preferences are often used to store user settings,
application configurations, and other lightweight data.
o Isolation: Shared Preferences are isolated on a per-app basis. Each app's preferences are stored in a
separate file within its own dedicated sandboxed storage area. This isolation ensures that one app
cannot directly access or modify another app's preferences.
o Data Security: Access to an app's shared preferences is governed by the app's own permissions. Only
the app that created the preferences file has direct access to it. This helps maintain data security and
isolation at the application level.
o Permission Groups: Permissions are organized into groups, making it easier to manage and
understand. For example, the "CAMERA" permission is part of the "CAMERA" permission group.
o Permission Levels: Permissions are categorized into normal, dangerous, and signature
categories. Dangerous permissions require user approval and typically involve accessing sensitive
data or system features.
o Permission Enforcement: Starting with Android 6.0 (API level 23), runtime permissions are used.
This means apps request dangerous permissions from the user at runtime rather than at
installation. Users can grant or deny permissions when the app needs to use them.
o Default Permissions: Some permissions, like "INTERNET" or "ACCESS_NETWORK_STATE," are
considered normal and are automatically granted to apps upon installation.
o App Manifest: An app declares its permission requirements in the AndroidManifest.xml file. This
informs the Android system and users about what the app can access.
3. Custom Permissions:
Android allows developers to define custom permissions, which can be useful in various scenarios:
4. Manifest Permission:
o AndroidManifest.xml: In the AndroidManifest.xml file, developers declare the
permissions their app needs to function. This informs the system and users about what
resources or features the app will access.
o Normal Permissions: Some permissions are classified as normal, meaning they are
automatically granted to apps upon installation. Examples include "INTERNET" and
"ACCESS_NETWORK_STATE."
o Dangerous Permissions: Dangerous permissions require explicit user approval. Apps
must request these permissions at runtime, and users have the option to grant or deny
them.
5. Intents:
o Intent System: Android uses an intent system for inter-component communication.
Intents are messages that convey requests or events to app components, like
activities, services, or broadcast receivers.
o Explicit Intents: Explicit intents specify the target component by name. They are used
when the sender knows the exact component that should handle the intent.
o Implicit Intents: Implicit intents do not specify the target component. Instead, they
declare an action or data type, allowing the system to find the most suitable
component to handle the intent.
o Broadcast Intents: Broadcast intents are used for system-wide or app-local events.
They can be sent and received by apps to trigger actions or react to events.
6. Activities:
o Activities: Activities are fundamental building blocks of Android apps, representing
individual screens or UI elements. They handle user interactions, such as button clicks
and text input.
Application Security
UNIT-3
o Activity Lifecycle: Activities go through a lifecycle that includes states like "onCreate,"
"onStart," "onResume," "onPause," "onStop," and "onDestroy." Proper management
of this lifecycle is crucial for memory and resource efficiency.
o Task and Back Stack: Activities are organized in a task and back stack. Users navigate
between activities using the back button. The task stack keeps track of the app's
navigation history.
7. Broadcasts:
o Broadcasts: Broadcasts are a means of inter-process communication in Android. Apps
can send and receive broadcast messages to inform other components or apps about
events.
o Broadcast Receivers: Components called broadcast receivers listen for specific
broadcast messages. They can respond to system-wide events or app-local events.
o System Broadcasts: Android OS sends system broadcasts for events like device boot,
battery low, network connectivity changes, etc.
o Custom Broadcasts: Apps can also create custom broadcasts to trigger their own
actions or to communicate between app components.
8. Services:
o Services in Android: Services are components in Android that allow you to perform
background tasks or handle long-running operations without a user interface. There
are two main types: started services and bound services.
o Started Services: These services are started with `startService()` and can run
independently of the calling component. They are often used for tasks like
downloading files or processing data in the background.
o Bound Services: These services are bound to a client component with `bindService()`.
They provide a client-server interface and are used for more complex interactions
between components.
9. ContentProviders:
o Content Providers in Android: Content providers are used to manage and share
structured data with other apps. They provide a standardized interface for data access.
They can be used to store and retrieve data, such as contacts, calendar events, or even
app-specific data.
o Data Access: Content providers allow you to access data using URIs, and they often
use a combination of the Content Resolver class and URIs to access and manipulate
data.
Application Security
UNIT-3
o Permissions: Content providers define permissions to control which apps or
components can access the data they manage. These permissions are declared in the
AndroidManifest.xml file.
1. Understanding G Suite:
2. Basic Settings:
- Domain and User Management: Basic settings include configuring the G Suite domain (your
organization's domain) and adding or removing users. Proper user provisioning and deprovisioning
processes are essential for security.
Application Security
UNIT-3
- Security Policies: Implement basic security policies like password complexity requirements, two-step
verification (2SV) for user accounts, and account recovery options.
- Email Security: Configure email settings, including spam filters, malware detection, and email
encryption.
3. Password Management:
- Password Policies: Establish strong password policies, such as minimum length, complexity
requirements, and expiration intervals. Encourage users to choose unique and hard-to-guess passwords.
- Password Reset: Configure password reset options, including security questions or alternative contact
methods for account recovery.
4. Password Monitoring:
- User Behavior Monitoring: Implement user behavior monitoring to detect unusual login patterns or
signs of unauthorized access.
- Account Lockout: Automatically lock accounts after a certain number of failed login attempts to
prevent brute-force attacks.
- Geographic Restrictions: Restrict login access to specific geographic regions or IP ranges to limit
access to trusted locations.
- API Access Control: Enable and manage API access to G Suite services for specific users or
applications. Use OAuth 2.0 and API keys to ensure secure and authorized access.
- Monitoring API Usage: Regularly monitor and audit API usage to detect any suspicious activities or
unauthorized access through APIs.
Application Security
UNIT-3
7. Setting Up Single Sign-On (SSO):
What is SSO? Single Sign-On is an authentication process that allows users to access multiple
applications or services with a single set of credentials. In the context of G Suite, it allows users
to sign in once with their G Suite credentials and access various integrated applications without
the need for separate logins.
Configuring SSO for G Suite: To set up SSO for G Suite, you can use an identity provider (IdP)
that supports SAML (Security Assertion Markup Language). Common IdPs include Okta, Azure
AD, and PingFederate. The general steps are:
Configure your G Suite domain as a service provider (SP) in your IdP.
Configure your IdP to trust G Suite as an identity provider (IdP-initiated SSO).
Establish the necessary SAML attributes, such as user attributes and groups.
Customize your IdP settings to align with your security and access control requirements.
Benefits of SSO for G Suite:
Simplified user access: Users only need to remember one set of credentials for multiple
applications.
Centralized access control: Administrators can enforce policies and permissions from a single
location.
Enhanced security: SSO helps prevent password-related security issues, such as weak
passwords and password reuse.
o Authorization and Authentication: Ensure that API access is properly authorized and authenticated,
and use OAuth 2.0 for secure API access.