<?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 ayush_cg on Medium]]></title>
        <description><![CDATA[Stories by ayush_cg on Medium]]></description>
        <link>https://medium.com/@ayushhh?source=rss-c770888b01ef------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EMgiT_zk2CNDjsNXjT2ZUA.jpeg</url>
            <title>Stories by ayush_cg on Medium</title>
            <link>https://medium.com/@ayushhh?source=rss-c770888b01ef------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 03:42:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ayushhh/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[Generative Recommendation Systems: When Content Creation Becomes Part of Recommendation]]></title>
            <link>https://ayushhh.medium.com/generative-recommendation-systems-when-content-creation-becomes-part-of-recommendation-2b2ff96f7e58?source=rss-c770888b01ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b2ff96f7e58</guid>
            <category><![CDATA[consumer-behavior]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[recommendation-system]]></category>
            <dc:creator><![CDATA[ayush_cg]]></dc:creator>
            <pubDate>Wed, 21 Oct 2026 11:27:03 GMT</pubDate>
            <atom:updated>2026-10-21T11:27:03.515Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hNGYBKzj_xQ1XKEj" /></figure><p><em>How AI-generated content could solve one of the oldest problems in recommendation systems.</em></p><p>Building a good recommendation system is hard. Building one from scratch is even harder.</p><p>Almost every great recommendation system today, whether it’s TikTok, YouTube, Netflix or Spotify, has one fundamental advantage: years of user interaction data.</p><p>The more users interact with content, the better these systems understand their preferences. Better recommendations drive more engagement, which produces more data, which makes recommendations even better.</p><p>A beautiful flywheel. Except there’s one problem.</p><p><strong>How do you get this flywheel started when you have almost no data?</strong></p><p>This is the classic cold-start problem.</p><h3>The cold-start problem</h3><p>Recommendation systems traditionally depend on two things: understanding users and understanding content.</p><p>For a new user, you don’t know what they like. For a new piece of content, you don’t know who will like it.</p><p>Existing systems solve this through a combination of content features, collaborative filtering, exploration and enormous amounts of behavioral data.</p><p>But fundamentally, they’re working with a fixed supply of content and trying to figure out what to recommend.</p><p>I think generative AI changes this assumption entirely.</p><h3>Introducing Generative Recommendation Systems</h3><p>What if recommendation systems could generate the content they recommend?</p><p>Instead of just finding the best content for a user, the system could create content specifically designed to understand and satisfy their preferences.</p><p>I’m calling this <strong>Generative Recommendation Systems (GRS)</strong>.</p><p>The idea is fairly simple.</p><p>A traditional recommendation system optimizes which content to show.</p><p>A generative recommendation system optimizes both <strong>which content to show and what content should exist in the first place.</strong></p><p>Imagine a platform for bite-sized games.</p><p>A new user joins. The system knows absolutely nothing about them.</p><p>Instead of recommending random games and waiting for enough behavioral data, it can serve a deliberately diverse set of experiences. A reflex game, a puzzle, a strategy game, a competitive game.</p><p>Each interaction tells the system something.</p><p>Maybe the user prefers strategy over reflexes. Maybe they enjoy difficult games but dislike long sessions. Maybe they’re unusually competitive.</p><p>Now the system doesn’t need to wait for somebody to create the perfect next game.</p><p>It can generate one.</p><p>And more importantly, it knows what characteristics it intended that game to have before a single person has played it.</p><p>This makes every piece of generated content both an experience and an opportunity to learn.</p><h3>Content becomes an instrument for learning</h3><p>This is the part I find most interesting.</p><p>In traditional recommendation systems, exploration generally means showing different existing items to discover user preferences.</p><p>With generative AI, exploration can mean creating new items to test specific hypotheses.</p><p>The recommendation system could generate two similar games with different difficulty curves to understand whether a user prefers challenge or mastery.</p><p>Or two experiences with identical mechanics but different visual styles.</p><p>Instead of passively waiting for signals, the system can actively design experiences that produce useful signals.</p><p><strong>Content generation becomes part of the recommendation algorithm itself.</strong></p><p>This doesn’t magically eliminate cold start. You still need initial interactions to understand a new user, and generated content still needs to prove that it’s enjoyable.</p><p>But it could dramatically reduce dependence on historical interaction data, particularly for new content.</p><h3>Why I think this matters</h3><p>For the last decade, building a great recommendation system has largely been a data advantage.</p><p>The incumbents have millions of users, billions of interactions and years of optimization behind them.</p><p>Generative AI could fundamentally change the economics of getting started.</p><p>A new platform might not need millions of existing interactions to begin delivering highly relevant experiences. It could use semantic understanding of generated content, a small number of informative user interactions and rapid content experimentation to learn much faster.</p><p>This is especially interesting for content that is becoming increasingly cheap to generate: short-form games, interactive experiences, educational content and eventually other forms of entertainment.</p><p>As the cost of content creation approaches zero, <strong>the bottleneck shifts from having enough content to understanding what content should exist.</strong></p><p>And that’s exactly what a generative recommendation system is designed to do.</p><h3>From recommending content to creating preferences-aligned experiences</h3><p>I think recommendation systems are going to become significantly easier to bootstrap over the next few years.</p><p>Not because collaborative filtering or ranking algorithms become irrelevant. They’ll remain incredibly important.</p><p>But because the recommendation engine will no longer be limited to choosing from whatever content happens to exist.</p><p>It will participate in creating its own supply.</p><p>The best recommendation systems of the last decade learned what people wanted from the content they consumed.</p><p><strong>The next generation might learn what people want by creating content specifically to find out.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b2ff96f7e58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maybe Anthropic is Building a Regulatory Moat]]></title>
            <link>https://ayushhh.medium.com/maybe-anthropic-is-building-a-regulatory-moat-806ea2d998c9?source=rss-c770888b01ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/806ea2d998c9</guid>
            <dc:creator><![CDATA[ayush_cg]]></dc:creator>
            <pubDate>Mon, 15 Jun 2026 12:48:18 GMT</pubDate>
            <atom:updated>2026-06-15T12:48:18.455Z</atom:updated>
            <content:encoded><![CDATA[<p>One possibility is that Anthropic is very strategically trying to create a regulatory moat, essentially converting the free market into a regulated one and killing competition and newcomers, limiting the choices of the end consumer.</p><p>So far, the only huge case of defensibility is the massive capex. It takes tens of billions of dollars to develop a frontier model. AWS survived solely because of the huge capex required to compete with them, likely in the 100s of billions.</p><p>But that may not be true for LLM development and inference. Right now, training and distributing a frontier model likely costs $50B per year, but with algorithmic advances in training and inference, those costs should come down. We also know that coding is one of the main use cases of LLMs, so a much smaller model that is simply SOTA at coding could fulfill like 60% of the demand in the next few years.</p><p>It feels like the capex moat is likely to go away soon with research progress, so a regulatory moat may be the only way to hold a monopoly.</p><p>Non-free markets almost always kill innovation. Pharma is probably the biggest example. If this is true, then it’s going to be a bad outcome for society.</p><p>Recent tweet from Dario:</p><p><a href="https://x.com/DarioAmodei/status/2064781775247950326">https://x.com/DarioAmodei/status/2064781775247950326</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=806ea2d998c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Bearish Case Against AI NPC Startups]]></title>
            <link>https://ayushhh.medium.com/the-bearish-case-against-ai-npc-startups-37c2c43da466?source=rss-c770888b01ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/37c2c43da466</guid>
            <dc:creator><![CDATA[ayush_cg]]></dc:creator>
            <pubDate>Tue, 14 Apr 2026 20:53:18 GMT</pubDate>
            <atom:updated>2026-04-14T20:53:18.686Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kF5dp2iKigODrZSWEpwifA.jpeg" /><figcaption>not related to ai npcs in games</figcaption></figure><p>My team has been exploring a bunch of theses around AI x Games, and naturally, we were really passionate about AI NPCs. I just wanted to pen down some thoughts, reasonings, and realizations we had after speaking with more than 50 game designers, producers, AI designers, and even the creator of the behavioral tree at one point.</p><p>Currently, the gaming industry makes about ~$200B annually, with around 55% coming from mobile game studios. I’m going to throw a lot of macro numbers in this blog that might be slightly off, but they help me keep things simple.</p><p><strong>Our thesis</strong>: We would build a VLA (vision language action model) for gaming that would help game studios make the next generation of 10x NPCs, Enemy AI, and Director AI. This would help genres like Multiplayer (MMORPG) solve the player liquidity and bad bots problem by replacing them with gen AI-driven bots, and also help create entirely more immersive games for genres like Adventure, Open World, and RPG. Essentially, a game like Westworld would finally be possible.</p><p>This thesis had 2 assumptions we needed to validate in our calls. This is a moonshot kind of idea, so even the studios can only guess, but at least their guess is better than ours.</p><p><strong>Assumptions:</strong></p><ol><li>VLA will solve for the next generation of bots in games.</li><li>10x NPCs, Enemy AI, and Director AI will be a huge unlock for the industry, and every AAA studio would want to buy it from us.</li></ol><p>The first assumption got invalidated very quickly. Think about it from this perspective. Why do you need vision models to make Tesla’s self-driving? It’s because you’re trying to make sense of data that is not present in 0s and 1s, it’s present in the 3D world. A vision model helps you vaguely quantify the distance of the car in front of you, its size, its velocity, its direction, and everything else.</p><p>Similar principles can be applied to NPCs inside a game. In order to make them 10x, they have to leave previously scripted behavior and react to the environment and the player naturally, like a living creature. The problem, or advantage, of a game engine is that you don’t need vision models to create that data. That data is already present inside the game engine. You already know the mesh, distance, and velocity of the object in front of you, so why rely on vision heuristics? This is like asking: if you had an Earth API, would you still use vision to self-drive?</p><p>A case for generality can be made here. If you build the vision model for games, that model would be relatively easier to scale across different games and physics systems. But a typical AAA game spends years in production, so most likely they can use text data and tune the model around that within the same timeframe.</p><p>So there goes our thesis on the model side, which I think truly broke the idea. Because now you just need reliable SLMs that can run on edge devices like a player’s laptop. SLMs are important because games usually operate at very large DAUs. Roblox has around 150M, PUBG I think has 30M. If you do cloud inference at this scale, it’s going to cost studios a lot, and most AAA games are sold on flat fees. With cloud, studios would have to bear a continuous cost every time a player plays. It feels like everyone in the industry understands this, and therefore most AI NPC companies are focused on SLMs only.</p><p>But with SLMs, the build vs. buy argument completely flips. Studios will mostly want to use an OSS SLM developed by DeepSeek, OpenAI, or they might just do it themselves since they already have amazing engineers. Developing a VLA is a really hard problem. Architectural improvements were needed, 3D action labeled data was not present at scale, so the company that solves this might have a greater chance at defensibility than one that builds SLMs. And most likely, SLMs are what’s needed, not VLAs.</p><p>Honestly, that could be enough to drop the idea, but we dug deeper and found some market dynamics that broke it further.</p><p><strong>Market Dynamics</strong></p><p>Game studios deeply care about a few metrics: CPI, Retention, Engagement, and Monetization. AAA studios care more about engagement because they usually don’t rely on ads much for UA. It’s more organic, influencer, trailer, and hype driven.</p><p>Other than AI-driven NPCs being exciting, a big advantage for game studios is the dynamic content that players might produce by talking with NPCs and asking them to do random things in the game.</p><p>Studios care about content a lot. Content is what keeps a game alive. GTA 5 Online has been running since more than 10 years ago because thousands of people play it regularly and keep each other engaged. Rockstar doesn’t necessarily have to push a lot of live ops events, skins, or missions to keep the game alive because players engaging with other players is already doing that. That’s not the case in a single-player game, where studios have to spend heavily on live ops content creation just to keep things engaging.</p><p>We had similar beliefs about AI-driven NPCs. NPCs that behave like real humans could keep players engaged, leading to more gameplay hours and more revenue.</p><p>But it turns out, if you look at macro trends, this isn’t really the case. Total game engagement hours across all players is decreasing year over year. The gaming industry is facing really hard competition from short-form content, OnlyFans, and social media. An average teenager who used to play games in 2010 now also has TikTok and Instagram.</p><p>So it feels like the gaming industry has kind of already hit a ceiling in terms of player hours, and that makes sense because it’s a demand-constrained industry. It can’t keep growing forever. Humans can only play so many games in a day.</p><p>An argument that AI NPCs could grow the industry from $200B to $250B falls short when you consider that social media is also improving and becoming more addictive due to AI.</p><p>Another argument was that PC and console gaming is kind of monopolistic. Only 15 to 20 games capture the entire mindshare of players each year. So maybe a game like Westworld comes along with 10x NPCs and kills everything else, capturing 95% of PC and console game revenue. But there haven’t been any real signs of that happening. The creator of AI in Halo 2 confirmed this to us.</p><p>Combining these two reasons, it was hard to stay motivated to build in this area. Also, this feels like a situation where no one can tell you the truth. Maybe AI games kill OnlyFans tomorrow. Maybe a game like Westworld does come around. Maybe a third-party startup does capture that value. Maybe SLMs are indeed what’s needed and studios need tools around them for production readiness, testing AI behavior, orchestration, multi-agent systems, and debugging. So many possibilities exist here, but for us, it didn’t make sense to continue in this area.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37c2c43da466" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Productive Delusions]]></title>
            <link>https://ayushhh.medium.com/productive-delusions-01756af9b12a?source=rss-c770888b01ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/01756af9b12a</guid>
            <dc:creator><![CDATA[ayush_cg]]></dc:creator>
            <pubDate>Wed, 01 Oct 2025 16:49:01 GMT</pubDate>
            <atom:updated>2025-10-01T16:49:01.091Z</atom:updated>
            <content:encoded><![CDATA[<p>At this point, it feels like I’m sharing way too much on blogs, but I guess it will help me remember the journey. I’m going to write this down somewhere in a private doc anyway, so why not publish it on the open internet for others to read?</p><p>It’s been about a year since I graduated from college, and it feels like I’ve had three very strong and productive “delusions.” I didn’t want to use the word “delusion” initially since “conviction” would have been a better choice. But when I think about it, “delusion” actually seems more accurate. In hindsight, these tasks I wanted to achieve were quite delusional, less connected to reality from the perspective of my brain and surroundings.</p><p>In the early days of SpaceX, Elon Musk was quite delusional until he developed a strong conviction about what was possible. He was still very delusional when he claimed SpaceX would land on Mars by 2010. It’s now 2025, and we haven’t even attempted a manned flight to Mars yet. But still, SpaceX is in a much better position to make humanity a multi-planetary species than it was back in 2004 when Elon started. So it’s safe to assume these “delusions” are often good for humanity. Because of them, people like Elon are able to move very fast, set unrealistic timelines they can’t achieve at first, but still create a sense of urgency and a larger-than-life purpose.</p><p>Back when I was preparing for JEE, I used to study very hard. I was in love with Physics, Math, and Organic Chemistry (though I hated Inorganic and Physical Chemistry). I had a very clear conviction in my head that I was going to get an AIR 1 (which I didn’t, of course). I think this was the goal of almost everyone preparing for JEE, but for me it wasn’t the only goal. Unlike others, I always ended up having these larger-than-life expectations of myself. At that point, I wanted to become a theoretical physicist, inspired by Einstein and quantum mechanics.</p><p>I noticed a gap in physics. The Theory of Relativity worked very well for large objects in space and time, like the Sun, Jupiter, and black holes. Newtonian physics and the laws of motion clearly explained day-to-day objects like cars, wind, and metal balls. And then there was this new physics, Quantum Mechanics, which was never taught properly in school but clearly explained how subatomic particles behaved. But there was still no clear Theory of Everything: a single framework that explains all fundamental forces and particles of the universe in one unified theory.</p><p>Naturally, that became my main objective during JEE. I ended up ditching a lot of mock tests because I thought they added no true value to my pursuit of coming up with the Theory of Everything. Eventually, I scored badly in the mains, though I did a little better in the advanced exam (ranked around 15–17k, which isn’t good at all). Looking back, I think that was my first “delusion.”</p><p>In college came my second delusion. I had been studying very hard throughout college. I tried everything: competitive programming, ICPC, cryptography, distributed systems, networking, web3, Bitcoin open source. I had a clear goal that I wanted to create a company down the line and therefore I had to explore a lot in order to understand what different people were doing and what gaps I could solve as a company. I got really inspired by Satoshi Nakamoto — how he was able to stay anonymous and add so much value through Bitcoin. At that time web3 was booming and we all knew it was very hard to scale Ethereum because of its nature as a decentralized currency. They called this problem the Ethereum Trilemma, and again I thought this was one of the hardest problems in the space. I definitely loved this space and wanted to work there, so why not become the person who solved this problem?</p><p>I spent the next year learning everything about how these protocols worked. I remember doing three courses at the same time: Cryptography, Math for Competitive Programming, and Decentralized Systems. Of course I failed to solve the Trilemma (it’s still unsolved), but I ended up contributing to the Bitcoin Core codebase originally created by Satoshi Nakamoto and got an internship at Summer of Bitcoin, which I think is still one of the best things I have done.</p><p>Post-college I got into Meesho and I was assigned to their Cybersecurity division (I think because of my previous experience in cryptography and security during Bitcoin contributions). At first I didn’t like the field. I wanted to write more backend code and scale systems, and cybersecurity felt inferior at that time. But I was clearly naive. I ended up writing a lot of code — backend, Kafka, and everything — way more than my intern colleagues who were assigned backend teams.</p><p>But working in cybersecurity and also researching Generative AI made me realize that everyone on the planet is trying to automate coding with English, and the same is not happening in security. It felt that this approach was not scalable because for a Fortune 500 company it’s too risky to put a feature into production without a security review. So I had to automate it. Therefore comes my latest and this time not-so-delusional and quite realistic pursuit: scaling security reviews with AI agents, i.e. hackwithalan.com.</p><p>I do believe somewhere within these delusions I’ll find something that I can spend the next 10 years of my life on without a doubt and that will have so much value to humanity. I think that’s the goal after all.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01756af9b12a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[High Severity GraphQL DoS via Alias Overloading Identified by Alan AI]]></title>
            <link>https://ayushhh.medium.com/high-severity-graphql-dos-via-alias-overloading-identified-by-alan-ai-65b5b2c32113?source=rss-c770888b01ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/65b5b2c32113</guid>
            <dc:creator><![CDATA[ayush_cg]]></dc:creator>
            <pubDate>Fri, 23 May 2025 05:58:58 GMT</pubDate>
            <atom:updated>2025-05-23T05:58:58.811Z</atom:updated>
            <content:encoded><![CDATA[<p>Alan AI was tasked with identifying GraphQL-related security vulnerabilities on a public bug bounty platform.</p><h3>Context:</h3><p>We have been participating in a public bug bounty program using our AI agent, Alan AI. Recently, it autonomously discovered a GraphQL Denial-of-Service (DoS) vulnerability caused by alias overloading.</p><h3>Impact:</h3><p>An attacker could exploit the affected API by batching queries, significantly increasing the service’s latency. This makes it a high-severity issue.</p><h3>The Hacking:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2DC8bSoWVzaRmKlmrSjp0A.png" /><figcaption>Gathering Requirements</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O7v0bf60Z05tQA61tEWykw.png" /><figcaption>Trying to generate some network traffic to intercept the GraphQL API</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9vBw5bkBbL9lm5FNnxVl7w.png" /><figcaption>Looking Access control Issues</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y5gXCapOl9G03DWU-T5VsA.png" /><figcaption>Validating its approach and asking for other credentials for checking more access control.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uIHdiwxkVp36mb3WXB0OIA.png" /><figcaption>Re-Authenticating to the Application because of short lived Session tokens</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JFchH3Guhc361vsxi_bI6A.png" /><figcaption>Finally Identifying an Alias overloading GraphQL — High Severity GraphQL DOS</figcaption></figure><p>This demonstrates how Alan can autonomously gather user requirements, interact with the website, understand business logic, generate traffic, and ultimately identify vulnerabilities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65b5b2c32113" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Alan: From Idea to Finding Three Critical Subdomain Takeovers in the Wild]]></title>
            <link>https://ayushhh.medium.com/building-alan-from-idea-to-finding-three-critical-subdomain-takeovers-in-the-wild-df7c7cb2f3f1?source=rss-c770888b01ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/df7c7cb2f3f1</guid>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[ayush_cg]]></dc:creator>
            <pubDate>Tue, 25 Mar 2025 21:04:19 GMT</pubDate>
            <atom:updated>2025-03-25T21:10:24.208Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey everyone! Quite exciting writing this since it’s the first time I’m sharing what I’ve been working on for the past few months. We’ve been building a Dynamic Security LLM Agent that autonomously detects vulnerabilities in web applications. We have named the agent <strong>Alan</strong> — <strong>your security engineering teammate</strong>, who can handle various tasks that a routine security engineer would, such as talking to developers about new features, conducting reconnaissance, discovering attack vectors, and finally, exploiting or assessing whether a vulnerability exists — all autonomously, with human intervention only when required.</p><p>For analogy, at this point, Alan can be considered your junior security engineer—well-versed in all the cyber-sec tooling and familiar with most common application vulnerabilities, but still needing occasional guidance to stay on track.</p><h3>Finding 3 Critical Subdomain Takeovers</h3><p>While Alan is still in its pre-MVP stage, it has already become <strong>highly capable in security tooling and orchestration</strong>. Unlike traditional automated tools, Alan behaves like a <strong>human security engineer</strong>, allowing it to find vulnerabilities that require <strong>semi-automated</strong> or <strong>manual</strong> effort — like <strong>subdomain takeovers</strong>.</p><h4>Why Subdomain Takeovers Are Still a Challenge</h4><p>Subdomain takeovers were a <strong>popular attack vector a decade ago</strong>, and while automation has improved, the rise of <strong>new SaaS platforms</strong> launching daily makes it <strong>impossible</strong> for tools like <strong>Nuclei</strong> and <strong>Can-I-Take-Over-XYZ</strong> to cover every possible case. Since every SaaS behaves differently, <strong>manual validation is still required</strong>.</p><p>This is where Alan comes in.</p><h4>Step-by-Step: How Alan Found the Takeovers</h4><h4>Step 1: Reconnaissance on the Target Domain</h4><p>I gave Alan a target domain that I found on Twitter through a <strong>chat-based interface</strong>. Alan then performed <strong>automated reconnaissance</strong>, looking for:<br> ✔ <strong>All subdomains of the target</strong><br> ✔ <strong>CNAME records</strong> for each subdomain (to check if they point to third-party services)</p><h4>Step 2: Identifying Potentially Takeover-able Subdomains</h4><p>After mapping <strong>subdomain-to-CNAME relationships</strong>, Alan started evaluating them one by one:<br> ✔ <strong>Checked for inactive or expired SaaS services</strong> linked to these subdomains<br> ✔ <strong>Analyzed page behavior</strong> to detect signs of expired hosting (404 errors, default pages, etc.)</p><h4>Step 3: Researching the SaaS Provider</h4><p>Alan needed <strong>additional context</strong> to confirm the takeover possibility:<br> ✔ <strong>Searched Google &amp; security blogs</strong> for previous takeover reports on that SaaS<br> ✔ <strong>Checked platforms like HackerOne</strong> for past bounty reports<br> ✔ <strong>Looked into Nuclei &amp; Can-I-Take-Over-XYZ lists</strong> to see if this SaaS was already known to be vulnerable</p><p>In our case, <strong>Google searches didn’t yield much confidence</strong>, meaning <strong>manual validation was required</strong>.</p><h4>Step 4: Human-in-the-Loop Validation</h4><p>Since Alan <strong>can’t autonomously log in to SaaS platforms</strong>, it <strong>asked for human assistance</strong>:<br> ✔ I manually logged into the SaaS provider’s website<br> ✔ Alan checked whether it could <strong>modify the subdomain settings</strong> to a custom domain</p><p>Once Alan confirmed that the subdomain could be reassigned, it determined <strong>with high confidence</strong> that a subdomain takeover was possible.</p><h4>Step 5: Responsible Notification Instead of Exploitation</h4><p>Since Alan is designed <strong>not to exploit vulnerabilities</strong> (only to <strong>discover and assess risks</strong>), it:<br> ✔ <strong>Notified us</strong> about the confirmed takeover risk<br> ✔ <strong>Did not execute the takeover</strong>, as we configured it to avoid harmful actions</p><p>This was still <strong>in the reconnaissance phase</strong>, meaning Alan’s role was purely to <strong>gather useful intelligence for security assessment</strong>.</p><figure><img alt="My first bug bounty submission came through Alan" src="https://cdn-images-1.medium.com/max/1024/1*E4hqPL-6OIJH7-Sw7qqoRg.jpeg" /><figcaption>My first bug-bounty submission came through Alan — I can’t disclose the domain here</figcaption></figure><p>This was classified as a duplicate, but it was still exploitable when I reported it and was fixed immediately.</p><blockquote>But we still consider this a big win since there was an exploitable vulnerability, and Alan was able to detect it with very little intervention.</blockquote><h3>Next Step and Ultimate Goal</h3><p>We have been exploring different ways to integrate Alan into existing teams. One of the most obvious approaches is to first automate all the grunt work that security engineers have to go through before, during, and after penetration testing (hacking, essentially) of a feature. This includes <strong>requirement gathering, reconnaissance, and exploiting some of the most common vulnerabilities</strong>.</p><p>Our ultimate goal with Alan is to elevate every security engineer into a <strong>security researcher</strong>. As a security engineer, I don’t particularly enjoy repeatedly finding <strong>IDORs, DoS vulnerabilities, and access control issues</strong> — while I do get satisfaction from discovering them, the process itself is not as exciting as it once was. Instead, I want my fellow security engineers, who have always aspired to work on <strong>malware research, supply chain attacks, new zero-days, and cache vulnerabilities</strong>, to focus on those areas. Meanwhile, Alan can take care of all the known bugs in the software.</p><p>Thanks for reading looking forward to writing more updates and eventually launching this soon for the world!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df7c7cb2f3f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Summer of Bitcoin’23: My Experience]]></title>
            <link>https://ayushhh.medium.com/summer-of-bitcoin23-my-experience-1357a0f16495?source=rss-c770888b01ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/1357a0f16495</guid>
            <category><![CDATA[bitcoin-core]]></category>
            <category><![CDATA[experience]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[summer-of-bitcoin]]></category>
            <category><![CDATA[fuzzing]]></category>
            <dc:creator><![CDATA[ayush_cg]]></dc:creator>
            <pubDate>Sat, 19 Aug 2023 00:00:19 GMT</pubDate>
            <atom:updated>2023-08-19T00:19:41.313Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BAwtT5NwFHcMNWEw" /></figure><p>Hello, everyone! Penning down these words as we approach the end of the summer in 2023, I’ve just wrapped up my internship at Summer of Bitcoin. Undoubtedly, this experience ranks among the most wonderful things in recent times.</p><p>It involved lots of coding (ofc), meeting incredibly awesome people, and working with fantastic mentors. But what made it truly special was that, for the first time in my life, I did something that had a real impact on the world.</p><p>I think it’s essential for all of us to have a vision of the world we want to build, and I believe I might have just found mine. This is the future I’m building!</p><p>Here’s a basic overview of how the program looks from my perspective:</p><h4>Applications and Screening:</h4><p>The initial step involves completing the applications. If the program organizers consider you a suitable candidate, they will provide you with a test link. Based on your performance in this test, they will assess your problem-solving abilities. In 2023, the test comprised two data structures and algorithm problems.</p><p>Fortunately, when I applied, my competitive programming profile was quite strong, which led to the exclusion of this round in my evaluation. (If you have previously been a GSOC intern or have participated in any other well-known open-source program, it is highly probable that you will also be exempt from this round and proceed directly to the next stage.)</p><h4>Learn Bitcoin Course:</h4><p>This year, they tried something different and added a new phase in which candidates had to finish a fundamental Bitcoin learning course before moving on to the next round. I believe this is important as it gives you a basic understanding of what is Bitcoin, why it is important, and what you are enrolling into.</p><h4>Proposals:</h4><p>Selected candidates advance to the next level when they are presented with a list of organizations and projects. It is recommended that each participant make proposals for one or two of these projects. The website contains all of the technical information needed, but the one thing that troubled me the most was deciding which organization to choose.</p><p>My only advice to anyone who is perplexed by the same issue is to not limit yourself to the technology you are familiar with. Choose an organization whose projects and goals you most connect with and are most driven by. The proposal and program period will most likely be sufficient for learning about new technologies. I learned <strong>C++</strong> for the first time in order to contribute to <strong>Bitcoin Core</strong>. Most of the other interns also learned new technologies in order to contribute. Personally, I found Bitcoin Core’s projects to be the most fascinating because they included networking and security. These are the areas I’ve long been intrigued by.</p><p>Once you’ve found some organizations that excite you the most, you should go on and try to complete their project’s Competency Tests. Completing a project’s competency test successfully indicates that you have everything the project requires and that with enough effort, you will be able to complete the project on time.</p><p>One thing I believe I did better than other students who gave proposals to Bitcoin Core was to be active in community conversations. I was helping other students in completing their competency tests and resolving their project-related questions.</p><blockquote>Contributing to open-source is not about competition for me. Imagine it as an intellectual charity in which you try to help others with great kindness.</blockquote><p>By the end of the proposal, you should have enough contributions (anything, PRs, blogs, community presence) to present your proposal. Again, the SoB website has all you need to know about writing a superb proposal. But the only advice I can give is to try to show your intent clearly, to show that you are not just motivated to contribute for the sake of Summer of Bitcoin or money, but that you genuinely align with the goals of the organization and intend to continue contributing to it even after the program ends.</p><p>Here’s my Proposal for Bitcoin Core: <a href="https://docs.google.com/document/d/1VcfN85PG_11YTK4YNRjWYS_QOgcMrjkwl6aHTHCBZts/edit"><em>Summer of Bitcoin 2023 Proposal — Bitcoin Core</em></a></p><h4>Project Period Kicks-Off:</h4><p>Selected proposals are instructed to meet with their mentors to discuss their work and timeframe, and the project is started!</p><p>This concludes the pre-project time; now, let us discuss my project and what I contributed.</p><h4>My Project:</h4><p>The Bitcoin Core Wallet codebase had almost no Fuzz coverage to it (<a href="https://github.com/bitcoin/bitcoin/issues/27272#issue-1628327906"><em>look</em></a>). My job was to increase the Fuzz coverage over the wallet codebase by writing Fuzz Harness files for it.<br>If these terms confuse you, kindly have a look at my other blogs: <a href="https://ayushhh.medium.com/fuzzing-bitcoin-core-using-libfuzzer-definition-and-implementation-93cd078ce3a0"><em>Blog1</em></a>, <a href="https://ayushhh.medium.com/the-fuzz-developer-dilemma-writing-efficient-fuzz-targets-d480bd1a52f4"><em>Blog2</em></a><em>.</em></p><h4>My Contributions:</h4><p>My contributions to Bitcoin Core include 5 files, 4 PRs, 3 technical blogs, and one new introduction to the coding style of Bitcoin Core. One of my merged PRs indicated an increase in Fuzz coverage of over 98% for its file. I can’t tell how much more Fuzz coverage there is because most of the PRs have yet to be merged into the Core. But I’ll update the blog as soon as they are.</p><p>Here are some of my most valuable contributions:</p><ul><li><a href="https://github.com/bitcoin/bitcoin/pull/27902"><strong>Coin Control</strong></a> PR merged, with <a href="https://github.com/bitcoin/bitcoin/pull/28236"><strong>Spend</strong></a> and <a href="https://github.com/bitcoin/bitcoin/pull/28074"><strong>Crypter</strong></a><strong> </strong>PRs<strong> </strong>live and under review.</li><li>Introduced the concept of <a href="https://github.com/bitcoin/bitcoin/pull/28236/files"><strong>Singleton Classes</strong></a> in the Bitcoin Core codebase. To the best of my knowledge, no one used Singleton in the codebase before this. For our file, my mentor and I discovered how helpful the use of Singleton can be on the speed of Fuzz targets because it saves multiple creations of the same objects, by re-using the already created object again and again. (I’m still waiting for other Core reviewers to comment on this)</li></ul><h4>Community Interaction:</h4><p>Interning in the Summer of Bitcoin not only gave me exposure to meet other wonderful and talented interns, alums, and mentors but also indirectly helped me to be a part of some other wonderful communities as well. One of them is <a href="http://bitshala.org/"><strong>Bitshala</strong></a>, a huge shout out to everyone on their Discord server for helping me throughout the journey and explaining technical concepts to me on calls that would have been extremely tough for me to understand otherwise. They also gave me an opportunity to listen and interact with Adam Jonas, which was just awesome!</p><p>We also had the opportunity to speak with <a href="https://twitter.com/adi_shankara_"><strong>Adi Shankara</strong></a> (the man himself) about Bitcoin-related topics. I could listen to him talk about Bitcoin for hours; he’s one of the most intelligent and passionate people I’ve met in the entire space. Adi, thank you for starting it all!</p><h4><strong>The Most Wonderful Mentor:</strong></h4><p>The man, the myth, the legend, <a href="https://twitter.com/brrrunog">Bruno Garcia</a>. The most shocking thing about Bruno is that he is just 23! (24 now ig) and already a legend in the Bitcoin ecosystem. He at the start of the program told me that we are going to keep this as a learning experience for you. He made me comfortable with doing mistakes and learning from them along the way. Never pressured me with anything. We worked like a force throughout the 3 months period, towards increasing the Fuzz coverage over the wallet. If I’m not wrong we contributed nearly 7 PRs to Bitcoin in this period related to Fuzzing! (most of them are his, ofc)</p><h4>Conclusion:</h4><p>I believe that open source and Bitcoin have and will continue to improve my life and the lives of millions of others. I’m not sure about the millions, but I’m planning to write some more follow-up blogs about how open-source helped me get a better career! See you soon!</p><p><strong>Author:<br></strong>Ayush Singh (<a href="https://twitter.com/Ayush_cg">Twitter</a>)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1357a0f16495" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up Cirrus CI for Your Bitcoin Core Fork]]></title>
            <link>https://ayushhh.medium.com/setting-up-cirrus-ci-for-your-bitcoin-core-fork-40d85799a9a4?source=rss-c770888b01ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/40d85799a9a4</guid>
            <dc:creator><![CDATA[ayush_cg]]></dc:creator>
            <pubDate>Sun, 13 Aug 2023 20:55:42 GMT</pubDate>
            <atom:updated>2023-08-13T20:55:42.742Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction:</h3><p>In the world of open-source development, maintaining the integrity and quality of your contributions is crucial. One powerful tool that aids in this endeavor is continuous integration (CI). In this guide, we’ll explore the process of setting up Cirrus CI for your fork of Bitcoin Core, ensuring that your commits are thoroughly tested before making their way into the main repository. Let’s dive into the step-by-step process to achieve this seamlessly.</p><h3>Why Add Cirrus CI to Your Workflow?</h3><p>Before delving into the setup process, let’s understand why integrating Cirrus CI is important. When working on open-source projects like Bitcoin Core, changes should be rigorously tested before they’re incorporated. This is where continuous integration shines. It automates the process of building, testing, and validating code changes, making sure that new commits don’t introduce regressions or vulnerabilities. By ensuring that your commits pass a battery of tests, you not only maintain code quality but also enhance collaboration by submitting reliable pull requests (PRs) to the Bitcoin Core repository.</p><h3>Step-by-Step Setup Guide:</h3><ol><li>Access Cirrus CI from GitHub Marketplace: Start by visiting the <a href="https://github.com/marketplace/cirrus-ci">Cirrus CI</a>. Here, you’ll find all the resources needed to integrate Cirrus CI with your GitHub account.</li><li>Select Public Repository Free Option: Choose the public repository free option to avail of the CI services for your public repositories. If your goal is to contribute to Bitcoin Core then this option is what you want.</li><li>Install Cirrus CI for Free: Click on the “Install” button. This initiates the process of integrating Cirrus CI with your GitHub account.</li><li>Fill in your details: You’ll be prompted to fill in your Name, Address, etc.</li><li>Complete Order and Begin Integration: This confirms your intent to integrate Cirrus CI.</li><li>Authorize Repository Access: Upon installation, Cirrus CI will request authorization to access your GitHub repositories. To ensure comprehensive testing, authorize access to your Bitcoin Core fork.</li><li>Live Testing on each Commit: With Cirrus CI integrated, every commit you make to your Bitcoin Core fork triggers a comprehensive suite of tests. This automated testing ensures that any changes you introduce are thoroughly evaluated.</li></ol><p>If your CI was correctly integrated, each of your commits will have a list of running integration tests like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*763Uo6lU3lEUntB1_IXGBw.png" /></figure><p>To investigate further, why a particular test is failing for your commit, you can see the <strong>live logs</strong> by clicking the <strong>Details </strong>button on the right side of each test.</p><h3>Conclusion:</h3><p>Integrating Cirrus CI into your open-source workflow is a proactive step towards maintaining code quality and contributing effectively to projects like Bitcoin Core. By automating the testing process for your commits, you can identify and rectify issues early, making the pull request process smoother and more efficient. The ability to submit well-tested code not only benefits your personal fork but also contributes to the overall stability and reliability of the Bitcoin Core ecosystem.</p><p>Incorporating CI practices aligns with the ethos of collaborative development, where transparency, reliability, and continuous improvement take center stage. As you embark on this journey of code enhancement, rest assured that your commitment to rigorous testing will significantly impact the open-source community.</p><h4>About the Author:</h4><p>I’m Ayush Singh. A Bitcoin Core FOSS contributor and Summer of Bitcoin’23 Intern, working under <a href="https://github.com/brunoerg">Bruno Garcia</a> to improve Fuzz coverage over the Wallet codebase in Bitcoin Core.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40d85799a9a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Fuzz Developer Dilemma — Writing Efficient Fuzz Targets]]></title>
            <link>https://ayushhh.medium.com/the-fuzz-developer-dilemma-writing-efficient-fuzz-targets-d480bd1a52f4?source=rss-c770888b01ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/d480bd1a52f4</guid>
            <dc:creator><![CDATA[ayush_cg]]></dc:creator>
            <pubDate>Thu, 10 Aug 2023 23:19:11 GMT</pubDate>
            <atom:updated>2023-08-10T23:19:11.978Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Fuzz Developer Dilemma — Writing Efficient Fuzz Targets</h3><p>For the past 2.5 months, I’ve been working as a Summer Intern at Summer of Bitcoin, where my job is to write Fuzz harness files for the codebase of the Bitcoin Core Wallet. If this doesn’t make sense right away, don’t worry; I’ll do my best to explain it once you’ve finished reading this blog.</p><p>Before reading this blog, it is necessary to have a basic understanding of what fuzzing is. If you are unfamiliar with this type of testing, I recommend reading my previous blog (<a href="https://ayushhh.medium.com/fuzzing-bitcoin-core-using-libfuzzer-definition-and-implementation-93cd078ce3a0"><em>here</em></a>). If you’re seeking a more comprehensive understanding, take a look at this: <a href="https://google.github.io/oss-fuzz/"><em>OSS-Fuzz doc</em></a>.</p><p>Assuming you are familiar with the fundamentals of fuzzing, let’s explain what a fuzz target is and how it differs from a fuzz harness.<br>Keeping this quick, Fuzz Harness is often the file in which you write the Fuzz target.</p><h3>Fuzz Target</h3><p>Imagine it as an API or a gateway, facilitating the entry of randomness into your codebase. Sounds pretty fancy, right? It is really interesting. Let’s get deeper into this.</p><p>OSS-Fuzz defines a Fuzz Target as a function that takes an array of bytes and applies the API under test to do something fascinating with those bytes. To clarify, let’s look at an example.</p><p>Suppose you want to do Fuzz Testing of the <a href="https://github.com/bitcoin/bitcoin/blob/master/src/wallet/spend.cpp#L1132">CreateTransaction</a> function in the Bitcoin Core Wallet codebase (Don&#39;t worry if you don&#39;t understand the Bitcoin Core codebase, just think of it like any other C++ function you want to fuzz).</p><p>Your current task involves calling this function in your Fuzz Harness file, where random bytes from the Fuzzer serve as input. The challenge is to do so in a manner that maximizes <a href="https://en.wikipedia.org/wiki/Code_coverage">Code Coverage</a>, leading to an intriguing mess I like to call “<strong>The Fuzz Developer Dilemma</strong>”.</p><h3>The Fuzz Developer Dilemma</h3><p>BTW, I’m just making this up; it’s not a thing. I refer to this as a dilemma because there are two possible types of inputs for the CreateTransaction function: <strong>Good inputs</strong> and <strong>Random inputs</strong>.</p><ol><li><strong>Good Input: </strong>This type of input contains ideal values for all of the parameters required by CreateTransaction. For example, the Wallet will include funds, and Coin Control will contain valid settings as well as selected Coins to initiate a transaction. If you leave Bitcoin Core running, it will only generate this type of input. Furthermore, because these inputs are valid, they have <strong>Maximum Code Coverage </strong>because the code allows these inputs to propagate deep inside it.<br>But is this even Fuzzing if the inputs aren’t random, strange, or even in-valid sometimes?</li><li><strong>Random Input</strong>: This is the type of input you truly want to give to a function while Fuzzing it. These inputs will discover crashes that the developers might have overlooked.</li></ol><ul><li>Imagine giving a Walletwith 0 funds to CreateTransaction.</li><li>Imagine supplying a Coin Controlto CreateTransaction that has faulty settings and selects random, false coins for Transaction creation.</li></ul><p>These are the type of inputs that make your Code go crazy, behaving in a manner that you would never expect it to. That is exactly what we want while fuzzing!<br>However, this has the <strong>lowest Code Coverage</strong> because your code will avoid propagating these kinds of inputs deep into the codebase (which is good by the way) as these inputs will make no sense to it, making the Fuzzing less effective as the code coverage is low.</p><p><strong>So, what should a Fuzz Developer do to strike the right balance between Good Inputs and Random Inputs</strong>?</p><p>Well, that’s where the art of writing an effective Fuzz Target comes into play.</p><p>An effective Fuzz Target is one that intelligently combines both types of inputs to achieve a comprehensive Fuzz Testing approach. By strategically mixing good inputs with random inputs, you can increase the chances of discovering hidden vulnerabilities while still maintaining decent Code Coverage.</p><p>One can achieve this by using a <strong><em>Random Switch Case </em></strong>where in one case you can update the input value to a Good Input and in the other case update it with a Random Input. So, “sometimes” you are calling CreateTransaction with Good input and “sometimes” not.</p><p>We use <a href="https://github.com/Ayush170-Future/bitcoin/blob/fuzz-coverage-spend/src/wallet/test/fuzz/spend.cpp#L141">CallOneof</a> function for creating a <strong><em>Random Switch Case </em></strong>in Bitcoin Core. CallOneof can also be used to generate different <a href="https://www.quora.com/What-is-a-code-path"><strong><em>Code Paths</em></strong></a> during fuzzing, we will see this later in the blog.</p><h3>Ways to improve Fuzz target efficiency?</h3><p>Until now, we focused mainly on Code Coverage, but there is another important factor that influences your Fuzzing process, and that is <strong>Speed</strong>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FnqYXNf3aK6EvK%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FnqYXNf3aK6EvK&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExazB6ZWRiajYyamRhcG02dWtoc3l5bjR6cjhkZjZncW8zamV6NDBpbyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FnqYXNf3aK6EvK%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="221" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6e2b978cd579ee5766c26464b5a295b/href">https://medium.com/media/e6e2b978cd579ee5766c26464b5a295b/href</a></iframe><p>By Speed, I mean Execution per second (exec/sec). The reason why this is important is that your Fuzz Target file is going to be executed repeatedly with different mutated inputs. If your file is slow and each execution takes a significant amount of time, the overall fuzzing process will be greatly hindered. The time it takes for each execution accumulates as the Fuzzer explores various inputs, potentially leading to a much longer time to discover bugs or vulnerabilities. Therefore, it’s crucial to optimize the speed of your Fuzz Target file to achieve a higher exec/sec rate, allowing the Fuzzer to cover more test cases efficiently and increase the chances of uncovering potential issues.</p><p>One should aim for at least <a href="https://chromium.googlesource.com/chromium/src/+/main/testing/libfuzzer/efficient_fuzzing.md#:~:text=for%20at%20least-,1%2C000%20exec/s,-from%20your%20fuzz"><em>1,000 exec/sec</em></a> according to the general consensus in the ecosystem.</p><h3>Here are different ways to speed up your Fuzz target:</h3><ol><li><strong>Write efficient Setup: </strong>A setup function is just a function that is executed before the start of the Fuzzing process; its job is to build the environment needed to run that specific Fuzz Target. It is best to only set up things that are essential for Fuzzing. Setting up a variable that will never be used inside the Fuzzing, for example, is pointless because it will take time unnecessarily.</li><li><strong>Move Redundant things inside the </strong><a href="https://github.com/Ayush170-Future/bitcoin/blob/fuzz-coverage-spend/src/wallet/test/fuzz/spend.cpp#L114"><strong>Setup</strong></a><strong>: </strong>All duplicate setup codes should be moved inside it so that it is not repeated over and again in each Fuzz run.</li><li><strong>Optimize the Fuzzing Algorithm: </strong>Explore different ways to write the same target file and select the one that is the fastest.</li><li><strong>Avoid big Loops inside your target: </strong>One should avoid having unnecessarily large loops inside their Fuzz target as they would take time to execute. But doing so shouldn’t be done by reducing loops when they are required. Priorities the functionality of the test first.</li><li><strong>Use the Singleton Class: </strong>If you find yourself repeatedly creating instances of a particular object during each fuzz run, it can be advantageous to implement the Singleton design pattern. By employing the Singleton class, you ensure that only a single instance of the object exists throughout the entire fuzzing process, saving valuable time spent on redundant object creation and initialization. Check my code for this — <a href="https://github.com/Ayush170-Future/bitcoin/blob/fuzz-coverage-spend/src/wallet/test/fuzz/spend.cpp#L30">here</a>.</li><li><strong>At last, try to think for yourself which part of the code is time-consuming and make it faster!</strong></li></ol><h3>Conclusion</h3><p>Last but not least, I just wanted to note that many developers don’t make their Fuzz Target efficient and simply rely on the fuzzing software to do the job, but in my opinion that is not the way to do it. Writing the best possible target should always be the goal!</p><p>Thanks!</p><h3>Author</h3><p>Ayush Singh (<a href="https://twitter.com/Ayush_cg"><em>Twitter</em></a>)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d480bd1a52f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fuzzing Bitcoin Core using LibFuzzer: Definition and Implementation]]></title>
            <link>https://ayushhh.medium.com/fuzzing-bitcoin-core-using-libfuzzer-definition-and-implementation-93cd078ce3a0?source=rss-c770888b01ef------2</link>
            <guid isPermaLink="false">https://medium.com/p/93cd078ce3a0</guid>
            <category><![CDATA[fuzzing]]></category>
            <category><![CDATA[summer-of-bitcoin]]></category>
            <category><![CDATA[libfuzzer]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[ayush_cg]]></dc:creator>
            <pubDate>Fri, 26 May 2023 10:23:10 GMT</pubDate>
            <atom:updated>2023-05-26T10:42:06.549Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Bitcoin core" src="https://cdn-images-1.medium.com/max/370/1*aqufDJSmp12FLqSj78CdNw.png" /></figure><p>In this blog, we are going to discuss how to do Fuzzing in bitcoin core using libFuzzer.</p><p>Before moving further let&#39;s define what fuzzing is.</p><p>Fuzzing is a testing technique that is employed in softwares to find potential vulnerabilities. It is the process of injecting random (sometimes not so random) input into a software/program and observing how it reacts. Any software that allows arbitrary user inputs is a suitable candidate for fuzzing.</p><p>The main objective of fuzzing is to uncover inputs that cause the program to behave unexpectedly, resulting in a panic scenario and a software crash.</p><p>Let’s call these inputs <em>bad inputs</em>.</p><p>These bad inputs are later handed to software developers, who modify the software to handle them.</p><blockquote><strong>Note:<br></strong>If a program already handles some kind of errors then inputs creating those errors need not be fuzzed as that is not an unexpected behavior. The main goal of fuzzing is to identify unexpected behavior.</blockquote><h3>libFuzzer</h3><p>libFuzzer is a library designed by Google employees to help with application fuzzing. libFuzzer is used to perform coverage-guided fuzzing (details on this are beyond the scope of this blog). <br>It is integrated with the Clang C compiler and can be enabled by adding a flag and a fuzzing target (harness file) to your code. libFuzzer works similarly to Unit-Testing, fuzzing one file at a time.</p><h4>Harness file</h4><p>The harness file is a small modification of the source code of the file to be fuzzed that serves as an entry point for fuzzing. It performs the initial setup required to perform fuzzing on a certain file and also provides a mechanism to directly fuzz input into the codebase when doing so via the command line or another traditional method is not possible.</p><p>These harness files contain the Fuzz target method implementation, which is used to enter data into the program.</p><p>Once you have the harness file and Clang C compiler installed on your system you are ready to do some fuzzing!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F15670049&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fhooray-sponge-bob-patrick-yey-celebrate-gif-15670049&amp;image=https%3A%2F%2Fmedia.tenor.com%2FnH1S2A13mO4AAAAC%2Fhooray-sponge-bob.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed7d2c1a0096cc655233072ba759e249/href">https://medium.com/media/ed7d2c1a0096cc655233072ba759e249/href</a></iframe><h3>libFuzzing the Bitcoin Core</h3><p>Now let’s see how to do fuzzing of Bitcoin Core software using the libFuzzing tool.</p><blockquote><em>Note: I’ll be using a Linux environment for this tutorial, so if you are on Windows kindly run these commands on WSL instead of the Command Prompt.</em></blockquote><p>All the fuzz harness files are present in this directory:</p><pre>src/test/fuzz/</pre><h4>Installing libFuzzer</h4><p>Since libFuzzer is already integrated into the Clang compiler, so we only need to install clang and gcc.</p><pre>sudo apt install gcc<br>sudo apt install clang</pre><h4>Let&#39;s start fuzzing</h4><p>As libFuzzer allows us to fuzz individual source code files, for this tutorial we are going to fuzz the <a href="https://github.com/bitcoin/bitcoin/blob/master/src/banman.cpp"><em>banman.cpp</em></a> file.</p><p>The first step is to clone the Bitcoin Core source code from GitHub:</p><pre>git clone https://github.com/bitcoin/bitcoin </pre><p>Move to the Bitcoin directory:</p><pre>cd bitcoin</pre><p>Run autogen.sh script. It is used to generate build configuration files required for compiling the Bitcoin core source code.</p><pre>./autogen.sh</pre><p>Setting variables to set Bitcoin core parameters for building, as well as configuring the fuzzing flags.</p><pre>CC=clang CXX=clang++ ./configure --enable-fuzz --with-sanitizers=address,fuzzer,undefined</pre><p>Let’s break down each option here:</p><ol><li>CC=clang and CXX=clang++ : These environment variables are used to set the C and C++ compilers to use during the build process.</li><li>./configure : Used to build configuration.</li><li>--enable-fuzz : Enable fuzzing support in Bitcoin Core. Ensures necessary dependencies are included in the build.</li><li>--with-sanitizers=address,fuzzer,undefined : Now these are settings for libFuzzer. This option enables specific sanitizers for detecting different types of errors. address is helps detect memory access errors such as out-of-bound, heap overflow, etc. undefined is used to detect undefined behavior in the code.</li><li>fuzzer : with this flag Clang automatically links our program with the fuzzer library present in the Bitcoin core.</li></ol><p>After setting all the configuration settings, now it&#39;s time to compile the source code.</p><pre>make</pre><p>make command is used to compile the C++ source code and create executable programs. When you run <em>make, </em>it reads the instruction present in the Makefile present in Bitcoin Core source code and performs the necessary compilation.</p><blockquote>Note: do not forget to ./configure before running make</blockquote><p>Once compiling is complete you are ready with the executable source code files necessary to do fuzzing!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F17780469&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Flets-do-it-lets-go-adam-sandler-hyped-up-gif-17780469&amp;image=https%3A%2F%2Fmedia.tenor.com%2FPe8ssGUqMwoAAAAC%2Flets-do-it-lets-go.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6e1e92531153dca7d4808dfe4888ab0/href">https://medium.com/media/d6e1e92531153dca7d4808dfe4888ab0/href</a></iframe><p>As I already mentioned earlier, we are going to fuzz the <em>Banman.cpp </em>class.</p><p><a href="https://github.com/bitcoin/bitcoin/blob/master/src/test/fuzz/banman.cpp"><em>src/test/fuzz/banman.cpp</em></a> is the fuzz harness file for the Banman class. Running the following command will fuzz this class using the libFuzzer:</p><pre>FUZZ=banman src/test/fuzz/fuzz</pre><p>If your Fuzzing was successful, you will see something like this in your terminal.</p><blockquote>Note: The fuzzing is intended to continue indefinitely until it finds an error, resulting in a system crash. As a result, it is recommended that you quit it after a certain period of time, depending on your needs.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WPMSmMOXSLDarqJlVMFtVA.png" /></figure><p>Here’s a little description of what these terms in the image mean:</p><ol><li>NEW: this indicates that the fuzzing process has found a new (previously unseen) input that has led to the discovery of a new code path.</li><li>REDUCE: This is when libFuzzer tries to simplify complex inputs by removing unnecessary data and simplifying the structure while preserving the ability to trigger the same error. It helps in analyzing and debugging by focusing on the essential elements of the input.</li></ol><p>In case of libFuzzer encounters a <em>bad input</em>, the fuzzing process halts and it reports the type of error encountered. It generates <em>Crash files</em> that contain detailed information about the crash, such as the input that triggered it, the stack trace, and other relevant diagnostic data.</p><p>This is pretty much what Fuzzing is and how it is implemented in Bitcoin Core using libFuzzing. I really hope this is easy to understand. I’m also open to all feedback and would be happy to modify the blog if any errors are found.</p><p>Thanks!</p><h4>Author</h4><p>Ayush Singh. I’m a Summer of Bitcoin’23 intern working towards increasing fuzz coverage over the wallet codebase in Bitcoin Core.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=93cd078ce3a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>