<?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 Swapnil Saha on Medium]]></title>
        <description><![CDATA[Stories by Swapnil Saha on Medium]]></description>
        <link>https://medium.com/@swapnilsaha?source=rss-be4fb91f7773------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iSubeIF1frWJP9WqzhnWVg.jpeg</url>
            <title>Stories by Swapnil Saha on Medium</title>
            <link>https://medium.com/@swapnilsaha?source=rss-be4fb91f7773------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 05:34:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@swapnilsaha/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[Microcorruption Cusco write up]]></title>
            <link>https://medium.com/@swapnilsaha/microcorruption-cusco-write-up-daa47075ad7b?source=rss-be4fb91f7773------2</link>
            <guid isPermaLink="false">https://medium.com/p/daa47075ad7b</guid>
            <dc:creator><![CDATA[Swapnil Saha]]></dc:creator>
            <pubDate>Thu, 31 Jul 2025 16:18:00 GMT</pubDate>
            <atom:updated>2025-07-31T16:26:27.992Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s dive into solving the <strong>Cusco</strong> level from the Microcorruption embedded security CTF. This level is an excellent introduction to stack-based buffer overflows in MSP430 architecture and gives you a taste of reversing real-world-like firmware with static and dynamic analysis.</p><p>Let’s dive in.</p><p>The main function doesn’t provide that much information to us. It directs us to the login function present at <strong>#0x4500</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*OT6EeJvm7v65dEV3_UEIZA.png" /></figure><p>Here’s the disassembly of the login function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/770/1*HXDqJY2U1FAybxh_gD6xoA.png" /></figure><p>At 4500, the function allocates <strong>16 bytes on the stack.(Adding 0xfff0 simply means sp = sp — 0x10 i.e sp = sp — 16 bytes)</strong></p><p>It then loads the string present at #0x447c ( fortunately the strings are written over the instruction) at r15 and executes puts function.</p><p>similarly at 450C and 4510 it does the same thing.</p><p>If we run the program or directly we can see from the login function , that the program asks no more than 16 characters.</p><p>But on 4514, we see <strong>mov #0x30, r14 </strong>. It is allocating 48 bytes to r14 and then calling the getsn( ) function.</p><p>So, the function is attempting to write <strong>48 bytes into a buffer that’s only 16 bytes long</strong>.</p><p>💥 <strong>Classic buffer overflow</strong>.</p><p>After reading the password, login() calls the &lt;test_password_valid&gt; function, which portrays its result in r15.(0 or 1)</p><p>we then, come back in the login and execute below commands:</p><pre>4524:  0f93           tst	r15<br>4526:  0524           jz $+0xc &lt;login+0x32&gt;</pre><p>These commands checks if r15 is zero or not.</p><p>If it is zero the execution jumps to login+0x32.</p><p>Basically, long story short it tells us whether the access is granted or not.</p><p>But at the end, there is something fishy.</p><pre>453a:  3150 1000      add	#0x10, sp</pre><p>The stack pointer is incremented by 0x10.</p><p>and why is that?</p><p>The Stack pointer comes from:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*UzhxXFGgQ92gkJe42E5-5Q.png" /></figure><p>to</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*6YNxzeB_QftKAkWhV6jaWw.png" /></figure><p>here.</p><p>since this is little endian, we should read it as 443c.But what we have at 443c?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*34ItIm7tBjFmYuLvE8z7_A.png" /></figure><p>Nothing but the stop program execution function.</p><h3>Exploit Strategy: Stack Buffer Overflow</h3><p>Let’s summarize the vulnerability:</p><ul><li>Stack buffer size = <strong>16 bytes</strong></li><li>getsn reads up to <strong>48 bytes</strong></li><li>So we have <strong>32 bytes of overflow</strong> available</li></ul><p>Now, instead of the Stack Pointer pointing to 443c ( stop program execution ), if we can trick the program to point to the &lt;unlock door&gt; function, we could bypass the authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*zIf5Z7aCVPzSAlZvYn8AlA.png" /></figure><p>so insetad of 3c44 we need to have 4644(little endian again)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*yWfHLlVD_GU_Pa_VTmvjKQ.png" /></figure><p>so to trigger the buffer to overflow, we can put any input, but it should replace the 3c44 to 4644.</p><p>Let’s put : 111111111111111111111111111111114644</p><p>obviosuly check this box:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*QEEiPWatIGQz07o3Q_A1WA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eHvoRrSuDiV8bKHLrdH_vw.png" /></figure><p>And we got it !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=daa47075ad7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How One App Can Starve Others: Let’s get to the basics]]></title>
            <link>https://medium.com/@swapnilsaha/how-one-app-can-starve-others-lets-get-to-the-basics-2bc87f769b32?source=rss-be4fb91f7773------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bc87f769b32</guid>
            <category><![CDATA[denial-of-service-attack]]></category>
            <category><![CDATA[memory-management]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[technical-analysis]]></category>
            <dc:creator><![CDATA[Swapnil Saha]]></dc:creator>
            <pubDate>Fri, 30 May 2025 17:49:41 GMT</pubDate>
            <atom:updated>2025-05-30T17:49:41.027Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>Just an intro:</em></strong><em> Modern multi-core CPUs share the same memory system. This opens a surprising vulnerability: a single greedy app can silently starve others, degrading performance without triggering alarms. This post explores how such Memory Performance Hogs (MPHs) work — and how researchers proposed we stop them.</em></blockquote><p>Ever feel like your computer slows down when you open a certain app — but your CPU usage looks totally fine? The problem might not be your CPU, but how apps are fighting for access to memory.</p><p>In today’s multi-core systems, multiple applications run in parallel — but they share the same <strong>DRAM memory</strong>. And guess what? That memory sharing isn’t fair. It might be a little racist here.</p><h3>Multi-Core Magic (and Mayhem)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6AzWXSj-YjXLy8OK" /><figcaption>Photo by <a href="https://unsplash.com/@boliviainteligente?utm_source=medium&amp;utm_medium=referral">BoliviaInteligente</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Over the past two decades, processor speeds hit power and thermal limits. To keep improving performance, chipmakers started adding <em>more cores</em> instead of faster ones.</p><p>So now, your laptop or phone likely runs on a <strong>multi-core processor</strong>. Multiple apps or threads can run in parallel on different cores. But all these cores usually share one thing: the <strong>DRAM memory system</strong>. Got it ? no ? let’s see a real world matching example.</p><p><em>Imagine four people cooking in one kitchen. The CPUs are the chefs, the memory is the fridge. And sometimes, one chef opens the fridge and just keeps standing there…</em></p><blockquote><strong>Memory Performance Hog (MPH)</strong></blockquote><p><strong>Just for the history:</strong> The researchers Thomas Moscibroda and Onur Mutlu (Microsoft Research) coined this term in 2007 to describe apps that <strong>abuse the memory system</strong>.</p><p>They found that some applications can <strong>hog the shared memory bus</strong>, effectively <strong>starving other apps</strong> of access. This was an accident. And Accidents can be deceiving.It can be CAUSED MANUALLY.</p><blockquote><em>On a dual-core system, one app slowed another down by nearly </em><strong><em>3×</em></strong><em>, while barely affecting its own speed.</em></blockquote><p>On a simulated 16-core system, it was even worse: <strong>14× slowdown</strong> for victim apps.</p><h3>How Does This Happen?</h3><p>It comes down to <strong>how DRAM memory scheduling works</strong>.</p><p>Most modern DRAM systems use a scheduling policy called <strong>FR-FCFS</strong> (First Ready, First Come, First Serve). It prioritizes:</p><ol><li>Requests that are <strong>“row hits”</strong> — fast, easy accesses to an already-open part of memory.<br><strong>row hit:</strong> Imagine the memory space as a 2D matrix(infact it is..).to get a particular cell of that matrix we need to first now which row and then which column.It is easier to switch between columns in a row.It takes time to switch the row number. Applications who tend to have similar data access pattern, requests data from mostly from single row but different columns( or maybe same column) and the processors favors who ask more from same row.</li></ol><p>2. Among those, the <strong>oldest</strong> request goes first.</p><p>But this scheduling <strong>doesn’t care which core made the request</strong>.</p><p>So, an app that floods the memory system with <strong>sequential, row-hit requests</strong> gets all the love from the scheduler. Meanwhile, apps with random access patterns (e.g., databases, simulations) get stuck waiting.</p><p>That’s what makes a <strong>Memory Performance Hog</strong> — and it can happen unintentionally or by design.</p><h3>Real Example: stream vs rdarray</h3><ul><li><strong>stream</strong> is a memory-intensive benchmark that reads arrays sequentially. High row-hit rate = gets priority.</li></ul><pre>// initialize arrays a, b<br> for (j=0; j&lt;N; j++)<br> index[j] = j;<br> // streaming index<br> for (j=0; j&lt;N; j++)<br> a[index[j]] = b[index[j]];<br> for (j=0; j&lt;N; j++)<br> b[index[j]] = scalar * a[index[j]];</pre><ul><li><strong>rdarray</strong> accesses memory randomly. Low row-hit rate = gets ignored.</li></ul><pre>// initialize arrays a, b<br> for (j=0; j&lt;N; j++)<br> index[j] = rand(); // random # in [0,N]<br> for (j=0; j&lt;N; j++)<br> a[index[j]] = b[index[j]];<br> for (j=0; j&lt;N; j++)<br> b[index[j]] = scalar * a[index[j]];</pre><p>When run together:</p><ul><li>stream only slowed down by <strong>18%</strong></li><li>rdarray slowed down by <strong>190%</strong> (!)</li></ul><p>It’s not just theory — this was tested on <strong>real dual-core Intel CPUs</strong> and <strong>simulated 16-core systems</strong>.</p><blockquote>Thomas Moscibroda &amp; Onur Mutlu showed us the results in their research paper “Memory Performance Attacks: Denial of Memory Service in Multi-Core Systems”</blockquote><p>Now comes the candy of the Cyber security enthusiasts:</p><h3>Denial of Memory Service Attack in Action</h3><p>Let’s walk through how an attacker can <strong>weaponize an MPH</strong> to silently degrade performance on a shared server — like in a <strong>cloud or enterprise environment</strong>.</p><p>Imagine you’re renting a <strong>virtual machine (VM)</strong> in a public cloud (like AWS or Azure), and so is a <strong>competitor</strong>. You’re running a <strong>latency-sensitive application</strong> — say, an online trading engine, or a real-time analytics dashboard.</p><p>Your competitor rents a second VM that <strong>shares the same physical machine, </strong>a common setup in multi-tenant cloud environments.</p><p>Now here’s the trick.</p><p>The competitor runs a program that looks innocent. It doesn’t use much CPU. It doesn’t consume excessive bandwidth. But behind the scenes, it’s a <strong>Memory Performance Hog</strong>.</p><p>This program continuously streams sequential data from memory — something like this:</p><pre>for (int i = 0; i &lt; BIG_ARRAY_SIZE; i++) {<br>    sum += big_array[i];<br>}</pre><p>This loop creates a <strong>high row-buffer hit rate</strong>, which the memory scheduler <em>loves</em>. So the scheduler gives this process almost all the attention, fulfilling its memory requests quickly.</p><p>Meanwhile, your real-time trading app is issuing <strong>random-access memory requests</strong> — which are much harder to serve efficiently (low row-buffer locality). The DRAM controller <strong>de-prioritizes</strong> your app in favor of the attacker’s memory-hogging process.</p><p>Here is the thing:</p><ul><li><strong>CPU usage?</strong> Normal.</li><li><strong>RAM consumption?</strong> Reasonable.</li><li><strong>Disk/network I/O?</strong> Minimal.</li><li><strong>Malware signature?</strong> None.</li></ul><p>Yet your app suddenly <strong>slows to a crawl</strong>. Users experience lag. Trades are delayed. Your SLA metrics suffer.</p><p>All because someone wrote a few lines of C code that exploit DRAM scheduling unfairness.</p><p>In the original paper, the authors show that:</p><blockquote>One malicious application slowed a victim by <strong>14.6×</strong> — while only slowing itself by <strong>4.4×</strong> — on a 16-core system.</blockquote><p>And this doesn’t require advanced hacking. Just <strong>clever use of memory access patterns</strong>.</p><h3>The Fix: FairMem</h3><p>The authors proposed a smart solution: <strong>FairMem</strong>, a new memory scheduling algorithm.</p><p>Here’s the idea:</p><ul><li>Measure how much slowdown each app suffers, compared to running alone.</li><li>If one app is slowing others too much, give priority to the <em>slower</em> apps.</li></ul><p><strong>Think of it like a traffic light that gives longer greens to the more congested lanes.</strong></p><p>FairMem tracks this using a “slowdown index” per thread and adjusts scheduling dynamically. The result? Balanced slowdowns, better fairness, and sometimes even <strong>better overall performance</strong>.</p><h3>Did It Work?</h3><p>Yes. Some examples from the paper:</p><ul><li>stream slowed down health by <strong>8.6×</strong> in the default system — but only <strong>2.2×</strong> under FairMem.</li><li>In most cases, FairMem also <strong>increased total system throughput</strong>, making all cores more productive.</li></ul><p>FINALLY..</p><p>In the age of multi-core processors, we assumed running apps in parallel meant <strong>fair and equal access</strong> to hardware. But under the hood, they’re all competing in a <strong>high-stakes memory race</strong> — and the rules aren’t fair.</p><p>One greedy app can feast on the memory bandwidth buffet, while others are left starving in silence. No red flags. No system alerts. Just slowdowns and frustration.</p><p>And if that greedy app is <strong>malicious</strong>? Welcome to a new class of stealthy denial-of-service attacks that operate without a trace — no exploits, no vulnerabilities, just <strong>smart abuse of hardware policy</strong>.</p><p>FairMem gives us a glimpse of a fairer future — where no thread gets left behind in the memory traffic jam.</p><p>Because <em>Arthur Morgan</em> once said:</p><blockquote>In the end, it’s not just about making memory faster.<br>It’s about making memory <strong>fair</strong>.</blockquote><h3>Read More:</h3><ul><li>Original paper: <a href="https://www.usenix.org/legacy/events/sec07/tech/full_papers/mutlu/mutlu.pdf">Memory Performance Attacks (USENIX 2007)</a></li><li>Onur Mutlu’s research: <a href="https://people.inf.ethz.ch/omutlu/">https://people.inf.ethz.ch/omutlu/</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vGDZ5hPDZkWSS-Sr" /><figcaption>Photo by <a href="https://unsplash.com/@blazphoto?utm_source=medium&amp;utm_medium=referral">Blaz Photo</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bc87f769b32" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[THE SCIENCE BEHIND “QUANTUM COMPUTER”]]></title>
            <link>https://medium.com/@swapnilsaha/the-science-behind-quantum-computer-16872e1c5550?source=rss-be4fb91f7773------2</link>
            <guid isPermaLink="false">https://medium.com/p/16872e1c5550</guid>
            <dc:creator><![CDATA[Swapnil Saha]]></dc:creator>
            <pubDate>Sun, 09 Feb 2020 15:13:30 GMT</pubDate>
            <atom:updated>2020-02-09T17:06:58.589Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*swG8SJ4VN-MRPQ3n.jpg" /></figure><p>We all know how quantum physics and mechanics have changed the world. The quantum world or realm is very much interesting than the real one. The particles don’t follow the rules of classical physics in that world. like, if you know the speed of the train on which I’m traveling right now, you can easily calculate and know my position after a short or long period. that’s how things work out here in the world you are seeing in front of you. But if I tell you to calculate the position of an electron or any subatomic particle, you cannot calculate its momentum.</p><p>so we know that which seems very easy for us in the real world, it is quite uncertain in the <strong><em>QUANTUM WORLD</em></strong>.</p><p>But scientists have used some of the most known phenomenons of the quantum world to make the smartest computer of this planet. It’s called a quantum computer.</p><h3>So the topics that we’ll discuss in this article are “QUANTUM ENTANGLEMENT” &amp; “SUPERPOSITION”</h3><blockquote><em>QUANTUM ENTANGLEMENT</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*magH-bVOLu4gitO1.jpg" /></figure><p>The word “Entanglement” means a thing to be connected to another thing. yes, that’s aight. Here in quantum physics, when two particles are completely connected to each other. It means we can easily determine the state of the other particle by only knowing the state of only the first one. suppose, you and your Facebook friend, who is living at the other end of the world from you are playing a game using two coins. One for you and the other for him or her. you both decided to toss the coin at the same time.</p><h4>what do you think would happen?</h4><p>so normally it can be anything. If heads= 1, and tails=0, Then we can get results of the tossing as (1,0),(0,1),(11),&amp;(00). That’s quite obvious, right?</p><p>BUT, if I give you two, two entangled coins to toss. though they are tossed a billion miles apart, I can say the result of your friend if I know yours. It will be opposite to it. if your result is HEADS, then your friend’s result will be TAILS. if you are quite familiar with the term “ electron spin” which we know are two types UP &amp; DOWN. so, if the spin of one electron is up the other onw\e will be surely down, if they are already entangled to each other.</p><p>all the possibilities I told you about tossing the coins, are all fit in a qubit, whereas in a normal computer, we have to consider all for cases. there are (1.27 * 10^ 30) microstates for tossing 100 coins. So, it takes very much time for a normal computer to calculate that much.</p><p>but since the quantum computer takes all possibilities in one single qubit, it’s effortless and time saving for us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*pB3PZmwVliUCvBZ4.png" /></figure><blockquote>SUPERPOSITION</blockquote><blockquote>The superposition theorem can rougly be said as “ both at the same time.” schroedinger once did a great thought experiment where he put a cat in a box, in which there was also a radioactive element which decays by a certain amount of time. so if we put that cat in such a box , and after a certain time if I ask you if the cat is alive or not, you surely wouldn’t be able to answer it without opening the box. so when the box is closed,<strong><em> THE CAT IS BOTH DEAD AND ALIVE AT THE</em> <em>SAME TIME.</em></strong>I know it sounds both weird and hilarious AT THE SAME TIME. But this theory changed many perceptions and perspecitve of the quantum world. Some people also compared this phenomena with the dual nature of the light.</blockquote><blockquote>so, this was about SUPERPOSITION theorem. Now the question arrives how this is related to QUANTUM COMPUTING?? The answer is that this is the main basic theory behind thid high quality smartest computer.</blockquote><blockquote>if I consider tossing three coins, then as our previous assumption about heads and tails we can say that the results will be (111),(000),(101),(110),(011),(100),(001)&amp;(010). Qubits can take all these possibilities at the same time. It creates multiple dimensions where all the possibilites have happened at the same particular time, which makes higher calculations and complex equations more simple to solve.</blockquote><blockquote>so this was all about the basic idea of understanding what is the science behind this great inventions. Currently google has made a chip with72 qubit, which is the highest till now. There are many more to be discovered in this field. Researchers are working on it. But until know what we have learned about it, concludes that QUANTUM COMPUTER is the future of the technology, AND THE FUTURE HAS BEGUN.</blockquote><p>THANK YOU.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16872e1c5550" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>