<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mahmoud Shaban on Medium]]></title>
        <description><![CDATA[Stories by Mahmoud Shaban on Medium]]></description>
        <link>https://medium.com/@drneweinstein?source=rss-d764f1167a98------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Okb8f1qIXVSOTmNQ</url>
            <title>Stories by Mahmoud Shaban on Medium</title>
            <link>https://medium.com/@drneweinstein?source=rss-d764f1167a98------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:36:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@drneweinstein/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hunting ATOs From Behind The Walls]]></title>
            <link>https://medium.com/@drneweinstein/hunting-atos-from-behind-the-walls-995fa4d40c55?source=rss-d764f1167a98------2</link>
            <guid isPermaLink="false">https://medium.com/p/995fa4d40c55</guid>
            <dc:creator><![CDATA[Mahmoud Shaban]]></dc:creator>
            <pubDate>Wed, 24 Sep 2025 15:55:12 GMT</pubDate>
            <atom:updated>2025-09-24T15:55:12.835Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello There!<br>Here I come with a new defense mechanism that I’ve never came across before, the analysis and eventually the bypass which revealed a wide attack surface behind it.</p><p>The application is a huge management system, where user data is very critical and sensitive. as usual, we are not satisfied until we get an RCE or , in this case, an Account takeover.</p><p>Let’s begin the journey💂‍♀️</p><p>I usually begin with the simplest functions to get an overview of application logic. here it is the forget password function. intercepting verify OTP request and here its normal behaviour:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9yLPJ_aqiT4LUInUcjfybg.png" /></figure><p>to test for the input validation, I started with a single quote within the OTP value, and here its response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wl6vHaspUygRkcCIbw4vAw.png" /><figcaption>The response to an added single qoute</figcaption></figure><p>Tried different special chars, and data types, and I get the same response! isn’t it a great input validation?<br>i tried the same for many other functions, and I always get the same response!<br> It was so good, that triggered this part of my mind, when the developers became this clever ?!</p><p>let’s get a step back and ask, is it actually an input validation?</p><p>i got the same above request and changed a number in the OTP value, it is now a very usual input that should be only an invalid OTP, and guess what? i got the same “ Bad Request response”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vPUzhSj6Z-Hj5NAVmcW42g.png" /></figure><p>hmmm it is not input validation, it might be some kind of anti-automation/anti-repeater mechanism, where a request is valid only by the original request data.</p><p>my first question was, is it a client side or a server side mechanism?<br>if it is a server side, I will raise my hat for the development team, but again, when the developers became this clever ?!😁</p><p>I started by narrowing down the parts of the request that is validated within this anti-automation mechanisim, and this is the part of the request that any change of it triggers the bad request response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i6KsBS1Isa2PoFXOaRcRmQ.png" /></figure><p>started debugging the client side main JS file to find this mechanism is as follows :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CcW1lzddVyVz5q0VyOYCBw.png" /><figcaption>anti-automation Implementation</figcaption></figure><p>function called “getxsrfToken” takes the request payload/data (R) as an input and returns the XSRF token value (d) as an output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mPOrRfM51i_2XgyAbyey_g.png" /></figure><p>you can see that the XSRF token value generated is the same as the value found in the originally intercepted HTTP request above.</p><p>so what we can do is to put a breakpoint on this function and change the request payload as we need</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hay8IDKO2PMpePZq2leOXQ.png" /><figcaption>Added single qoute within the OTP value</figcaption></figure><p>then click stepover, and get the newly generated value of XSRF token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zHuhunWv5EHBKBf71H46jA.png" /><figcaption>the newly generated XSRF token</figcaption></figure><p>Now let’s try the new payload with its associated XSRF token value:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7sPem0JuJsRnOuAgLtVmZQ.png" /></figure><p>this is what it felt like :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*huwUUk_iaf96dN6feZYHmw.gif" /></figure><p>Now Let’s Start our actual Penetration Test 👽😈</p><p>my target was to gain ATO. I’ve gone through different attack vectors that might get us an ATO with no Luck, until I noticed the following:</p><p>1- any user can change his password while he is logged in</p><p>2- admins can reset any user password</p><p>3- both features use the same endpoint, but with only different sets of parameters</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JmDR1L2fRhADtO0TQhAVAg.png" /><figcaption>any user can change his password</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hTlHoY6hoxWdM3cUgZNC2g.png" /><figcaption>admins can reset any user’s password</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IZu9oZQERxugOfb5B8-91w.png" /><figcaption>request of a user changing his password</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zOBMH8F4ajnk4-KZbMyXIA.png" /><figcaption>Request of an admin resets the paswword for another user</figcaption></figure><p>the silver line here is that, the endpoit is permitted for everyone, so if there any authorization implemented, it must depend on the set of the parameters received by the backend. and again, are developers this clever? especially the application is huge and there is an authorization technique that is used across the application, which is not enough to secure our case here. so I was sure this will exploit the ATO(and I was right).</p><p>but to achieve a high likelihood exploit, we needed to get the user id for the victim, which is random and long value. so we exploited another access control vulnerability that successfully leaked all users’ UID. so the complete exploit was as follows:</p><p>1- attacker exploited a vulnerability that let him know the required parameters for each action</p><p>2- attacker exploited a vulnerability that let him know the UID for any User(as the UID is a parameter needed to execute the admin’s reset password feature)</p><p>3- attacker put a breakpoint on the Anti-automation function</p><p>4- attacker tried to change his law-privileged account password</p><p>5- from the browser debugger, when the execution paused by the breakpoint, the attacker changed the payload to the payload that is associated with the admin reset password feature, and steped-over to catch the value of the associated XSRF token</p><p>6- attacker intercepts the change password request, change the payload to the admin’s reset password payload, and the XSRF token to the one associated with the admin’s reset password payload</p><p>7- attacker send the request, to find it is successfully executed and he is able to login to the victim’s account by this password now</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZZ2Yj8yliFDFDXv-xKICw.png" /><figcaption>An attacker can change the password of any user by only its login-id and UID</figcaption></figure><p>That’s it !</p><p>Hope you enjoyed the scenario 🤖👾</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=995fa4d40c55" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Security Internals — Research Approach — Part 1]]></title>
            <link>https://medium.com/@drneweinstein/android-security-internals-research-approach-part-1-ba1bee3f3fa0?source=rss-d764f1167a98------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba1bee3f3fa0</guid>
            <dc:creator><![CDATA[Mahmoud Shaban]]></dc:creator>
            <pubDate>Wed, 14 May 2025 00:27:48 GMT</pubDate>
            <atom:updated>2025-05-14T00:27:48.703Z</atom:updated>
            <content:encoded><![CDATA[<h3>Android Security Internals — Research Approach — Part 1</h3><p>When I first began exploring mobile security, I often asked myself, <em>“If I own the device, why don’t I have root access?!”</em> Eventually, I realized that the restriction isn’t just about protecting <em>my</em> data— it’s about safeguarding all users. Actions I take on my device, such as granting permissions to malicious apps, could compromise data belonging to other applications or even entire businesses.</p><p>This led me to a related question in the context of web security: if a web application relies on client-side controls, it becomes an easy target. Such controls are inherently vulnerable to debugging and manipulation. So how can a system enforce security on a device <em>against</em> its owner when the very mechanisms used are essentially just client-side defenses?</p><p>In this Blog post, we will go through Android operating system security architecture and attack surface, not through heavy theory, but <strong>by asking simple questions</strong> that progressively lead us to full clarity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*BrvFmALixFaX8GLVxIKPMQ.jpeg" /><figcaption>Our Methodology</figcaption></figure><h3>In the first place, how any android-based device is different from the other?</h3><p>Based on the targeted business, different hardware components are presented, hence, different services are deployed. <br>Let’s look at two different Android-based products, a POS ( payment terminal) and a Mobile phone :<br>using the command adb shell service list<strong><em> </em></strong>on both the Samsung mobile device and the POS terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_k9J9DUEsdorLpO_Dmxa2w.png" /><figcaption>Samsung Mobile Services</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ztC8OcRdl6a5sHAXD1jp9Q.png" /><figcaption>PAX POS Terminal Services</figcaption></figure><p>You can see the different services ( and their corresponding interfaces in the form of &lt;service name&gt;: &lt;[service interface]&gt;) deployed for different devices. Each of these services is usually an <strong>interface</strong> that apps (or the system) can use to interact with hardware, features, or the OS, many of which are exposed through the Android SDK.</p><ul><li>The Android <strong>SDK</strong> gives developers Java/Kotlin <strong>APIs</strong> to interact with those services easily.</li><li>Under the hood, when you call an API from the SDK, it talks to these system services to perform real actions.</li></ul><h3>Simple example:</h3><p>package service (Package Manager), when your app uses PackageManager class from SDK to query installed apps.<br>activity service (Activity Manager), when your app starts another Activity or Service via startActivity().</p><p>(Have you ever wondered why a system service call must be made to start any activity, even for the activities of the same application? Why is it not enough to make this low-level system service call only when you start an application and the application governs its additional activities? <br>Let&#39;s get back to this.</p><p><strong>However</strong>:</p><ul><li><strong>Internal system services </strong>(vendor-specific services) like paxsmartdeviceservice, semdevicepolicy, samsung_print, knoxguard, etc., are <strong>not part of Android Open Source Project (AOSP)</strong>. Even if you see them via adb shell service listYou <strong>can&#39;t officially use them</strong> unless you’re part of the Vendor&#39;s partnerships.</li><li>These services usually use <strong>Privileged AIDL interfaces</strong> or <strong>Privileged system permissions</strong>, meaning <strong>normal apps</strong> can’t directly call them.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*r3hV_yr8Flj-5W57fC5nuw.png" /><figcaption>Un-allowed Call for a Privileged Service</figcaption></figure><p>Why are there System Services that Are <strong>Private</strong> and <strong>Undocumented?</strong></p><p><strong>They are intended for internal use only: </strong>Samsung or PAX engineers design these services for their own apps, not for third-party developers.</p><p><strong>They may expose security-sensitive operations: </strong>Things like device lockdown (Knox), firmware updates, SIM control, battery tuning — if public, it could allow malicious apps to abuse them.</p><p>hah here comes our first attack vector &gt; What if this service is poorly implemented that makes a privileged action based on a normal user’s controllable input?</p><p>For example, <strong>CVE–2023–42136</strong> — Privilege escalation from any user/application to system user via <strong>shell injection binder-exposed service.<br></strong>Below is quoted the explanation provided for this CVE:</p><p>An Android service named PaxSmartDeviceServcie (typo intended) is vulnerable to shell injection, escalating any user to system account. While it checks if the command starts with dumpsys, this check can be trivially bypassed by passing in dumpsys; command as an argument.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dl1ByyzPWTpnm4JWa8y1GA.png" /></figure><p>adb shell &quot;service call PaxSmartDeviceServcie 16 s16 &#39;dumpsysx; id &gt; /data/local/tmp/win&#39;&quot;</p><p>and the implementation of these services usually exists in “<strong>/system/framework/services.jar</strong>” where you can reverse this jar file and understand how to use or exploit these services.</p><p>==============================</p><h3>How does this OS manage access to these services?</h3><p>Alongside the known android sandboxing, there is a main concept that manages application-level actions, which is permissions. In Android, all possible actions that an application might ask for are mapped to distinct permissions, You can list all permissions by: adb shell pm list permissions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qhn8uLUW58eWdgx5hPIggw.png" /></figure><p>Every installed application/UID is granted a set of permissions that are validated at the execution time, in the sense of “ does this application UID have this permission?” <br>you can check all the permissions granted for an application by: <br>adb shell dumpsys package &lt;pachage name&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDveSHTD9Qdctl4nAVqtnw.png" /><figcaption>Granted permmission for the UID 2000 (shell user)</figcaption></figure><p>If many applications share the same UID, they all have the same set of permissions. UID 1000, for example, is the system privilege which is shared between multiple system applications, and they all share the same set of permissions. you can check this by collecting all packages that share that UID by the command adb shell pm list packages -U | grep 1000 then Dumbsys for them to check their permissions.<br> Permissions exist in different categories, you can find more about it<strong> </strong><a href="https://developer.android.com/guide/topics/permissions/overview"><strong>here</strong> </a>. the main point here is to understand the collaboration between the application sandboxing mechanism and the concept of permissions. UID is mainly for application separation and sandboxing, permissions are for application action validation.</p><p>An interesting attack vector arises from applications that are granted privileged permissions. Such applications are system and pre-installed applications that some can be found at /system/priv-app and /system/app.</p><p>To tackle this wide/dangerous attack vector, we first need to deeply understand:<br>1- what are the components of android application<br>2- the interaction between the android OS and the application’s compoenets<br>3- How applications communicate, and what are the internals of these communications</p><p>to mess with your thoughts regarding these last questions, don’t you feel that you can understand every line of code of a web application, but for android applications, you skip some lines that you treat them as default and not essential to understand the application?<br>we need to dive into this part that reveals the interaction between applications and the android OS in the next part</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba1bee3f3fa0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>