<?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 d0nut on Medium]]></title>
        <description><![CDATA[Stories by d0nut on Medium]]></description>
        <link>https://medium.com/@d0nut?source=rss-3e0d2d8b6702------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*8S6IeiTBKa4pZdTlrUsAtA.jpeg</url>
            <title>Stories by d0nut on Medium</title>
            <link>https://medium.com/@d0nut?source=rss-3e0d2d8b6702------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 06:56:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@d0nut/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[Eliminating Authorization Vulnerabilities with Dacquiri]]></title>
            <link>https://d0nut.medium.com/eliminating-authorization-vulnerabilities-with-dacquiri-882b38146f36?source=rss-3e0d2d8b6702------2</link>
            <guid isPermaLink="false">https://medium.com/p/882b38146f36</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[appsec]]></category>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[infosec]]></category>
            <dc:creator><![CDATA[d0nut]]></dc:creator>
            <pubDate>Sat, 29 Jan 2022 09:52:24 GMT</pubDate>
            <atom:updated>2022-01-29T09:52:24.809Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jQK_NAK8z2SxSHTDLOWYQg.jpeg" /></figure><p>Over the last year I’ve taken a step away from my usual bug bounty work to focus more on building <a href="https://resync.gg/">resync</a> — my continuous reconnaissance platform. As part of that work, I’ve built, and made public, a <a href="https://github.com/resyncgg/armada">high performance TCP SYN scanner named Armada</a> and a unique <a href="https://github.com/resyncgg/dacquiri">authorization framework named Dacquiri</a>.</p><p>Both Armada and Dacquiri were made to address problems I encountered while developing resync. With Armada, it was that I was tired of shelling out to <a href="https://github.com/nmap/nmap">nmap</a> or <a href="https://github.com/robertdavidgraham/masscan">masscan</a> and parsing String output from stdout. I wanted a high performance TCP port scanner written <em>as a library</em> so it was easy for Rust applications to integrate with. Port scanner libraries <a href="https://crates.io/crates/async-port-scanner">existed</a> for Rust beforehand, but none were remotely designed to work on any appreciable scale.</p><p>So that’s Armada, but what is Dacquiri?</p><h3>What is Dacquiri</h3><p>Resync has become a relatively intricate project at this point. As I’ve been building out the core web services, which allow users to interact with their resync instances, I’ve found myself narrowly avoiding authorization vulnerabilities in the flurry of development.</p><p>The process of checking user rights with if statements and SQL queries everywhere felt archaic and was clearly error prone. After some inspiration from <a href="https://owasp.org/www-chapter-boulder/zz_presentations_2021_05.pdf">a talk by members of r2c</a>, I decided to solve this problem by building Dacquiri. So what does Dacquiri do?</p><p><em>Dacquiri turns authorization vulnerabilities into compile-time errors.</em></p><p>It might sound absurd but, with proper application, Dacquiri is the ultimate security code reviewer. By gating privileged actions in your application behind Dacquiri’s <strong>entitlement</strong> system, it will ensure that every single codepath that interacts with the protected function has performed the required authorization checks ahead of time.</p><p>Dacquiri is broken down into two main components: <strong>attributes </strong>and <strong>entitlements.</strong></p><h4>Attributes</h4><p><em>Attributes</em> are true statements about a <em>subject</em> (e.g. a User). For example, it’s common in applications to have an enabled or disabled state for users, so a IsEnabled attribute would make sense for many applications. Another example of a common, useful attribute might be IsMemberOfTeam which would attest that a user is a member of a team.</p><p>What’s powerful about attributes is that they can optionally depend on <em>resources</em>, like the aforementioned IsMemberOfTeam attribute. These <em>resources</em> are tracked so you can always retrieve the specific <em>resource</em> that a <em>subject’s attribute</em> was checked against. In the case of an IsMemberOfTeam attribute, the tracked <em>resource</em> would be the Team object. This is a powerful defense against <a href="https://portswigger.net/web-security/access-control/idor">IDORs</a>.</p><h4>Entitlements</h4><p><em>Entitlements</em> are where you define your authorization model. With entitlements, you define what combination of <em>attributes </em>(e.g. IsEnabled) are required to use privileged functionality in your application.</p><p>For example, a bank may want to restrict who can perform the withdraw and deposit actions differently to support features like <em>sending money</em> or <em>account managers</em>. We could require that a user’s account must be <em>enabled</em> to perform a deposit, but the user must <em>also</em> be authenticated if they wanted to perform a withdraw.</p><p><em>Entitlements </em>make it easy to identify what <em>attributes </em>are required to access your privileged functionality. In typical applications, your access control model may be defined by the application of various control-flow statements (e.g. if , break, return ) throughout your call-graph. With Dacquiri, your access control-model is presented clearly and succinctly to your developers enabling easy audits and a simple developer workflow.</p><h3>Building a Bank</h3><p>To explore how Dacquiri can help us secure our applications, let’s build a <em>send money</em> feature for a fictional bank. For this feature we want to allow enabled users to send and receive money with each other. They’ll submit a request to an API endpoint with a session in a cookie, an amount they want to send, and an email address of the user they want to send their money to.</p><p>We’ll start by defining a User with withdraw and deposit methods.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db14758e6a6fd9921a6515ead7aef3cf/href">https://medium.com/media/db14758e6a6fd9921a6515ead7aef3cf/href</a></iframe><p>Now let’s build an API endpoint for our users to call. This is what it might look like if we didn’t use Dacquiri.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/570fb77b17d5d3a030a1776b14b1badc/href">https://medium.com/media/570fb77b17d5d3a030a1776b14b1badc/href</a></iframe><p>We have two primary functions. One of them receives the requests from the web as a handler and its primary job is to take information from the web request and convert it into types and information we can use later to service the request.</p><p>The second function takes two User objects — a <em>sender</em> and a <em>recipient</em> and transfers funds between the two.</p><p>Despite how simple this code is, we already have introduced a vulnerability! Recall that our bank application is supposed to only allow the transfer of funds for <strong><em>enabled</em></strong> users. Unfortunately, the above code doesn’t actually check the <em>enabled </em>state of the referenced users which means that this endpoint allows users that aren’t enabled to send or receive money. Not good!</p><p>Let’s begin integrating Dacquiri by defining two attributes IsEnabled and IsAuthenticated — the attributes we’ll build our authorization model against.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed634b7c19aae566169249ab2ea44464/href">https://medium.com/media/ed634b7c19aae566169249ab2ea44464/href</a></iframe><p>Additionally, let’s move the withdraw and deposit implementations into their own respective <em>entitlements.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/87296cfb6ae825c3510b8ba9f5cc9d14/href">https://medium.com/media/87296cfb6ae825c3510b8ba9f5cc9d14/href</a></iframe><p>We define <em>entitlements</em> by creating a trait and annotating them with a combination of <em>attributes</em> that we want Dacquiri to require before we can access any of the defined functionality. In this case, a user must be <em>enabled</em> if we wanted to deposit money into their account. On the other hand, a user must be both <em>enabled</em> and <em>authenticated</em> if we wanted to withdraw money.</p><p>Lastly, let’s update the send_money function from earlier to use our new Withdraw and Deposit entitlements.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc59218e0b063095f233c7dda58ad722/href">https://medium.com/media/cc59218e0b063095f233c7dda58ad722/href</a></iframe><p>After updating the <em>sender </em>and <em>recipient </em>function arguments to use our newly defined <em>entitlements</em>, it introduces compiler errors in response to our vulnerability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*w2VR_Ta-zJxky0oJE5ej9Q.png" /><figcaption>Dacquiri catching our authorization vulnerability</figcaption></figure><p>To make Dacquiri happy, we’ll need to prove to it that we’ve checked that the sender account is both <em>enabled</em> and <em>authenticated</em> using Dacquiri’s try_grant and try_grant_with_resource methods.</p><p>try_grant is a method that Dacquiri defines allowing us to test if a <em>subject </em>has a particular <em>attribute</em>. Dacquiri will run the function we previously defined alongside our <em>attribute</em> and return a type that attests to the compiler that our <em>subject</em> has a particular <em>attribute</em> and any <em>entitlements</em> that these <em>attributes </em>may qualify for. try_grant_with_resources is similar to try_grant but it also allows us to pass in a resource (<em>e.g. like a </em>Team<em> ,</em>Session<em> , or even another </em>User).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e3d17347b9975ba139eddf8d36cad86/href">https://medium.com/media/1e3d17347b9975ba139eddf8d36cad86/href</a></iframe><p>We’re still left with compiler errors, but we’re making progress here. We’ve successfully proved to Dacquiri that our sender must be <em>authenticated</em> and must be <em>enabled</em>. If they aren’t, our handler will return early (<em>signified with the </em>?<em> at the end of both of the function calls</em>).</p><p>While we’ve handled the case that the caller isn’t <em>authenticated</em> or <em>enabled</em>, we haven’t checked that the account we’re sending money to is <em>enabled</em>. In this state, if Dacquiri wasn’t helping us, we’d still be able to send money to disabled accounts (<em>which our bank definitely doesn’t want</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*R1zDYbrOgikPc0Y5QZ-TZA.png" /><figcaption>Dacquiri stopping us from letting users not in the enabled state from receiving money.</figcaption></figure><p>We need to add in a check that enforces that the recipient account is <em>enabled</em> (<em>which is required by the</em> Deposit <em>entitlement</em>).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/be16228366c839d664df0aeef80e33c0/href">https://medium.com/media/be16228366c839d664df0aeef80e33c0/href</a></iframe><p>Now that we have all of the required checks in place, our code is able to compile 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*pn45ASUxXmcDUkGc0WCOJg.png" /></figure><h3>Dacquiri Going Forward</h3><p>Dacquiri is a powerful framework for teasing out authorization vulnerabilities in Rust applications, and preventing them from being introduced in the future. I <em>do </em>think there’s a bigger message here about leveraging type systems to help write more secure code — there’s ample opportunity to identify and eradicate classes of vulnerabilities using approaches enabled by more advanced type systems. This gives me hope that Rust will be taken as a serious language for secure code beyond the protections it offers for memory safety and concurrency.</p><p>In the meantime, I’ll be integrating Dacquiri into resync further to help ensure that resync is as secure as possible. <a href="https://en.wikipedia.org/wiki/Eating_your_own_dog_food">Dogfooding</a> Dacquiri has helped fuel the development of new features like async support, contexts (<em>e.g. database connections for attribute decisions</em>), and the ability to access an <em>attribute’s</em> associated <em>resources (preventing many common cases of IDOR</em>).</p><p>My hope for Dacquiri is that you walk away with a novel idea on how to solve some of the security problems you face in your day-to-day by building secure-by-default frameworks and leveraging the type system in your language. If you’re using Rust or are just curious about Dacquiri, give it a look over at the Github repository below.</p><p>Thank you!</p><p><a href="https://github.com/resyncgg/dacquiri">GitHub - resyncgg/dacquiri: A strong, compile-time enforced authorization framework for rust applications.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=882b38146f36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Year in Review — 2020]]></title>
            <link>https://d0nut.medium.com/my-year-in-review-2020-a83ac95cc302?source=rss-3e0d2d8b6702------2</link>
            <guid isPermaLink="false">https://medium.com/p/a83ac95cc302</guid>
            <dc:creator><![CDATA[d0nut]]></dc:creator>
            <pubDate>Tue, 05 Jan 2021 15:23:40 GMT</pubDate>
            <atom:updated>2021-01-05T15:23:40.437Z</atom:updated>
            <content:encoded><![CDATA[<h3>My Year in Review — 2020</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XdZoaB4joiBiceRL.jpg" /></figure><h3>A Star is Born</h3><p>As we collectively (and emphatically) usher in 2021, I can’t help but look back on 2020 in an effort to try and make sense of it all.</p><h3></h3><p>I&#39;m not normally one who does New Year&#39;s resolutions but I&#39;ve been seriously considering what do I want 2020 to look like for myself. I&#39;ve got some pretty serious goals that I want to accomplish and I&#39;m looking to really tighten up my life in a number of areas.This is my year.</p><p>2020, for me, was the year I was going to become the best version of myself. Just a few months prior to the start of our plague-ridden roller-coaster ride, I began a new position as a Senior Security Engineer on <a href="https://twitter.com/Cruise">Cruise’s</a> Red Team. I was beyond excited to get an opportunity to branch out from my previously held AppSec role at Dropbox and explore an aspect of my growing interest in offensive security work. Having had a strong start in 2020 by winning the Nova competition for CanSecWest, I felt as if I was on a rocketing trajectory in my personal growth and career.</p><h3></h3><p>I&#39;m super honored to have been selected for the Nova Speaker competition :) https://t.co/nXG70FGa4u</p><p>By this time, the world was already coming to realize that 2020 wasn’t going to be the “Roarin’ Twenties” reboot we had hoped it would be. Well into month, Australia had suffered one of the most devastating bush-fires (<em>50x larger than California’s largest-ever wildfire</em>) and affected <a href="https://www.bbc.com/news/50986293">an estimated 480,000,000 animals</a>. Additionally, the world was looking at a potential World War 3 (<em>though, thankfully, the situation between the United States and Iran simmered down to a less frightening level within a week or so</em>).</p><p>However, despite all this bad, more was to come. It was international news by now that a new virus was discovered in Wuhan, China that was rapidly spreading within the region. By the end of January, the virus had successfully emigrated to regions outside of China (<em>including the United States</em>) and the prospect of a wide-scale pandemic was beginning to take hold.</p><p>My partner and I decided to prepare for a worst-case scenario by the middle of February when it was clear to both of us that the rate of transmission and spread of the virus could lead to lockdown scenarios within the United States, similar to what we had been seeing elsewhere in the world. Much like everyone else at this time, it was unclear what the long-term effects this new disease could have and we wanted to take precautions to avoid finding out first-hand. We stocked up on food, a few cleaning items, over the next couple of weeks before the panic shopping would begin.</p><p><em>Also,</em> <strong><em>no</em></strong><em>:</em> <em>we did </em><strong><em>not</em></strong><em> purchase toilet paper — we had a bulk order from a previous 2019 Costco shopping trip that was still going strong.</em></p><h4>Masks Before they were Cool</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*tzMPEfjGA2EGaA90T6zvRA.png" /><figcaption>If you’ve never watching The Phantom of the Opera, you really should! Webber is a genius!</figcaption></figure><p>Fun story from around this time: my partner had finally convinced me to start wearing a mask when going out. I remember the first time I got into an Uber with a mask on and the driver was so worried that I had the virus. (<em>At this time, there were no mandates to wear a mask and the public messaging on whether or not they were helpful was dangerously inconsistent</em>). I had to repeatedly convince my driver that I was not sick and that the mask was to mitigate the chance of breathing it in myself.</p><p>I wonder if they think about that interaction at all.</p><h3>SuperNova</h3><p>Anyway, back to CanSecWest.</p><p>I felt reasonably prepared to present the work I did on identify a strategy to exploit some usages of insecure randomness in the V8 JavaScript engine. My slides were mostly done, my demo was fairly fleshed out, and at this point it would just be down to repetition and polish. I had confidence that my talk was going to go over well and I was still beaming that I would actually get to present at this prestigious conference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8D7fCl21KzPo6EN4" /><figcaption>A photo from my time on Kauai, Hawaii around November, 2019</figcaption></figure><p>Having never been to Canada before (<em>aside from a brief 3-hour stay in Windsor for a show</em>), I was eager to meet up with a friend of mine. We made plans that after the conference, I would take a short domestic flight to visit them before returning to the States. 2020, despite its rough start, was looking like a continuation of the awesome luck, travel, and experiences I had in 2019.</p><p>Sadly, as Covid progressed throughout the United States and fear still running high, I had decided that the responsible move would be to cancel my in-person trip to CanSecWest to avoid spreading (or catching) the illness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U7ul0Ph_aWNQXG_EUkHitg.png" /><figcaption>Canceling my free trip to Vancouver, Canada :(</figcaption></figure><p>While terribly disappointed, I still had drive left in me to do well for myself and continue onward. At this time, I believed that we’d roll out strong enough lockdowns to quell the spread of Covid-19 and that we’d possibly be back to a version of “normal” by fall.</p><h3>Location, Location, Location</h3><p>What is life if not a journey of self discovery?</p><p>2019 was the year that I discovered that my productivity was heavily influenced by the environment I put myself in. This might sound obvious to you (<em>or me, now</em>), but I didn’t <em>understand</em> what this truly meant until I spent some time reflecting on how I had such a productive streak when I first joined Cruise.</p><p>I realized that the environment that I created for myself there (<em>mostly professional, not logged into distractions, sitting near / around others working on similar stuff</em>) provided ample motivation and direction to guide my effort on productive, useful work. Despite my team having a well-established culture of remote work, I actively made the decision to come into the office every day and be the best employee I could be. I was so happy I had found my groove; I felt like I could take on almost any task if necessary.</p><p>Of course, the pandemic changed all of that. At some point around March, Cruise had issued orders for everyone to work from home. Even before that, while many of my coworkers were optionally choosing to work from home, I still was walking into the (<em>nearly empty</em>) office to try and stay focused. My last bastion of hope for 2020 was taken from me when I watched the all-hands informing us that we were no longer allowed in the office.</p><p>The transition to working from home was horrific for me. Now in a mental slump, working from home felt like a monumental task. It took great effort for me to focus enough on reading even a single document, let alone doing anything useful for my job. Over the next couple of months, the combination of waning mental state, guilt over my sudden plummet in productivity, and a desire to find work that I found genuinely interesting started me on a path that I already knew was going to lead me to finding employment elsewhere.</p><h3>BLM</h3><p>March 25, 2020 — George Floyd, a man reduced to begging for his life, is killed by a group of police officers attempting to arrest him allegedly using a counterfeit $20 bill.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/0*41j5LM7U5Uyvxf52" /><figcaption>An interpretation of “Defund the Police” — Police still keep the peace, but we redirect much of the funds that made up their budgets to services and policies better targeted at solving the vast swath of problems we previously used the Police for. The police are the hammer; let’s stop seeing all problems as nails.</figcaption></figure><p>This event, as you all may know now, sparked another conversation about the brutality of policing and the justice system against black Americans. In fact, as protests began across the United States demanding a reform, we saw undue brutality and authoritarian practices from many police forces around the country.</p><p>For a whole week, I spent so much of my time watching these protests; being angry at the vicious and oppressive policing unfolding all across the nation. This was the first time I could ever remember being restricted by curfew from someone other than my parents. While this will forever be a scar on our nation’s history, we did see some small reforms like the repeal of Qualified Immunity from some small regions of the US and putting the discussion of Defunding the Police into the public discourse.</p><h3>Discord Downfall</h3><p>Fast forward a little while and we arrive to around July or so. By this time, tens of thousands have been infected with Covid-19 in the United States and it’s becoming pretty clear that Covid-19 is going to stay for the entirety of the year. Occasional protests are still going on but the focus on them in the media has fallen drastically.</p><p>Meanwhile, in this lull of 2020, I tried distracting myself with anything and everything. From drinking a fair bit more, spending more time on discord talking with hackers, and trying to moderate some discords, I found myself getting burned out from the stress of my job (the lack of focus, guilt, etc.) and the perpetual desire to be productive again.</p><p>I let myself get more and more frustrated with otherwise trivial things like questions that didn’t provide enough detail, posting behaviors that didn’t appear to be in good faith, and drama (<em>occasionally, quite weird</em>). As an example of the trivialities that I mulled over, here’s a tweet where I complained about a type of interaction I had become accustomed too.</p><h3></h3><p>General rule for newer bug hunters: If you find a potential issue, are unsure if you should report it, ask more experienced hackers if you should and they say no, you probably should listen to them.Yoloing bug reports tanks your signal, rep, impact and your chances for invites.</p><p>At some point I decided to pull away from actively moderating these groups and even left a number of them. I don’t exactly understand why I get like this when I invest so heavily in a group, but it’s not the first time I left a group or community in frustration. Definitely an area of growth for me in the future.</p><p>Regardless, for those curious, I still do respond to mentions and DMs when those are open. Feel free to reach out with questions as I still happily answer them!</p><h3>Grapl</h3><p>As alluded to before, the sudden shift in working environment, lack of interest in my work, an unexpected round of layoffs that heavily affected my team, and the culmination of stressors from 2020 pushed me over the edge. I was desperate to find something that I could believe in (that also paid the bills).</p><p>Thankfully that day finally came when I was given the opportunity to join <a href="https://twitter.com/GraplSec">Grapl</a>: a company a friend started that not only solves the problem of SIEMs in a novel way, but the product is predominantly built using Rust, my favorite programming language.</p><h3></h3><p>Sadly today will be my last day at @Cruise . Despite learning so much about the offsec role, having plenty of good times, and working with smart people I&#39;ve decided to move on to a more engineering focused role at @GraplSec !</p><p>Grapl has a special place in my heart as it’s a project that I have believed in since the first time I heard about it back when it was just a side-project. I’m so happy that I found a place that I genuinely feel like the work I’m doing matters, is valuable to society, and will succeed with gusto.</p><p>Since joining Grapl, I’ve had some of the following contributions:</p><ul><li>Refactoring major services to significantly improve code organization and structure</li><li>Identifying and fixing dozens of bugs in the core product</li><li>Finding and fixing vulnerabilities</li><li>Building out high-demand features in Grapl</li><li>Identifying and fixing a significant performance bottleneck that was previously classified as a blocker</li></ul><p>All-the-while, I get to work with people that I enjoy and respect. I’m truly lucky that I get to work where I do, even if the startup life isn’t everything it’s cracked up to be.</p><p>Something fun to point out, though: my new job is entirely remote, yet I find myself much more able to focus despite working from home. It goes to show how important enthusiasm for your job is in productivity as well, I guess.</p><h3>California Fires</h3><p>If 2020 wasn’t bad enough, California decided to remind the world that Climate Change is still a very real thing.</p><p>It’s not atypical for California to have <a href="https://en.wikipedia.org/wiki/2020_Western_United_States_wildfire_season">seasonal wildfires</a>. I remember in the first month I moved to San Francisco, waking up to the heavy smell of smoke in the air and an incredibly dry throat. However, in the years I’ve lived here, I’ve never experienced anything as bad as the fires were this year.</p><p>The air quality index, for days at a time, would be well over 200. In previous years, when the air got bad, it was mostly a permanent bonfire smell (<em>something similar to hanging out around a campfire with your friends</em>). This year, the air was putrid and smelled of burning rubber and plastics. Thick with toxins, and not at all pleasant to the nose, we were forced to keep our windows and doors shut constantly.</p><p>Of course, 2020 wasn’t quite done with California yet, as an intense heatwave sweeped the state. San Franciscan homes, for those unfamiliar, often do not have centralized cooling. This is because, nine or so months of the year, SF’s weather is very temperate and does not require further regulation to be enjoyable. Now, though, we were faced with sweltering heat and unbreathable air; forced to make a decision between opening the windows to get 5–10 degrees of relief (2–5 degrees Celsius) and breathing toxic air, or close the doors to preserve our clean air but die in the heat.</p><p>After a couple of weeks of on-and-off heat waves and smoky conditions, we approached the end of this literal hellscape. This experience, though, remains in my memory as it was a first-hand encounter with the post-climate change world we’re entering into.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*o-hFqdxFILtsgOnL" /><figcaption>San Francisco during the middle of the day with a thick layer of smoke high in the atmosphere, changing the color of the world below orange.</figcaption></figure><h3>Distractions</h3><p>While many of my peers were using this time for self-improvement, I was clearly struggling. For whatever reason, the only thing that remotely interested me (<em>in my free time</em>) was playing games and chatting with people. This is not terribly abnormal for me. I often have said I tend to go through cycles of extreme productivity (which, thankfully, I’m on right now), and stretches of relaxation and entertainment.</p><p>Notably, this stretch of self-indulgence had lasted longer than is typical. Usually these periods of distraction last 2–3 months, but since March, I had been unable to focus on hacking, working on side-projects, or even writing blog posts. This can be seen though the lack of updates posted to this blog for the entirety of 2020 (<em>having last posted </em><a href="https://medium.com/d0nut-reads/week-3-real-talk-on-real-number-systems-57bc30011312"><em>about reading a book</em></a><em> in June</em>).</p><p>After the toughness of this year, I’ve decided to not be too hard on myself.</p><p>2020 has been heartbreaking, polarizing, frustrating, isolating, demoralizing, unrelenting, and deadly. In this mindset, I probably let my break from “productive pursuits” last longer than is typical, but by the end of December I regained my productive desires. I’ve since started back up on a side-project that I’ve had incredible success with so far, been reading again, and am writing this blog post for all of you today.</p><h3>My Interpretation of 2020</h3><p>We’re not out of the woods quite yet.</p><p>With all of the discussion regarding 2020 as the worst year ever (<a href="https://en.wikipedia.org/wiki/536"><em>which it’s probably not</em></a>), I suspect many of us confine this series of bad luck and horrible events to the year. In my opinion, this is a mistake. Nothing about the year restricts horrific events, polarization, effects of climate change, and an uncertain landscape for the future of the US to come to an end on New Years.</p><p>There is work to be done and progress to be made with our environment, our politics, and within ourselves. If we brush off this last year as “2020 sucks”, we fail to recognize that the year was a messenger from the future giving us its message that we need to act now or our future will look similar and worse.</p><p>I fear, based on our response to the global challenges handed down to us, that we will fail future challenges as well. The Spanish Flu was much more deadly than Covid-19, yet an anti-mask sentiment was present even then. Our wildfires scorched two continents, and our politicians fail to act.</p><p>On Climate Change: we still treat it as something one can <em>choose </em>to believe in or not. We need to teach people that Climate Change is a well proven, solidly understood phenomenon like Gravity or Photosynthesis — it’s not a question of belief, it’s a question of your understanding of it. Even if some countries and administrations do understand it, they promise too little and deliver too late.</p><p>Our future does not look bright, from my perspective.</p><h3>Lastly</h3><p>Enough doom and gloom for one blog post.</p><p>What am I doing now? Well, as mentioned before, I’m working on my side-project (<em>that I’ve only mentioned at least a couple dozen times by now in vague detail</em>). As some of you may know, I’ve also taken a hiatus from my stream on <a href="https://www.twitch.tv/d0nutptr">Twitch</a> which is partly due to that streak of just wanting to play games and chat with people. That being said, I’ll be <a href="https://www.twitch.tv/d0nutptr">returning to Twitch</a> later this month to show off my side-project, illicit feedback, and continue to improve it with all of you.</p><p>In terms of bug bounty work, I’ll be making it a soft goal to get back into bug bounties again, though I don’t want to promise any commitments. I don’t have a strong desire to spend my time hacking alone these days and I haven’t felt interested enough in collaborating with my friends either.</p><p>Lastly, I’ll be returning to reading the book <strong>The Road to Reality</strong> and posting updates on my “<a href="https://medium.com/d0nut-reads">D0nut Reads</a>” publication. In fact, I’ll be posting a review soon of another book I’ve been reading called <strong>Something Deeply Hidden</strong> by Sean Carroll sometime today or tomorrow.</p><p>Have a good 2021, everyone. Let’s actively make this year better than the last one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a83ac95cc302" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Week 3 — Real Talk on Real Number Systems]]></title>
            <link>https://medium.com/d0nut-reads/week-3-real-talk-on-real-number-systems-57bc30011312?source=rss-3e0d2d8b6702------2</link>
            <guid isPermaLink="false">https://medium.com/p/57bc30011312</guid>
            <category><![CDATA[physics]]></category>
            <category><![CDATA[numbers]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[the-road-to-reality]]></category>
            <dc:creator><![CDATA[d0nut]]></dc:creator>
            <pubDate>Wed, 10 Jun 2020 08:11:10 GMT</pubDate>
            <atom:updated>2020-06-10T08:13:39.768Z</atom:updated>
            <content:encoded><![CDATA[<h3>Week 3: Real Talk on Real Numbers</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uC8xhiVMc1jmRd64.jpg" /><figcaption>A really fancy paint by numbers.. err, maybe it was a safari for finding different kinds of numbers?</figcaption></figure><p>In continuation of the philosophical and foundational nature of the book thus far, Chapter 3 opens with a discussion on kinds of numbers, our reliance on the appearance of <em>some</em> of them in nature and how that fueled their original derivation, and how we can rederive them without ties to our <em>subjective, messy </em>world experience.</p><p>The chapter begins with a demonstration of a powerful proof of contradiction demonstrating the existence of <strong>irrational numbers</strong>. Firstly, the proof (and original inspiration: Pythagorean Theorem) relies on <strong>whole numbers</strong> and <strong>rational numbers</strong> existing (rational numbers being ratios of whole numbers). Assuming that’s agreed upon, we can get on with the proof.</p><p>Assume we have a triangle with sides length 1 and, by the Pythagorean Theorem, a diagonal with a squared length of 2. We’ll then assume that the square root of 2 can be represented by a rational number (a ratio of whole numbers).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/0*fcYx1Vx20OP4YCfr.png" /></figure><p>We then rearrange the above to put a on one side and b on the other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/0*uCJeNg4P-BzPcOEl.png" /></figure><p>We know that since 2 is a factor on the right hand side that a^2 must be an even number that is divisible by 2^2 and therefore a is divisible by 2. We’ll now introduce a new number c that must also be a whole number that is the other factor of a when divided by 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/0*yJyuR80tC6226SLu.png" /></figure><p>Reducing this down we’ll see that we’re right back where we started but with c instead of a .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/0*05LwFvQbQ1bRjcrM.png" /></figure><p>This pattern clearly continues on ad infinitum; eventually we would be unable to divide these whole numbers any further, demonstrating that the square root of 2 must not be rational.</p><h3>Keeping it Natural</h3><p>The chapter continues to try to confront the discussion on validity and practicality of various kinds of numbers. Clearly, in tasks such as counting sheep, <strong>natural numbers</strong>, whole values starting with 1 and increasing, are pretty clear participants in the natural world. That being said, the set of i<strong>ntegers,</strong> whole numbers including their negative counterparts such as -1, -2, -3, …,<strong> </strong>is an interesting topic since you may believe they occur often in the natural world; however, as <strong>scalar values </strong>(representations of magnitude irrespective of direction)<strong> </strong>they do not.</p><p>It was believed for a period of time that integers, as scalar values, did not appear. It was first when we began work with Quantum Mechanics did we discover that the charge of an electron and the charge of the proton were exactly opposite of each other irrespective of time, angle, position, etc.</p><p>These values are known as <strong><em>additive quantum numbers</em></strong> which are values that both describe particles and are only added together (with sign included). It’s interesting that unlike scalars at the macroscopic scale which operate on natural or whole numbers, additive quantum numbers operate in the realm of integers.</p><h3>Conclusion</h3><p>Compared to the last chapter, this felt like a fun break. I enjoyed rounding out my knowledge on the kinds of numbers there are as, admittedly, I struggled to recall the difference between <em>real </em>and<em> natural</em> numbers. It was strange trying to understand where the usefulness of this lesson would come in except to perhaps cover <em>proofs by contradiction</em>, but the note on <em>additive quantum numbers</em> helped drive home the importance of understanding what kinds of numbers a phenomenon could accurately be described by.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57bc30011312" width="1" height="1" alt=""><hr><p><a href="https://medium.com/d0nut-reads/week-3-real-talk-on-real-number-systems-57bc30011312">Week 3 — Real Talk on Real Number Systems</a> was originally published in <a href="https://medium.com/d0nut-reads">d0nut reads</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Week 2]]></title>
            <link>https://medium.com/d0nut-reads/week-2-44c0096a82b2?source=rss-3e0d2d8b6702------2</link>
            <guid isPermaLink="false">https://medium.com/p/44c0096a82b2</guid>
            <dc:creator><![CDATA[d0nut]]></dc:creator>
            <pubDate>Wed, 10 Jun 2020 07:23:55 GMT</pubDate>
            <atom:updated>2020-06-10T07:23:55.814Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/739/0*GVmv-XLIBQxoeqMl.png" /></figure><p>This week wasn’t about me.</p><p>I and millions of others were focused on the murder of George Floyd.</p><p>Black Lives Matter.</p><p>My progress will resume in the next update.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44c0096a82b2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/d0nut-reads/week-2-44c0096a82b2">Week 2</a> was originally published in <a href="https://medium.com/d0nut-reads">d0nut reads</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Week 1: The Road to Reality]]></title>
            <link>https://medium.com/d0nut-reads/week-1-the-road-to-reality-6b09e5d18a25?source=rss-3e0d2d8b6702------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b09e5d18a25</guid>
            <category><![CDATA[physics]]></category>
            <category><![CDATA[reading]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[d0nut]]></dc:creator>
            <pubDate>Wed, 27 May 2020 04:47:52 GMT</pubDate>
            <atom:updated>2020-05-27T05:01:31.334Z</atom:updated>
            <content:encoded><![CDATA[<p>I love watching educational Youtube channels. It’s a great way to constantly keep myself exposed to science and technology. And this is nothing new: I’ve always been engrossed with STEM. Even at a young age, I was <strong>sure </strong>that I would become a scientist or an engineer, destined to discover and build marvelous things. I wanted to understand the distant stars, peer into a black hole, and prove that Einstein-Rosen bridges could be traversed.. one day. Around highschool, my dreams of becoming an Astrophysicist were pushed aside by a (more practical) desire to become an engineer at a major tech company. I had a knack for computers and felt I would be able to more easily achieve success for myself there. However, I couldn’t help but feel some cognitive dissonance at times. I gave up one passion for another, sure, but at the same time I had failed to satisfy all aspects of my nature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wpvGdYtkiOJZsgToqCTH-w.png" /><figcaption>Banner for the SpaceTime Youtube channel</figcaption></figure><p>In the endless pursuit to stay abreast of this kind of knowledge, I had discovered this <a href="https://www.youtube.com/channel/UC7_gcs09iThXybpVgjHZ_7g">incredible Youtube channel</a> created by PBS Digital Studios. My impression at first glance was this channel would be the kind that focuses on widely approachable, boiled down explanations of complex astrophysical topics; however, I was astounded by the thoroughness of the content, accuracy, and the fact that jargon and mathematics were not off-limits for the content. At the same time, they somehow figured out how to capture a less technical audience, as evident by the view count and comments section. What a wonderful project!</p><p>A recent live stream, hosted by Matt O’Dowd (pictured above), recommended a book that was on Matt’s bookshelf called “The Road to Reality” by Roger Penrose. He mentioned that the first 16 chapters were focused on covering the mathematics needed to understand the remaining chapters which covered topics like SpaceTime, Minkowski space, QFT, and String Theory. How daunting! Having just recently finished the channel’s excellent videos on Penrose diagrams and how they’re used to describe the behavior of objects traveling near and through event horizons, I <em>knew</em> I wanted to conquer this book.</p><h3>Why Am I Reading this Book</h3><p>After the book arrived I started asking myself “Why even is the point of me reading this?”. It seems like a silly question, but it’s important that my motivations be honest if I wanted a chance to finish the book (or even make a noticeable dent). I’ve been known to lose motivation for things that don’t capture my attention (hence why I’m trying to track my reading here).</p><p>I think I’ve come to the following conclusion: I want some inner peace.</p><p>I often question “Why am I here?”, “What am I doing?”, “What is the nature of reality?”, “What even is ‘real’?”. Having given up my original dreams of working in science over a decade ago, I think my mind has been craving this knowledge. Just thinking about how wonderful it would be to truly understand the way our reality works. Some of the ideas in physics are so fantastical:</p><ul><li>Our existence may be built on infinitesimal 6 dimensional closed, vibrating strings (<a href="https://www.youtube.com/watch?v=k6TWO-ESC6A">What are the Strings in String Theory?</a>).</li><li>Spinning black holes may contain a singularity “donut” that, upon traveling through one, could take you to brand-new universe (<a href="https://www.youtube.com/watch?v=4v9A9hQUcBQ">Mapping the Multiverse</a>).</li><li>The results of many quantum experiments may actually lead to the conclusion that a near-infinite realities may exist and it’s the divergence of these realities that gives rise to the otherwise pure randomness we see when observing quantum phenomenon (<a href="https://www.youtube.com/watch?v=kTXTPe3wahc">Parallel Worlds Probably Exist. Here’s Why</a>).</li></ul><p>How amazing.</p><p>While I may achieve this “inner-peace” by learning more about philosophy (and maybe getting some therapy), it feels, now self-evident, that I am reading this book to stay truer to myself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*sw4CLbATz9hp46tQ.jpg" /></figure><p>Also: <strong>science is rad</strong>.</p><h3>Week 1</h3><p>In addition to the preface, I’ve read chapters 1 and 2 this past week. The first chapter was more a discussion on the value of an objective, separate reality in which mathematical structures exist in (to not misconstrue pure mathematical ideas not aligning perfectly with our less simple reality). It was very philosophically focused and really brought out some interesting historical ideas around the idea of an objective truth in numbers (with many callbacks to <a href="https://plato.stanford.edu/entries/platonism-mathematics/">Platonism</a>). In all honesty, one could skip this chapter and probably not lose much detail other than the introduction to Pythagoras and the Pythagoreans.</p><p>Chapter 2 is when the mathematics started to really be introduced. The chapter starts off with a simple introduction to the five postulates of Euclidean geometry:</p><ol><li>A straight line segment may be drawn from any given point to any other.</li><li>A straight line may be extended to any finite length.</li><li>A circle may be described with any given point as its center and any distance as its radius.</li><li>All right angles are congruent.</li><li>If a straight line intersects two other straight lines, and so makes the two interior angles on one side of it together less than two right angles, then the other straight lines will meet at a point if extended far enough on the side on which the angles are less than two right angles.</li></ol><p>The book then showed light on the fifth postulate as being particularly.. problematic. Many mathematicians felt it could be proven merely as a combination of the original four postulates. In fact, one mathematician, <a href="https://en.wikipedia.org/wiki/Giovanni_Girolamo_Saccheri">Giovanni Girolamo Saccheri</a>, spent a significant amount of their time working on this problem. Near the end of their tenure on this problem, they concluded that it may not be possible to specifically prove this postulate from the first four.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TDOyyolgC_AEw9oy.png" /><figcaption>A triangle, with angles that add up to less than 180 deg in a hyperbolic geometry.</figcaption></figure><p>This was actually an amazing revelation as it suggested the first non-euclidean geometry: <strong>hyperbolic geometry</strong>. Hyperbolic geometry, unlike euclidean geometry, exists on a surface that is negatively curved; warped into a saddle shape. In fact, <a href="https://en.wikipedia.org/wiki/Hyperbolic_geometry">hyberbolic geometry has its own parallel postulate</a> which is opposite of the euclidean one. Instead of exactly one parallel line passing through at point <em>P</em> not on line <em>l, </em>the <em>hyperbolic parallel postulate</em> calls for at least 2 distinct parallel lines passing through a similar construction. The chapter also briefly touched on elliptic geometry (positive curvature) but little detail was presented on this topic.</p><h3>Takeaway</h3><p>This book is intimidating. It’s clear that even at its massive 1,000+ page size, each page is incredibly chock-full of information; Penrose pulled no punches. I’m starting to treat each page as a guidebook on topics to read up on and push myself to understand. For example, I didn’t readily understand how combining two reflections in Euclidean geometry can result in a rotation about a defined point. After reading up on the topic a bit, I felt that I had a better grasp on some of the important pieces (which is good for me to hear.. as Geometry was one of my weakest math disciplines).</p><p>I do have some concerns after taking a second look at the Table of Contents again.. as I’ve said over and over: this book is daunting. I’m just hoping to vaguely understand topics at the higher levels of mathematics and physics when I get to them. This publication will serve as a testament to that outcome, one way or another.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b09e5d18a25" width="1" height="1" alt=""><hr><p><a href="https://medium.com/d0nut-reads/week-1-the-road-to-reality-6b09e5d18a25">Week 1: The Road to Reality</a> was originally published in <a href="https://medium.com/d0nut-reads">d0nut reads</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Piercing the Veal: Short Stories to Read with Friends]]></title>
            <link>https://d0nut.medium.com/piercing-the-veal-short-stories-to-read-with-friends-4aa86d606fc5?source=rss-3e0d2d8b6702------2</link>
            <guid isPermaLink="false">https://medium.com/p/4aa86d606fc5</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ssrf]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[d0nut]]></dc:creator>
            <pubDate>Mon, 27 Apr 2020 07:22:56 GMT</pubDate>
            <atom:updated>2020-04-27T07:22:56.090Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bwlmgn3lrZfTcOd3" /><figcaption>Title respectfully inspired by Alyssa Herrera’s <a href="https://medium.com/bugbountywriteup/piercing-the-veil-server-side-request-forgery-to-niprnet-access-c358fd5e249a">Piercing the Veil SSRF blog post</a></figcaption></figure><p>It’s been over a year and a half since I’ve started my bug bounty journey as a hacker. With years of experience triaging reports and working in security, I’ve seen a plethora of bug types, attack vectors, and exploitation techniques. I’ve had such a healthy diversity in exposure to these different concepts that it’s quite honestly surprising that one particular bug class has captured my imagination so effortlessly and decisively as Server-Side Request Forgery has.</p><p>Today, I want to share my love for SSRF by discussing what it is, why companies care about it, how I approach testing features I suspect may be vulnerable to SSRF, and lastly share a couple of short stories on SSRFs that I’ve found in my time hacking.</p><h3>Modern Web Applications</h3><p>The modern web application consists of a fair bit more than just a couple of <a href="https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/">php</a> files and <a href="https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/">fastcgi</a>. These increasingly complex stacks often consist of dozens upon dozens of services running in a production network, mostly isolated from the public internet. Each of these services, generally responsible for one or a few related tasks or models powering the web application, can be spun up and down to help deal with sudden changes in load. It’s an amazing feat that allows the modern web application to scale to millions and hundreds of millions of users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R9PkyrCFCqYefYNw0oN5lw.png" /><figcaption>An example modern web application architecture</figcaption></figure><p>In this model, attackers and users both start with the same level of privilege (unprivileged network position — left side of above image) which directly affects the exposed attack surface. The only service these actors can directly interact with (or attack) is the nginx instance with public and private IP addresses. It’s also worth pointing out that because the exposed nginx instance uses vHosts, external parties are also able to interact with the www, app, and link services, though not the machines directly. Regardless, attackers are unable to meaningfully control interactions with the IAM, Redis, Widget Service, and two MySQL instances.</p><p>But imagine that this wasn’t true. Imagine, as an attacker, that you were able to talk to any of these services and systems directly. Perhaps, and is often the case, these internal services aren’t secured as well; priority to the security of these systems is yielded to that of the perimeter. It would be a field-day for any attacker.</p><p>At this point, our story could diverge: we could talk about how differences in the interpretation of the HTTP standard between the vhost services and nginx could enable Request Smuggling vulnerabilities. We could also talk about how second-order SQLi can occur from data stored in one service and processed by another. We could even discuss the attacks against internal HTTP requests by injecting query parameter-breaking characters such as # or &amp; to introduce new parameters or to truncate them instead. However, I’d like to discuss how SSRF fits into this picture.</p><h3>What is SSRF?</h3><p>SSRF, or <a href="https://portswigger.net/web-security/ssrf">Server-Side Request Forgery</a>, is a vulnerability where an attacker is able to direct a system <strong><em>in a privileged network position</em></strong> to issue a request to another system <strong><em>with a privileged network position</em></strong>.</p><p>Keep in mind the bold sections: there is definitely a need to support features where an attacker can direct a service <strong><em>in a privileged network position</em></strong> to make a request to a system <em>in an </em><strong><em>unprivileged </em></strong><em>network position</em>. A perfect example of this is a <a href="https://en.wikipedia.org/wiki/Webhook">webhook feature</a> as found on Github or Dropbox. Being able to point a webhook at your burp collaborator instance <em>is </em><strong><em>not </em></strong><em>a vulnerability</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZecGR3tqidxy9o_C27yHQg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DrkC4UU9W8_FnbgUVkfqaA.png" /><figcaption>Impactful SSRF on left; not right</figcaption></figure><p>Of course, there are exceptions to every rule. I use this more strict definition above to help direct the most common instances of SSRF and faux SSRF to their respective determinations: valid or invalid. Case in point: I did once encounter a situation where being able to change the address to an attacker controlled machine without a privileged network position allowed me to read the Authorization header and steal credentials used on an internal api call… so take this with a grain of salt.</p><p>The typical feature or place to find SSRF is where some parameter contains a url or domain as the value. Seeing a POST request like the following</p><pre>POST /fetchPage HTTP/1.1<br>Host: app.example.com<br>...<br>Content-Type: application/x-www-form-urlencoded</pre><pre>url=http%3A%2F%2Ffoobar.com%2fendpoint</pre><p>is a pretty clear sign that this is the kind of feature that <em>may </em>introduce an SSRF vulnerability. There are some other types of features, like HTML to PDF generators, where a headless browser or similar is used in a privileged network position to generate a preview or PDF. If you’re curious about these kinds of attack vectors, go read the <a href="https://twitter.com/nahamsec/status/1161130930339110912">slides that Daeken and Nahamsec</a> put together for DEFCON.</p><p>In fact, <em>anywhere </em>where you may be able to control an address to another system is a place where you should try testing for SSRF. Technically, <em>even a </em>HOST <em>header</em> could be a vulnerable parameter.</p><h3>If It Walks Like a Duck and It Talks Like a Duck..</h3><p>I didn’t originally intend for this blog post to be a “how to test for SSRF” guide (<a href="https://www.hackerone.com/blog-How-To-Server-Side-Request-Forgery-SSRF">there</a> are <a href="https://medium.com/bugbountywriteup/server-side-request-forgery-ssrf-testing-b9dfe57cca35">plenty </a>of <a href="https://affinity-it-security.com/test-server-side-request-forgery/">those</a>), but when I was drawing the outline for the material I felt that I should at least cover some of the behaviors or characteristics that I look for when testing for SSRF.</p><p>I’m generally interested in the following questions:</p><h4>Can I read the response?</h4><p>Am I able to read the response? If not, is there any additional information given to me based on the availability of the receiving system? If the port isn’t open, does an error get returned? If the system doesn’t speak HTTP but is receiving traffic, what happens?</p><p>If I can read the response then proving impact is a breeze: we just need to identify an internal service that responds to whatever protocols we have access to and read a response from it. If we can’t read the response, we might have to come up with interesting side channels like different error messages or see if we can blindly coerce an internal service to issue a request to the internet.</p><h4>Where are we?</h4><p>Is the vulnerable service running on some Infrastructure as a Service (IaaS) platform (like AWS or GCP) or are we on something less sophisticated or more custom? This lets me know if I’m able to reach a metadata service and may clue me in to what kinds of systems may be running in the internal network.</p><h4>Can I redirect?</h4><p>This is pretty straightforward. What are the rules for redirecting? Are they always rejected? Are they always processed? Or is there some nuance in between?</p><p>Redirects are a super common method of bypassing mitigations for SSRF. Occasionally web applications will check if the initial domain resolves to an RFC1918 address and error out if so. These kinds of checks are usually only performed on the initial request and a 302 redirect could be leveraged to tell the client to pivot to the internal network. Beware proxies in front of these internal HTTP clients, though, as they can properly discern if a request should be forwarded to its destination.</p><h4>What protocols does the client support?</h4><p>HTTP/HTTPS only? FTP? Gopher?? Supporting additional protocols (especially Gopher) will increase the level of impact and options for exploitation available to you.</p><p>Remember to think creatively about how you can demonstrate that you’re able to successfully interact with internal systems. This is much easier when you can read the response, of course, but if you’re able to provide that kind of information via a sidechannel like an error when ports are filtered/blocked or if you’re able to get that service to interact with the outside world as a result of your privileged message then you’re going to be more successful in proving the presence of SSRF.</p><p>For inspiration, one of my favorite methods of demonstrating that I have an SSRF is leveraging a localhost smtp services to show that I’m able to trigger the system to send me an email. This is a method that I’ve used twice now in HackerOne SSRF reports.</p><p>Lastly, moving away from HTTP and HTTPS protocols can let you bypass the proxies mentioned earlier. Oftentimes these proxies only handle HTTP or HTTPS traffic, so being able to speak a protocol like Gopher can allow you to bypass the internal proxy all-together.</p><h3>SSRF and Where to Find Them</h3><p>As stated before, SSRF can show up anywhere a system addressable string shows up (IP, domain name, email address, etc). While I <em>could </em>start enumerating every possible features that could become an SSRF (and still miss a ton of possible examples), I think a better way to learn is reading stories about ones others have found and try to extrapolate other similar attack vectors.</p><h3>Story 1 — Duck Duck Gopher</h3><p><em>(This report is public so go </em><a href="https://hackerone.com/reports/398641"><em>read about it here</em></a><em>)</em></p><p>This story starts in the middle of October of 2018: the early part of my bug hunting career. I was hacking on a the advice of a friend on this new private program invite I received for Nintendo (<a href="https://hackerone.com/nintendo">it’s public now</a>). I spent a number of hours hacking trying to find <em>anything</em> remotely interesting but struggling to make progress. I ended up giving up after an unsuccessful couple of hours. I was going to take one last brief look at my HTTP History in Burp Suite before closing it down and going to bed. That’s when I noticed a single request fly by that just seemed too good to be true.</p><p>At this time I had DuckDuckGo configured as my default search engine in Chrome (<em>though, admittedly, I pretty much always opened Google instead; so much for privacy ¯\_(ツ)_/¯</em>). At one point I had accidentally submitted a search query to DuckDuckGo and burp had intercepted all of the requests that page made. The one that caught my eye was a request to <a href="https://duckduckgo.com/iu.">https://duckduckgo.com/iu.</a> This request had a query parameter named url that appeared to return a page response whenever the parameter contained a url with a domain name of yimg.com</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IksYFSvlkyom5gZdFA-SwA.png" /><figcaption>Successful request</figcaption></figure><p>However, when you try another domain like google.com you’d encounter an error indicating that they’re doing some sort of filtering to reject requests to other domains. Notice the 403 Forbidden in this response as opposed to the 200 OK above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jVFBMCYsIQq-GooL" /><figcaption>Unsuccessful request</figcaption></figure><p>On a hunch, I decided to see if this service was actually parsing the url for the whitelist or if they were just using a string.contains fueled check. Sure enough, this was all I needed to bypass the filter and begin investigating this for possible SSRF behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*75BbTdKcm6MjQv85" /><figcaption>Bypassing a string.contains filter by appending the domain to a fake query parameter</figcaption></figure><p>As mentioned above, some of the things I want to investigate are the client’s ability to redirect and to identify what other protocols it supports if possible.</p><p>Upon testing for redirect behavior, I did notice that redirects were respected. I pointed DuckDuckGo at an endpoint that would respond with a 302 redirect to a burp collaborator instance and confirmed that the redirect worked. Afterwords, I checked to see if the gopher protocol was supported by using it in the Location header in the redirect. The gopher protocol would allow me to talk to many more services internally so it was useful to learn if this client would support it (and increase the severity of this finding).</p><p>I was able to perform a port scan using this SSRF and discovered a number of services running on localhost. One of these services, on port 6868, was Redis which was actually returning some data when hit with HTTP. The json that was returned mentioned a domain that only seemed resolvable internally. Now, with this SSRF, I would be able to port scan that service and begin identifying services I could communicate with.</p><p>Here’s a diagram to help demonstrate where we’re at with this attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*GlVeoR7OvvChFtn4f1_8xw.png" /><figcaption>SSRF against duckduckgo</figcaption></figure><p>Eventually, I noticed that port 8091 was open on cache-services.duckduckgo.com and was returning a ton of data. I had begun my report with DuckDuckGo a bit earlier than this but wanted to see what else I could do to increase the impact (and learn). Around this point, I had stopped hacking on the target and called it a day.</p><h4>Aftermath</h4><p>Unfortunately, DuckDuckGo doesn’t pay for bugs, but they do offer some swag. I ended up getting a DuckDuckGo t-shirt, a really great story, and a <a href="https://hackerone.com/reports/398641">public disclosure</a> that I’m quite proud of.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*HXppkU8EOtPnUHluh9nJOA.png" /></figure><h3>Story 2— In ursmtp</h3><p>I was invited to a private program that I didn’t have a lot of hope for. It was one of those services that felt like it could be replaced by any other <a href="https://en.wikipedia.org/wiki/Create,_read,_update_and_delete">CRUD app</a> on the market. It didn’t really offer much in the way of interesting behavior as far as I could tell and I was getting quite bored of it. While the scope did have a *. domain allowed, I wasn’t finding much interesting on it.</p><p>Eventually, I found a feature that allowed a user to update the information on their account. One of the fields you could fill out was your personal website address (similar to the one on twitter). An interesting behavior was that if the website didn’t exist or was inaccessible for some reason, this field would become yellow. If the site <em>did</em> exist, the field would turn green.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*DxQK2lRmE0jbnyQbLDHEAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*j7Yh_wt7spKARGGQExAvjg.png" /><figcaption>Site doesn’t exist vs site does exist</figcaption></figure><p>This feedback mechanism made me realize that this was more than a simple CRUD app and this service must be issuing an HTTP request to the specified address. I put a Burp collaborator address in to confirm and sure enough I saw a request come in.</p><p>I was able to use the feedback mechanism to perform a local port scan and found a number of services online: SSH, SMTP, DNS, and a few others that I couldn’t identify by port. To get to work on proving the impact here, I ended up performing a similar set of tests as I did with DuckDuckGo: I checked redirect and gopher behavior and was lucky enough to find that both were available.</p><p>Now that I had gopher available, I was able to prove some impact by crafting an SMTP message in gopher and firing it at localhost:25 . Sure enough, moments later, a new email showed up in my inbox.</p><h4>Aftermath</h4><p>I was awarded $800 for this finding and received a rating of high for this finding.</p><h3>Story 3— CMSSRF</h3><p>I was invited to a recently opened private program. If you’ve never been invited to a program that <em>just</em> opened up, then you may not be aware that you’ll get this sense of “blood in the water”: you <strong>know<em> </em></strong>that all of your fellow hackers and friends who also got an invite are going to start tearing this program up in the next couple of hours and if you don’t want to miss out on any low hanging fruit, you need to be quick.</p><p>I started my process off by deciding to not look at the core domain but jump to interesting subdomains. I ran sublist3r and discovered a couple of subdomains that mentioned cms in their domain name. In my experience, cms services tend to have many problems and that this might be a great place to take a look. I didn’t find much on the home page of this asset so I ran dirsearch to see if there was anything potentially interesting hidden on the asset.</p><p>Sure enough, after about 15 minutes of pounding the asset I found an endpoint that mentioned something about user management that would 302 to another endpoint. That endpoint had a login page for some management system. What’s more, there were some javascript files that referenced an API on this asset.</p><p>After discovering that the qa subdomain of <em>this</em> asset had unobfuscated javascript, I was able to figured out how to call the api and what calls I had available to me. One of the calls was named createWebRequest and took one url parameter in a POST body.</p><p>By this point in my hacking I already knew that this asset was running on AWS so I wasted no time in trying to issue a request to this api endpoint for the AWS metadata ip address. Sure enough, we got a hit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*1t39rygQDxoR79-xUcwANw.png" /><figcaption>Response from createwebrequest api</figcaption></figure><p>When I tried the AWS keys in the aws cli client, I found that I had an absurd level of access to dozens of S3 buckets, dozens more EC2 instances, Redis, etc. It was a critical in every sense of the word.</p><h4>Aftermath</h4><p>I was paid $3,000 (max payout) and the report was marked as a critical.</p><h3>Story 4— Authenticated Request</h3><p>This is the story of my most recent SSRF and, in a way, has been the most entertaining SSRF I’ve ever found. I started hacking on this new private program I was invited to. I started to look at the core asset for issues. I found a couple stored XSS at this point and was in a really great mood. I was about to wrap up shop when I took a look at the burp collaborator instance that I had left open. What I saw would surprise me.</p><p><em>As an aside</em>: one of the things I do when I’m signing up for services that I’m going to hack on is that I use a burp collaborator instance to review email. It’s a good way for me to not pollute the email accounts I have with annoying advertisements after I’ve finished hacking on a service and it also lets me see if anything interesting is happening after the fact.</p><p>Anyway, when I looked at burp collaborator, I noticed that it had received an HTTP request with a User-Agent that mentioned the service that I was hacking on. I thought to myself, “Did I just accidentally discover a feature that could be vulnerable to SSRF?!”. I set out to figure out how to trigger this again.</p><p>Well, putting the timeline of requests together clearly explained what happened. I had <em>just</em> signed up for this service with an email like user@abc123.burpcollaborator.net and seconds later received both an SMTP message (email) and HTTP request for the homepage.</p><p>I signed up again with an email address like user@1.2.3.4.xip.io to see if I could check if 302 behavior was respected. After receiving the forwarded request in my burp collaborator instance, I wanted to confirm that gopher worked as I had noticed that this request was fronted by Squid Proxy (which would probably block my attempts to access the internal network).</p><p>Similar to the previous stories, I checked the gopher protocol on a 302 redirect and noted that I was able to use it to interact with internal services. Unfortunately, there was no feedback of any kind so I wouldn’t be able to perform a port scan here. I decided to try for a localhost smtp message anyway to see if I could get lucky.</p><p>Sure enough, after crafting a message and performing the attack, I received a new email in my inbox proving that this SSRF was real and dangerous.</p><h4>Aftermath</h4><p>Well, unlike the previous stories, I have yet to get paid for this finding. The good news is that my report has been triaged as a high so I’m just waiting for a final determination on the payout. I’ll probably post about it <a href="https://twitter.com/d0nutptr">on my Twitter</a> (which you should <a href="https://twitter.com/d0nutptr">go follow</a> if you haven’t yet).</p><h3>Story 5 — Owning the Clout</h3><p>I wish I could say that this story was inspired by <a href="https://twitter.com/nahamsec/status/1161130930339110912">Nahamsec and Daeken’s SSRF talk at Defcon</a> but I had found this roughly a year prior to their talk being released. I was hacking on a new program for a company in the financial space. It was a product I had never seen (or heard of) before and was heavily involved in analytics. One of the features allowed you to upload images and store them for use in a couple of others features in the product.</p><p>Of course, one of the tests that I want to perform here is “Can I upload HTML” and if so, “What happens if that HTML fetches external resources”?</p><p>I tried uploading an HTML file but found that the service rejected the upload. I tried to see if I could lie about the content type in the multipart upload by changing it to say image/jpeg and sure enough it uploaded the document fine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*nud0-lia9tq3sqQge4z6zA.png" /></figure><p>After making a request to this other endpoint that gave you updates on the status of the document, it would trigger an internal renderer/browser to issue a request to attacker.com.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TKRL5QLa3i8OuJYLj1fXrQ.png" /></figure><p>In this case, I would’ve done more to prove impact, but it was pretty clear in this case that this was super unintended and I would’ve been able to access an internal system if I had an address to hit. I ended up reporting and getting a bounty.</p><h4>Aftermath</h4><p>I was compensated $1,000 for this finding and it was rated a medium. In retrospect, I should’ve done more to see if I could prove additional impact. I feel like that would’ve allowed me to be compensated much more highly than I was.</p><h3>Wrap Up</h3><p>SSRF is my favorite bug class due to its simplicity in execution, difficulty in mitigation, and the crazy number of ways that SSRF manifests (I’ve even heard of methods to use FTP to trigger it). Having the ability to interact with private, internal networks is incredibly fascinating to me and I hope that after reading this post and the stories within, you’ll feel more empowered to find and explore the inaccessible networks powering the modern world.</p><p>Shout-outs to <a href="https://medium.com/u/1855bdb0d898">Alyssa Herrera</a> whose <a href="https://medium.com/bugbountywriteup/piercing-the-veil-server-side-request-forgery-to-niprnet-access-c358fd5e249a">Piercing the Veil</a> post inspired me to even look for and become fascinated with SSRF in the first place.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4aa86d606fc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Attacks on Applications of K-Anonymity — For the Rest of Us]]></title>
            <link>https://d0nut.medium.com/attacks-on-applications-of-k-anonymity-for-the-rest-of-us-426d3b75145c?source=rss-3e0d2d8b6702------2</link>
            <guid isPermaLink="false">https://medium.com/p/426d3b75145c</guid>
            <category><![CDATA[bugsbounty]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[haveibeenpwned]]></category>
            <dc:creator><![CDATA[d0nut]]></dc:creator>
            <pubDate>Tue, 20 Aug 2019 19:14:58 GMT</pubDate>
            <atom:updated>2019-08-20T19:14:58.566Z</atom:updated>
            <content:encoded><![CDATA[<h3>Attacks on Applications of K-Anonymity — For the Rest of Us</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_OVb6OZNEaCJAutecfMWfw.png" /></figure><p>Three weeks ago I saw a <a href="https://cablej.io/blog/k-anonymity/">blog post</a> by fellow bug hunter, <a href="https://twitter.com/jackhcable">Jack Cable</a>. The post both inspired and challenged me. The attack vector presented was focused more on reduction in computational security than a binary outcome (e.g. <em>XSS, which either fires or it doesn’t</em>).</p><p>Jack’s article presents a theoretical attack by a malicious (or compromised) application using K-Anonymity, similar to that used by Have I Been Pwned (HIBP).</p><p>Today, we’ll briefly talk about what K-Anonymity is and why the implementation of K-Anonymity in HIBP matters. Then we’ll break down the attack described by Jack Cable in a way that doesn’t require in-depth technical knowledge.</p><h3>What is K-Anonymity</h3><p>The concept of K-Anonymity has been explained elsewhere online so I intend to borrow heavily from other sources here. We really only need a basic understanding of K-Anonymity before we take a look at attacks against it.</p><p>From <a href="https://dataprivacylab.org/dataprivacy/projects/kanonymity/index.html">dataprivacylab.org</a>, K-Anonymity is explained in the following way:</p><ul><li><em>Consider a data holder, such as a hospital or a bank, that has a privately held collection of person-specific, field structured data. Suppose the data holder wants to share a version of the data with researchers. </em><strong><em>How can a data holder release a version of its private data with scientific guarantees that the individuals who are the subjects of the data cannot be re-identified while the data remain practically useful?</em></strong><em> … A release provides k-anonymity protection if the information for each person contained in the release cannot be distinguished from at least k-1 individuals whose information also appears in the release…</em></li></ul><p>I’ve bolded the main problem that K-Anonymity attempts to address. K-Anonymity attempts to achieve a “diffusion of identity” by applying various levels of suppression and generalization.</p><p><strong><em>Generalization</em></strong> is the practice of taking a specific piece of information (like a home address) and reducing the precision of the information to a form that is still accurate, but less specific. An example of generalization is transforming a record’s <em>home address </em>to <em>city</em>.</p><p><strong><em>Suppression</em></strong> is the practice of omitting (or <em>suppressing</em>) information entirely.</p><p>For example, if I have a collection of data (a database, for example) and I want to share that data with some researchers, it’s very likely that I will infringe on the privacy of the individuals represented in the dataset. To make it more difficult to attribute the data to particular individuals, we can selectively <strong><em>generalize </em></strong>sensitive data fields, or we can omit (or <strong><em>suppress</em></strong>) them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/0*Lx5nzF8U_EEY_pXG.png" /><figcaption>A table before and after k-anonymity</figcaption></figure><p>That’s basically all we’ll need to know about K-Anonymity to understand the rest of this post.</p><h3>Use Case: Have I Been Pwned</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jtW91YmJS9wcMo-LrSQfwg.png" /></figure><p><a href="https://haveibeenpwned.com/">Have I Been Pwned</a> is an awesome service started by <a href="https://twitter.com/troyhunt">Troy Hunt</a> that allows you to determine if one of your accounts has been compromised in a data breach. Troy collects data dumps from breaches, <a href="https://www.troyhunt.com/heres-how-i-verify-data-breaches/">proves the validity of the data</a>, and then uploads them into his service which then notifies anyone subscribing to HIBP whether or not they‘re present in the dump.</p><p>It’s an incredibly useful service and I highly recommend everyone subscribe for notifications <a href="https://haveibeenpwned.com/NotifyME">here</a>.</p><p>Have I Been Pwned also offers another service which is going to be the subject of our criticisms today. Troy worked with <a href="https://twitter.com/IcyApril">Junade Ali</a> from Cloudflare to build the HIBP “<a href="https://www.troyhunt.com/ive-just-launched-pwned-passwords-version-2/#cloudflareprivacyandkanonymity">Pwned Passwords</a>” service. This service allows you to safely query whether or not a particular password is present in Troy’s collection of compromised passwords.</p><p>There are a couple of engineering challenges already:</p><ol><li>We definitely don’t want to require that users send their plaintext password to this service! (<em>“Just send me your credit card number and I’ll tell you if a hacker has it”</em>)</li><li>We probably don’t want to share out a list of plaintext passwords as a response</li></ol><p>Troy and Junade came up with an alternative system modeled after K-Anonymity that involves using client-side hashing and partial redaction of queries (<em>see: </em><strong><em>generalization</em></strong><em> above</em>) submitted to the Pwned Password API. The service then returns a list of password hashes that share the same prefix as the input so the user can determine if their password is in that list.</p><p>If that’s not particularly clear, here’s a diagram explaining it better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0rJTF_9EcVyLFdn0.png" /></figure><p>Here we can see that the password we wish to check is first hashed on the client-side producing a digest (<strong>F3BBBD66A63D…</strong>). Afterwards, we <em>only</em> send the first 5 characters of the digest to the Pwned Passwords API. The service then returns a <em>list </em>of password digests which begin with the same sequence we sent (<em>in reality, they don’t send the 5 character prefixes back.. but that’s just an implementation detail and not important here</em>). Our client then takes the full, unredacted digest of the password we wish to check (<strong>F3BBBD66A63D…</strong>) and determines if that digest is in the returned list.</p><p>This system allows a user to avoid sending over the plaintext password (or a simple digest) and potentially compromising their password if HIBP ever became malicious or was compromised.</p><p>While this system appears to provide those guarantees to a reasonable level of “<a href="https://en.wiktionary.org/wiki/computationally_secure">computational security</a>”, Jack Cable’s work showed that if we make some <em>reasonable </em>assumptions on how users might use the service, that a malicious or compromised HIBP could actually greatly reduce the security of your password(s) despite the usage of a partial digest <strong><em>generalization</em></strong>.</p><h3>Attacks on HIBP’s Model of k-anonymity</h3><p>Jack describes two attacks against this model. One relies on your passwords already being compromised (and therefore Troy has a copy of the plaintext, compromised passwords). The other attack relies on a relationship, described as being <strong><em>neighboring passwords</em>, </strong>between multiple password hashes submitted by the user. As it turns out, both attacks rely on very similar principles therefore to make this easier to understand, I’ve taken the liberty of explaining just the underlying principle of both attacks instead of each of them in succession.</p><h3>Wanna Play A Game</h3><p>Let’s imagine that we’re gonna play a game…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*iteo0d5256TTXZnb.jpg" /></figure><p>Well.. not that kind of game.</p><p>We’re going to play a special game of <a href="https://en.wikipedia.org/wiki/Hangman_(game)">Hangman </a>with a few special changes to the rules.</p><ol><li>Instead of one game of Hangman, we’re going to play <strong>three </strong>concurrent games of Hangman all at once.</li><li>Instead of showing you how many letters are in the word, I’m going to show you the first three letters of the word. The words can be any length after that. (<strong>app</strong> can be <em>apple</em> or <em>application</em>)</li><li>Lastly, I will ensure that the words for <strong>all</strong> <strong>three </strong>games<strong> </strong>will be <strong>synonyms </strong>of each other.</li></ol><p>This game might seem daunting considering that you’re trying to win not only 1 but 3 games at the same time; however, if we use the modified rules of this game to our advantage we can probably win all three with a few guesses.</p><p>Let’s assume that the hint (<em>the first three letters</em>) for our three games are the following:</p><ol><li><strong><em>HAC</em></strong></li><li><strong><em>CRA</em></strong></li><li><strong><em>CYB</em></strong></li></ol><p>The first thing we’re going to do is grab a Dictionary and a <a href="https://www.merriam-webster.com/thesaurus">Thesaurus</a>. We’re, then, going to want to try and figure out all of the possible answers for Game 1. If we were to build a Venn diagram of all words and all words that start with <strong>HAC</strong> then we might see this.</p><figure><img alt="Venn Diagram showing crude relationship between “All Words” and “Words beginning with HAC”" src="https://cdn-images-1.medium.com/max/960/0*Zn7RlixiFGTCU0I3.png" /></figure><p>The answer for Game 1 lies within that small yellow circle. Unfortunately, that circle still contains too many words for us to guess all of them before we lost game 1.</p><p>Thankfully, we can still use this information from the Dictionary to our advantage.</p><p>Our next step is to take the list of all words that start with <strong>HAC</strong> and use our Thesaurus to build <em>another</em> list. A list of every synonym for words that begin with <strong>HAC</strong>.</p><p>If our list of words from the Dictionary looked like the following:</p><pre>Hack<br>Hackberry<br>Hacked<br>Hacker<br>Hackers<br>Hacking<br>Hacksaw<br>...</pre><p>Then our list from the Thesaurus may contain the following synonyms:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*lcPcAQx-RxmQAFEExFFzDw.png" /></figure><p>While this list is long, it’s certainly a LOT shorter than the “<em>List of All Words</em>”. We know that the answer to Game 2 and Game 3 <strong>MUST </strong>be in this list as they are synonyms of each other. Therefore, the next time we need to find words that only start with a particular prefix, we can search through this much smaller set of words.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*m4R-MVxjf4kVmMSR4yR1pw.png" /></figure><p>In our particular case, only 2 words start with <strong>CRA</strong> (<em>cracker</em> and <em>crackers</em>) making the answer to game 3 pretty easy to guess at this point. However, just for the sake of the example, we’ll continue to go through the process.</p><p>It might appear that we should just repeat the previous step and build a list of synonyms from the <em>“List of All Words</em>” that start with <strong>CRA</strong>. But, as we said, we only care about <strong>CRA</strong> words that are <em>also</em> present in the list of synonyms we created for <strong>HAC</strong>. To narrow our list even further, words we need for Game 3 (which start with <strong>CYB</strong>) <em>also</em> need to be in <em>both </em>lists of synonyms of <strong>HAC </strong>and <strong>CRA </strong>words. At this point it’s probably best to represent all this in another diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/0*-2vzYrdDq9cBbqJg.png" /></figure><p>We’re particularly interested in the middle section as these are possible candidates for Game 3 being both synonyms of <strong>HAC</strong> words and synonyms of <strong>CRA </strong>words (where the <strong>CRA </strong>words are synonyms of <strong>HAC </strong>words).</p><p>We’re basically establishing the following relationship.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/0*fXc0Ekm_Gs8wxCjA.png" /></figure><p>Eventually, after we’ve narrowed down all of the words that are:</p><ol><li>Synonyms of each other</li><li>Start with <strong>HAC</strong>, <strong>CRA</strong>, and <strong>CYB </strong>respectively</li></ol><p>We’re left with few options for the games:</p><pre>Game 1: Hacker, Hackers<br>Game 2: Cracker, Crackers<br>Game 3: Cyberpunk</pre><p>The relationship of the words allowed us to <em>significantly </em>reduce the possible answers to these games much more easily than if this relationship didn’t exist.</p><h3>No More Fun and Games</h3><p>So how does playing games of Hangman relate to the Pwned Passwords API and HIBP? Well, it’s pretty well known that many people reuse passwords or reuse parts of passwords (hunter2 and hunter3 or june1997 and june1998). <a href="https://cablej.io/blog/k-anonymity">Jack Cable described this relationship</a> between similar passwords as <strong><em>neighboring passwords</em></strong>.</p><blockquote><em>We generalize password modification to the notion of </em><strong><em>neighboring passwords</em></strong><em>, which encapsulates two passwords that are similar to each other.</em></blockquote><p>In the imaginary game we described above, having the secret words being synonyms of each other was a significant advantage. Likewise, if we assume that the user of the Pwned Password service is checking <strong><em>neighboring passwords</em></strong> with their three queries then an attacker can gain a similar advantage in their guessing.This means that if HIBP was compromised or Troy was secretly malicious, it would be possible for HIBP to significantly increase their ability to guess your passwords even if that password didn’t previously appear in their list of compromised passwords.</p><h3>Conclusion</h3><p>I would like to clear up some potentially confusing things:</p><ol><li>I think that the work Troy Hunt is doing with HIBP is very awesome and I do recommend that everyone signup for notifications from the service.</li><li>I also think at the work Troy is doing with Pwned Passwords is awesome and he’s probably not spending his time trying to break into random people’s Neopet’s account.</li><li>The point of Jack’s work and this blog post is to help make sure everyone is aware of the potential risks in using a system like Pwned Passwords and makes an informed decision on how to use it. Do note that we’re taking some liberties here in demonstrating this attack and this attack scenario won’t apply to everyone.</li></ol><p>Lastly, if you aren’t already, you should definitely use a password manager like 1Password or LastPass and make sure to use long, unique, randomly generated passwords for all of your services to ensure that your accounts remain safe.</p><p>If you’ve made it this far, thanks for taking the time to read this long, technical piece I’ve been working on. I thank Jack Cable for writing up such a cool blog post that I just needed to talk about it. I also thank the reviewers for helping make this post easy for everyone to read.</p><p>Keep an eye out for the next piece I’ll be releasing which has everything to do with Regular Expressions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/64/0*ksfCpcAtXQrsvxuY" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=426d3b75145c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Better Exfiltration via HTML Injection]]></title>
            <link>https://d0nut.medium.com/better-exfiltration-via-html-injection-31c72a2dae8b?source=rss-3e0d2d8b6702------2</link>
            <guid isPermaLink="false">https://medium.com/p/31c72a2dae8b</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[d0nut]]></dc:creator>
            <pubDate>Thu, 11 Apr 2019 02:00:10 GMT</pubDate>
            <atom:updated>2019-04-11T02:00:10.119Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Exy7rKXpCmzhbuWnuMHLbA.png" /><figcaption>I used <a href="https://drawings.google.com/">Google Drawings</a> and there’s no shame in that</figcaption></figure><p>This is a story about how I (re)discovered an exploitation technique and took a bug with fairly limited impact to a 5 digit bounty by bypassing existing mitigations.</p><h3>A Curious Case of HTML Injection</h3><p><a href="https://medium.com/u/62a9c5006f7a">André Baptista</a> and <a href="https://twitter.com/itscachemoney">Cache-Money</a> were working on a very strange bug. It started off as a simple character-set bypass and through a crazy series of steps evolved into HTML injection somewhere else in the target (not full-blown XSS, though, due to <a href="https://github.com/cure53/DOMPurify/tree/master/src"><strong>DomPurify</strong></a>). It was a cool chain and they could tell they were onto something big, but the next step was giving them a fair bit of trouble.</p><p>After hearing about the progress they made, I jumped in to see if I could offer any assistance in escalating this bug. At this point, we determined the worst we could do was a fairly effective clickjacking attack. 0xACB (Andre) and Cache-Money had a beautiful idea on how to chain a couple more attacks together to potentially achieve a high impact vuln, but I had different ideas.</p><p>After we determined that <a href="https://github.com/cure53/DOMPurify/blob/DOMParser/src/purify.js#L106">DomPurify<strong> </strong>allowed </a><a href="https://github.com/cure53/DOMPurify/blob/DOMParser/src/purify.js#L106">style tags by default</a>, I became fairly interested in how we could leverage CSS to do more than just manipulate the DOM. If you’ve read some posts of mine already, you’ll know that I’m <a href="https://medium.com/bugbountywriteup/exfiltration-via-css-injection-4e999f63097d">no stranger to CSS injection exploitation</a>. Unfortunately, this page both had frame protection and required some user interaction to trigger the injection. It seemed that if we wanted to exfiltrate something sensitive it would take a long time (over the course of many days) to perform the leakage. Of course this is a fairly weak, error-prone attack and would, at best, yield a low 4 digit bounty on this target.</p><p>I needed a way to get the browser, without reloading, iframes, or additional user interaction, to reevaluate multiple CSS payloads to make an attack like this work. Additionally, we had limitations on the length of the payload we could inject setting us back even further. It didn’t really seem possible to exploit this using just a &lt;style&gt; tag… until I started thinking about interesting CSS features, namely @import.</p><h3>A Primer on CSS Injection</h3><p>Before I get into the meat of the technique, I want to leave a short section here to describe the traditional token exfiltration technique used in CSS injection. If you’re already familiar, feel free to skip ahead to the next section. Also, I go into more depth on the technique in a <a href="https://medium.com/bugbountywriteup/exfiltration-via-css-injection-4e999f63097d">previous blog post</a>.</p><p>The traditional CSS injection token exfiltration technique relies on a feature of CSS called <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors"><strong>Attribute Selectors</strong></a>. Attribute selectors allow a developer to specify that a particular style should only apply to an element if an attribute of that element meets the condition indicated by the selector.</p><p>We can leverage the attribute selector to create rules that only apply to sensitive elements on the page given certain conditions. Then we can use properties like background-image to make the browser call out to an attacker controlled system when these styles apply. This allows us to establish a feedback loop that drives the token exfiltration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de5d347583c39a6ddc7ef4e37757985e/href">https://medium.com/media/de5d347583c39a6ddc7ef4e37757985e/href</a></iframe><p>In this example, we tell the browser that <em>“if the CSRF token starts with an </em><em>a then set the </em><em>background-image to be the image found at </em><em>https://attacker.com/exfil/a”</em>. We then repeat this rule for every possible character the token could start with (a, b, c, .. 7, 8, 9, etc.).</p><p>Once we learn what the first character of the token is we can perform the attack again (usually using iframes) but with a slightly modified payload.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28de21bffb7e10948a0ac01d90968274/href">https://medium.com/media/28de21bffb7e10948a0ac01d90968274/href</a></iframe><p>In this example, we assume that the first token of the CSRF token is a c . In this way, we’re able to determine the second character of the CSRF token by rerunning the previous rule but with all tokens prepended with a c.</p><h4>Prerequisites</h4><p>The aforementioned technique generally requires 3 things to be true:</p><ol><li>The CSS injection needs to allow for sufficiently long payloads</li><li>Ability to frame the page to trigger CSS re-evaluation of newly generated payloads</li><li>Ability to use externally hosted images (could be blocked by CSP)</li></ol><p>This means that the previous technique might not be applicable if the injection doesn’t allow for sufficiently sized payloads or if the page cannot be framed. In our case, that meant we were unable to use this technique due to both the presence of framing mitigations and the limited number of characters we could actually inject.</p><h3>@import to the Rescue</h3><p>Many programming languages have the ability to import code from other source files. CSS is no exception. While many might only be aware of &lt;link href=&quot;...&quot; rel=&quot;stylesheet&quot;&gt; , CSS itself actually has a way to perform a similar (but different) type of stylesheet inclusion using an <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule"><strong>at-rule</strong></a> called @import.</p><p>@import , <a href="https://drafts.csswg.org/css-cascade-3/#at-ruledef-import">in most cases</a>, performs a direct in-place swap of the fetched styles into the current stylesheet. This allows a developer to pull in external styles and simultaneously override any undesirable directives defined in the external resource below the @import line.</p><p>An interesting side-effect of how this feature is implemented in some browsers (namely Chrome) is that the external resource can be fetched <em>in parallel</em> to the browser also processing the rest of the stylesheet. My understanding is that this behavior increases <a href="https://developers.google.com/web/tools/lighthouse/audits/time-to-interactive">TTI</a> of the page while attempting to mitigate “flashes of unstyled content” (see: <a href="https://webkit.org/blog/66/the-fouc-problem/"><strong>FOUC problem</strong></a>) but it actually has practical use in exploitation.</p><p>Imagine for a moment we had a webpage containing the following stylesheet:</p><pre>@import url(http://laggysite.com/base.css);</pre><pre>* { color: red; }</pre><p>Chrome processes this stylesheet in 3 steps:</p><ol><li>Issue a request to <a href="http://laggysite.com/base.css">http://laggysite.com/base.css</a></li><li>Evaluate the remaining directives (apply * { color: red; } )</li><li>When <a href="http://laggysite.com/base.css">http://laggysite.com/base.css</a> returns, substitute the response into the stylesheet and reevaluate the stylesheet.</li></ol><p>We could leverage this browser behavior of re-evaluating stylesheets when @import targets respond simulating the same “ability to control reevaluation of CSS” behavior that we needed from iframes in the old technique. The only requirement we have to use @import is <a href="https://drafts.csswg.org/css-cascade-3/#ref-for-at-ruledef-import%E2%91%A3">we must have control at the start of a </a><a href="https://drafts.csswg.org/css-cascade-3/#ref-for-at-ruledef-import%E2%91%A3">style tag</a> (which we have since this is HTML injection).</p><p>To do this, we’ll create a couple of @import rules in our stylesheet and let our server keep all of the connections open. Then we’ll use a standard CSS injection token exfil payload to pull out the first token from our target attribute. After our server receives this token from the background style, we can generate the next token exfil payload and respond to the next pending @import rule using the newly minted payload.</p><p>To make it all nice and neat, we can kick everything off with a lone, initial @import rule (also helping us accomplish our goal of limiting the size of the payload).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vWkX27iq0UoSM_p4NCtlfQ.png" /><figcaption>A method to chain @import for attribute exfiltration</figcaption></figure><p>To prove that this attack could work, I went about creating a tool I call sic (which stands for <em>Sequential Import Chaining</em>). The name inspired by the sequential “1 by 1” nature of the @import rules being chained together to cause controlled reevaluation of the CSS.</p><p>You can see an example of a vanilla HTML injection being leveraged with sic to exfil an href on the page with a single page load below. In a more practical example, an attacker would pull something more sensitive such as a CSRF token in the DOM using the value attribute.</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZiLf65iTcaM&amp;src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZiLf65iTcaM%3Ffeature%3Doembed&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/04600a2428ddba93ac0ba347669df314/href">https://medium.com/media/04600a2428ddba93ac0ba347669df314/href</a></iframe><p>The code for the tool is here:</p><p><a href="https://github.com/d0nutptr/sic">https://github.com/d0nutptr/sic</a></p><p>With this new technique, we were now able to demonstrate how a victim would, with a single click, leak sensitive information off of the current page increasing the bounty on the report tremendously.</p><h3>A Rediscovery</h3><p>Well you can imagine my surprise as I watched my tool (that I spent hours working on) finally succeeded in its task…</p><h3>d0nut on Twitter</h3><p>Holy shit I think i just invented a new exploitation technique for a type of vulnerability. After the #h165 event I&#39;ll do a write up on how to do it and share the tool you&#39;ll need to do it.</p><p>All of the hackers I showed this to had never seen something like this before reaffirming my conviction that I was first to this new technique. It wasn’t until I shared the concept with <a href="https://twitter.com/edoverflow">EdOverflow</a> that he pointed me to <a href="https://twitter.com/cgvwzq">Vila</a>, who actually <a href="https://vwzq.net/slides/2019-s3_css_injection_attacks.pdf">came up with a variation of this technique</a> roughly half a year ago.</p><p>Funny enough, I tried to build a PoC similar to Vila’s PoC but was unable to figure out how to chain the stylesheets recursively while simultaneously getting the browser to respect the newly injected styles. The recursive method requires that you add “<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity"><strong>additional specificity</strong></a>” to each newly added rules otherwise the browser will only respect the last applicable styles in the stylesheet (which also happen to be the first styles injected into the page). This is why I came up with a sequential technique which doesn’t require additional specificity. Nonetheless, both techniques use the same core principles.</p><h3>Potential Applications</h3><p>There are a number of places where this could be applicable. Outside of the obvious case of HTML injection in web applications, I’ve done some attempts at poking around with email clients to see if any of them exhibited similar behavior to Chrome; however, an interesting application suggested by Vila is in electron applications.</p><blockquote>“…this approach can be really useful for HTML injections in Electron apps (attackers usually don’t have iframes or control over navigation)” — Pepe Vila</blockquote><p>Lastly, I’m curious about the implications of server-side rendering. I can imagine a case of, perhaps, PDF generation where both SSRF and javascript execution are mitigated. This could potentially allow an attacker to leak contents injected into this document efficiently.</p><h3>Thanks</h3><p>Huge shoutout to the following people for help in one way or another along this process:</p><ul><li><a href="https://twitter.com/0xACB">0xACB</a></li><li><a href="https://twitter.com/itscachemoney">cache-money</a></li><li><a href="https://twitter.com/infosec_au">shubs</a></li><li><a href="https://twitter.com/seanyeoh">sean</a></li><li><a href="https://twitter.com/_ruby">ruby</a></li><li><a href="https://twitter.com/cgvwzq">vila</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31c72a2dae8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Tips Bug Bounty Programs *Want* You to Know About]]></title>
            <link>https://d0nut.medium.com/5-tips-bug-bounty-programs-want-you-to-know-about-544d29888aeb?source=rss-3e0d2d8b6702------2</link>
            <guid isPermaLink="false">https://medium.com/p/544d29888aeb</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[hackerone]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[d0nut]]></dc:creator>
            <pubDate>Tue, 25 Sep 2018 05:46:46 GMT</pubDate>
            <atom:updated>2018-09-25T05:46:46.988Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*_GFHpSrVT1uw7VBj" /><figcaption><em>This is the only good CC0 image I could find</em></figcaption></figure><p>If you’re not aware, I <a href="https://medium.com/@d0nut/week-15-hello-dropbox-af71d0e3e2c6">joined Dropbox’s security team</a> last September. Since then, I’ve become very involved in the bug bounty community on two fronts: both running a program and as a hacker in my spare time. It’s offered me a unique perspective on many divisive issues and I’ve used my experiences to both improve our program as well as helping to bring a program’s perspective into the conversation with other prominent bug hunters.</p><p>Sometime last week I gave back to the bug bounty community by contributing a tip to <a href="https://twitter.com/hashtag/bugbountytip?src=hash">#bugbountytip</a> on twitter.</p><h3>d0nut on Twitter</h3><p>I figured I would submit a low quality #bugbountytip of my own, today: One of the most successful ways to get a stacktrace, in my experience, is find a POST endpoint that accepts JSON, and send it malformed JSON. Works like 80% of the time.</p><p>Originally, I didn’t expect anyone to pay attention as I’m not as experienced in bug hunting as <a href="https://twitter.com/nnwakelam/status/1041921888526594048">nnwakelam</a> or <a href="https://twitter.com/Yassineaboukir/status/1040686607341379590">yassineaboukir</a>. However, I was pleasantly surprised at the amount of people who thought my tidbit was noteworthy.</p><p>Today, I’d like to give back to the community, again, by contributing a few tips to newer hackers in the community. While there are plenty of things your programs would want you to know, I believe these are some of the most impactful tips I could give based on my experience running a program.</p><h3>Tip 1: Understand “Human Augmented Signal”</h3><p>Many programs have a feature turned on called Human Augmented Signal, or HAS for short. If you haven’t heard of HAS before, you can read more about it here: <a href="https://docs.hackerone.com/programs/human-augmented-signal.html">https://docs.hackerone.com/programs/human-augmented-signal.html</a>.</p><p>In short, HAS flags reports that <em>look</em> like spam or will probably not be accepted. This feature helps reduce the spam and other low quality submissions that programs occasionally receive. While HAS has proven invaluable to our program, I’ve noticed that many (including veteran) hackers don’t understand how it works.</p><p>If your report is flagged by HAS, your report won’t enter the <em>new</em> state (<a href="https://docs.hackerone.com/hackers/report-states.html">https://docs.hackerone.com/hackers/report-states.html</a>) but, instead, will enter a state called <em>pre-submission</em>.</p><p>At this time, your report will be reviewed by the <em>HackerOne triage team</em>. Generally, the bug bounty program will not even see, or be alerted to, reports that were put into <em>pre-submission</em>. If the report is valid, then the HackerOne triage team will transition the report to the <em>new</em> state. At this time, the program will then see the submission enter their main queue. However, it’s important to remember that if your report goes from <em>pre-submission </em>to<em> N/A </em>then the program has almost certainly not seen the report <strong><em>at all</em></strong><em>.</em></p><p>A couple of times now, I’ve seen hackers get frustrated when they observe changes to the asset involved in their report without realizing that the program likely hasn’t even seen their submission. In their frustration they accuse the program of not wanting to pay out to researchers or other shenanigans.</p><p>I would advise all (especially newer) hackers on HackerOne to learn a bit more about HAS and what a good report looks like. Writing <a href="https://hackerone.com/reports/32825">a better report</a> (being clear, providing examples, showing impact, etc) will help significantly reduce your chance of getting flagged by HAS and will also help the program triage your report quicker.</p><h3>Tip 2: Learn How to Properly Mediate</h3><p>Sometimes, as a hacker, the way a program is handling a report might appear unfair or irresponsible. If you feel strongly about how a report is transgressing, there are options to help mediate the situation.</p><h4>Option 1: HackerOne Mediation Request</h4><p>The first option is use a mediation request. <a href="https://docs.hackerone.com/hackers/hacker-mediation.html">HackerOne offers mediation services</a> if communication between a hacker and the program has begun to break down. They’ll evaluate the report and act like an advocate on your behalf to ensure that everything goes smoothly. However, this feature is a privilege for hackers with 200+ reputation and over 1.0 signal.</p><h4>Option 2: Email support@hackerone.com</h4><p><a href="https://docs.hackerone.com/hackers/hacker-mediation.html">I</a>f your account doesn’t have the necessary reputation or signal to use this feature, you can always email support@hackerone.com to get assistance, manually.</p><h3>Tip 3: Learn about Capability-based Security</h3><p>One of the most common causes of <em>N/A</em> and <em>informative </em>reports I’ve seen is hackers not recognizing <a href="https://en.wikipedia.org/wiki/Capability-based_security">capability-based security</a> when they see it.</p><p>In short, capability-based security is a security model in which an unforgeable token (referred to as a capability) is used to convey access rights to some resource. For example: an application may create a capability when generating a download link. After the capability is minted, any party carrying the capability (visiting the link) would have access granted to that particular resource as carried by the capability. An example of what this link may look like: h<a href="https://example.com/download.php?tkn=4b8368666456c476327dd285a6a21050bea5eeec41c64f5145a561fcb25e9955`">ttps://example.com/download.php?tkn=4b8368666456c476327dd285a6a21050bea5eeec41c64f5145a561fcb25e9955</a>.</p><p>Occasionally, bug hunters may look at this and discover that they don’t have to be authenticated to download the file. Because they’re not logged in, they assume that this must be a vulnerability. However, if we recall, capabilities are also supposed to carry access right information and, therefore, this software is working as intended (and this isn’t a missing access control check).</p><p>One issue to check for might be predictable capability generation. If the capabilities are easy to predict then attackers could gain access to some resource by predicting the capability’s value manually. This is similar to IDOR except the vulnerability isn’t missing or <em>insufficient access control logic,</em> but <em>use of insufficiently random values</em>.</p><h3>Tip 4: Subscribe to Policy Changes</h3><p>Every so often, programs will update their policies to reflect new rules to be mindful of or new assets to hack on. It’s important to both the programs and hackers that participating hackers are up-to-date on the latest policy changes. That way, hackers are both playing by the rules and getting access to the full scope for testing.</p><p>Thankfully, HackerOne has a feature to help keep hackers in-the-know with regards to policy updates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*z3q73sXZCqDHAgiXg_6KKw.png" /></figure><p>If you plan to keep hacking on a program, make sure to stay aware of recent changes to the policy!</p><h3>Tip 5: Learn how to Demonstrate Impact (And why your missing security headers report is bad)</h3><p>This is probably the most important tip I could offer. Properly understanding and demonstrating impact is one of <em>the most important parts of your report</em>.</p><p>I asked well-known bug hunter, <a href="https://hackerone.com/europa">europa</a>, “What is the one thing you wish you could go back and tell yourself when you first started bug hunting?”</p><blockquote>Demonstrate impact; if you can’t do (any) such thing, then reconsider submitting — europa</blockquote><p>Similarly, <a href="https://twitter.com/KarimPwnz">karimpwnz</a>, had this to say:</p><blockquote>There are many so-called “vulnerabilities” that people shouldn’t report, such as logout CSRF, cookie missing secure flag, and content spoofing. A lot of the time, the aforementioned vulnerabilities are not found in a dangerous context; they don’t pose any considerable risk on the users or the website. However, such minor issues can be chained together to create an impactful vulnerability, like with the chaining of logout CSRF, cookie missing secure flag “vulnerability”, and self-XSS; a similar chain was used by Jack Whitton on Uber. Also, who would be friends with a donut? — karimpwnz</blockquote><p>Okay, so we’ve established that it’s important to demonstrate impact, but what does that mean? It means that if you <em>think</em> you’ve found a weakness, you have to be able to demonstrate (not just describe) how that weakness would be abused.</p><p>Here’s a couple of examples:</p><h4>XSS on example.com</h4><p>Don’t just report “XSS on example.com” but describe what an attacker would do with that XSS.</p><ul><li>Could you steal cookies (verify important cookies don’t have <em>HttpOnly</em> set)?</li><li>Could you perform an account takeover by changing the password (There are tricks to get the existing password that don’t require phishing.. but for another time 😄)?</li><li>Could you perform some critical action like purchase items, exfiltrate secrets, etc. etc.</li></ul><p>These are the important questions that you should be able to answer. By answering these questions ahead of time, you’ll make the triaging process faster, you’ll be less likely to get flagged by HAS, and you’ll make the program much happier.</p><h4>Missing X-Content-Type-Options: nosniff on example.com/foo</h4><p>Very few programs actually ask for “missing best practice” reports. These reports try to pass off a “missing best practice” as a vulnerability. While it may be smart of the program to add these missing security headers or make a particular change to their DNS record, what these reports often don’t do is show how an attacker would be able to exploit these missing security practices. As a result, the value of these reports is severely diminished.</p><p>For example, if you found an endpoint that returns JSON without a <em>X-Content-Type-Options: nosniff</em> header but no reflected XSS to demonstrate why having that header is a good idea, then don’t report it. You haven’t found a vulnerability. You found a weakness that <em>could</em> manifest into a vulnerability <em>eventually, </em>but without this reflected XSS <strong><em>you cannot demonstrate impact</em></strong>.</p><p>One way to help demonstrate the impact of a report (as well as improve communication) might be to create an easy to use proof of concept (PoC). This is especially helpful if your report contains complicated or specialized knowledge to replicate the attack. As the bug hunter, <a href="https://hackerone.com/filedescriptor">FileDescriptor</a>, says</p><blockquote>Some of my bugs (e.g. OAuth) requires calculate signature and a also a bunch of complicated settings before you can even verify if it’s an issue. Most of my reports are one click no brainier or a script that you can easily execute. — FileDescriptor</blockquote><p><em>Demonstrating impact</em> doesn’t mean pointing to OWASP articles describing why it’s a good idea to accept the report.</p><p><em>Demonstrating impact</em> doesn’t mean citing another HackerOne report where a different program accepted a similar report (this might also get you flagged by HAS, too).</p><p><em>Demonstrating impact</em> doesn’t mean describing what <em>could</em> happen if a vulnerability existed that let you exploit the misconfiguration.</p><p>There are some exceptions to this rule, of course. For example, if you find what looks like credentials to an internal system, you should probably report that. However, the general rule of thumb is..</p><p>If you can’t exploit it, don’t report it.</p><blockquote>tl;dr: PoC||GTFO — europa</blockquote><h3>Conclusion</h3><p>I hope that both new and experienced bug hunters learned something interesting. While most of these tips are targeted at new bug hunters, I think there’s room for everyone to grow. I may consider coming up with some more bug bounty related posts in the future, but I’ll likely be focusing on my experiences as a hunter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=544d29888aeb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exfiltration via CSS Injection]]></title>
            <link>https://infosecwriteups.com/exfiltration-via-css-injection-4e999f63097d?source=rss-3e0d2d8b6702------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e999f63097d</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[d0nut]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 17:02:22 GMT</pubDate>
            <atom:updated>2018-11-06T04:33:58.977Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*C_IwDTsXhnfX_b535mtdxQ.png" /></figure><p>Today’s topic is something that’s <a href="https://curesec.com/blog/article/blog/Reading-Data-via-CSS-Injection-180.html">already</a> <a href="http://eaea.sirdarckcat.net/cssar/v2/">pretty well covered</a>: CSS injections. I wanted to talk about my experience implementing this attack on a real site. As you may have encountered, the situation in which you find a vulnerability may not be the pristine situation many vulnerabilities are originally described in (<a href="https://buer.haus/2017/03/08/airbnb-when-bypassing-json-encoding-xss-filter-waf-csp-and-auditor-turns-into-eight-vulnerabilities/">like XSS but with a WAF</a>). As such, writing about the experiences researchers encounter in real life can give light to practical implementations of preventative mechanisms (or general roadblocks) and bypasses for those blockers.</p><p>As some of you may know, I’ve recently taken up bug bounties in my spare time. While doing bug bounties, I’ve had the wonderful opportunity to work with two of the best hackers in the business: <a href="https://medium.com/u/9a72584d6865">Behrouz Sadeghipour</a> and <a href="https://twitter.com/bbuerhaus">Brett Buerhaus</a>. While we were hacking away at various targets, nahamsec (Benrouz) messaged me saying they had found a <a href="https://www.owasp.org/index.php/Testing_for_CSS_Injection_(OTG-CLIENT-005)">CSS injection</a> but had trouble exploiting it.</p><p>The main use for exploiting a CSS injection is data exfiltration from input elements. The input elements we’re mostly concerned with are usually <a href="https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet#Synchronizer_.28CSRF.29_Tokens">CSRF token input elements</a> as these are commonly placed on the page as type=hidden input elements in forms. This brings us our first problem with exploiting this CSS injection: in both Chrome and Firefox, input[type=hidden] elements do not fetch background-image urls.</p><p>The general CSS injection data exfil method is to use css like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d56546885c2fcc4735706d10ade99ac/href">https://medium.com/media/7d56546885c2fcc4735706d10ade99ac/href</a></iframe><p>Then, attacker.com would load an iframe with this css injection on it on target.com . attacker.com would then wait for a request to https://attacker.com/exfil/&lt;data&gt;.</p><p>Let’s assume the token is csrF. This CSS would trigger a page load on <a href="https://attacker.com/exfil/c.">https://attacker.com/exfil/c.</a> Then, we would reload the iframe but with CSS like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab7c2572ae1351ae491cf98daa4b8737/href">https://medium.com/media/ab7c2572ae1351ae491cf98daa4b8737/href</a></iframe><p>Which would cause a page load at <a href="https://attacker.com/exfil/cs.">https://attacker.com/exfil/cs.</a> Eventually, after repeating this pattern a few times, the final request to <a href="https://attacker.com/exfil/csrF">https://attacker.com/exfil/csrF</a> which allows an attacker to learn of the visitor’s CSRF token.</p><p>With the specific site that we were looking at, there was, thankfully, no X-Frame-Options specified, which would prevent us from using iframes to exploit the cssinjection in a simple way (you could technically open more tabs.. but that’s really ugly.. and super “noisy”).</p><h3>The Problem</h3><p>Ok, so that’s all explained and seems simple enough to implement, what’s the problem? Well, remember that type=hidden input elements don’t actually request those images? It turns out that since almost all csrf tokens in forms are type=hidden which means that it makes directly using the input field to exfiltrate data much harder.</p><p>Originally, we looked at other methods we could use to call out from the page but we didn’t find anything simple. We figured that there was another way to do this attack but we just had to figure it out. After some investigating, we learned of ~ and + in CSS which are the <a href="https://css-tricks.com/child-and-sibling-selectors/">general and adjacent sibling</a> selectors.</p><p>What the sibling selectors let you do is take an element that shares a common parent and style it based on a CSS query. For example, imagine we had a page like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef278346626dfb7541912ff1583dfffc/href">https://medium.com/media/ef278346626dfb7541912ff1583dfffc/href</a></iframe><p>With the following CSS:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ec1e9b1f6ac08a4134ccd3a6567ad89/href">https://medium.com/media/0ec1e9b1f6ac08a4134ccd3a6567ad89/href</a></iframe><p>This says (read right to left) “Any p that’s a sibling to a p[color=red] should have color: red .</p><p>What this selector lets us do is say “if any element is next to an input element that contains the CSRF token, set a background-image it”. We can construct a potential CSS directive by similarly writing right to left on the statement above:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a888b2d5d9eb67585ebe0f89bc9c432d/href">https://medium.com/media/a888b2d5d9eb67585ebe0f89bc9c432d/href</a></iframe><p>Since there existed a form on our target with elements that were not type=hidden, we were able to cause those elements to make the request on behalf of the CSRF token element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ezbqa0CDN5tMCUJaP2f2zg.png" /><figcaption>Screenshot of the PoC written for our recent CSS injection CSRF token exfiltration report</figcaption></figure><p>Lastly, here’s an anonymized version of the PoC that we used for our report: <a href="https://gist.github.com/d0nutptr/928301bde1d2aa761d1632628ee8f24e">https://gist.github.com/d0nutptr/928301bde1d2aa761d1632628ee8f24e</a></p><p>This doesn’t include the server side code as most of that should be pretty obvious (we had the background-image requests set a value on a cookie; this also has the benefit that <a href="https://superuser.com/questions/1292504/how-to-allow-third-party-cookies-in-safari-11-0-3-13604-5-6">our PoC won’t work in Safari</a>).</p><h3>The Future</h3><p>A couple of the forms on the page were concerning us when we were originally attempting to exploit this vulnerability. Some of the forms <em>only</em> contained hidden inputs. This would mean that we couldn’t use the sibling selector technique because none of the siblings would be able to make a request via background-image for us.</p><p>Some research into this problem yielded the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:has">following proposed directive</a> in the selectors-4 <a href="https://drafts.csswg.org/selectors-4/#relational">draft from the W3C</a>. :has() allows you to perform a similar query to the sibling selector with the big difference being that you can make this query from the parent of an element.</p><p>For example, in our proof of concept, one could instead have written:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b3cbf27d8398158c4259685cad6064c2/href">https://medium.com/media/b3cbf27d8398158c4259685cad6064c2/href</a></iframe><p>Which says “any form that has a descendant input element with name csrf and value token should have a background-image of &lt;url&gt;”.</p><p>This, obviously, would work when all input fields are type=hidden and allow for easier general exploitation of this issue. Currently, this feature hasn’t made it into general support (<a href="https://caniuse.com/#feat=css-has">or <em>any</em> support</a>, for that matter) so it might be some time before we can use this for CSS injection exploitation. It’s definitely something to look out for, though!</p><h3>Closing Remarks</h3><p>That’s it for this month’s article. The next article will be either about an event I’m about to participate in at the start of August, or a phishing trick that I (re?)discovered via the macOS Mail Client.</p><p>Speaking of events and August, I’ll be in Vegas from August 6th to 13th. I’ll be around at various events during then but if you’re interested, I’d love to meet up :)</p><p>See ya next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e999f63097d" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/exfiltration-via-css-injection-4e999f63097d">Exfiltration via CSS Injection</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>