<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Adam</title>
    <description>The latest articles on Forem by Adam (@snowmac).</description>
    <link>https://forem.com/snowmac</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F462342%2F4cf5ace9-73d6-48fa-9bab-2e90a7bcb752.png</url>
      <title>Forem: Adam</title>
      <link>https://forem.com/snowmac</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/snowmac"/>
    <language>en</language>
    <item>
      <title>I used to be fat</title>
      <dc:creator>Adam</dc:creator>
      <pubDate>Sat, 12 Dec 2020 20:03:48 +0000</pubDate>
      <link>https://forem.com/snowmac/i-used-to-be-fat-21pi</link>
      <guid>https://forem.com/snowmac/i-used-to-be-fat-21pi</guid>
      <description>&lt;p&gt;&lt;a href="http://www.adambourg.com/fat/lifestyle/health/fitness/potato-diet/2020/12/12/I-used-to-be-fat.html"&gt;Originally posted on my blog&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Oh man, 2 weeks ago, I started on this journey, the great potato famine. I wasn't going to tell anyone, but I quickly let that go and made it to the front page of the Hacker News. I posted "I am not fat", and oh boy people were mean. Some people listened and I even got new Linkedin connections because people are curious or excited about what I'm doing. Today, I'm going to share my results, talk about what's next and address some of the common feedback. &lt;/p&gt;

&lt;h1&gt;
  
  
  Feedback
&lt;/h1&gt;

&lt;p&gt;There was a lot of comments, I learned that only about 10% of people read the entire article before posting about it. This shouldn't surprise me, but most of the most hateful and mean comments were from this group of people. &lt;/p&gt;

&lt;h2&gt;
  
  
  Extreme diets don't work
&lt;/h2&gt;

&lt;p&gt;Well, they do work. The problem isn't their effectiveness, the problem is people don't stick to extreme diets. They do it for a goal or an event, then once they go to the wedding or hot date or whatever, they go back to their old ways of life. The problem isn't just the diet, but their lifestyle. But for those that were like 'he's going extreme, he's an idiot and should do keto.', I don't care. Meh. If you read the post you'd understand, the potato diet was a RESET, like a fast. &lt;/p&gt;

&lt;h2&gt;
  
  
  Keto is better, stop eating carbs
&lt;/h2&gt;

&lt;p&gt;I got a variant of this several times. Dr Joel Fuhrman, author of the Nutritarian Diet goes into a lot of detail of why Keto is really bad for you in his book &lt;a href="https://www.amazon.com/End-Dieting-How-Live-Life/dp/0062249339"&gt;The end of dieting&lt;/a&gt;. Here are a &lt;a href="https://www.mayoclinic.org/healthy-lifestyle/weight-loss/in-depth/low-carb-diet/art-20045831"&gt;few&lt;/a&gt; other &lt;a href="https://www.drfuhrman.com/elearning/blog/124/why-a-nutritarian-diet-is-superior-to-the-ketogenic-diet-in-the-fight-against-cancer"&gt;examples&lt;/a&gt;. &lt;a href="https://www.health.com/weight-loss/keto-diet-side-effects"&gt;Ketoacidosis&lt;/a&gt; is a risk of the keto diet. &lt;/p&gt;

&lt;p&gt;The biggest why I'm agianst Keto is my doctor told me that it would likely harm my kidneys and liver, while increasing my risks for heart disease. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why don't you eat like a normal person, eat less then 2000 calories and exercise
&lt;/h2&gt;

&lt;p&gt;Because I AM A FAT GUY. My relationship with food is garbage. Moderation has ALWAYS been a challenge. I need an extreme intervention, it's either change my life style or get some kind of gastric sleeve. NO WAY. I do not want surgery for a LIFESTYLE change. If I eat like a NORMAL person, IE, STANDARD AMERICAN DIET, I'm going to get fatter. I have to change my relationship with food. &lt;/p&gt;

&lt;p&gt;I've done low carb, slow carb, jucing, whole 30, paleo... the problem is not the diet, the problem is me. I'm sick and tired of being sick and tired. I'm not interested in eating like a normal person. Yes, I will eat 2000 calories or less, but eating like an American is killing me. I have a dozen plus medical issues, mainly from the fact I eat like an AMERICAN. &lt;/p&gt;

&lt;p&gt;So, no more SAD, Standard American Diet. Cheeseburgers without buns aren't health food, a small French fry is still bad for you and a tall skinny latte from Starbucks will still make you fat. &lt;/p&gt;

&lt;h2&gt;
  
  
  Plant Based isn't healthy, what about xyz thing?
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Protein&lt;/em&gt;: Where do cows get their protein?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fats&lt;/em&gt;: No diary? Where will you get your fats? Avocados? Nuts? no, not in weight loss phase. Fat you eat becomes fat you wear. Plus, we're the only species on the entire planet that eat another animal's milk in its diet. We have like 9 different sources of milk, which gives us things like butter, cheese and heart disease. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Omega 3's&lt;/em&gt;: Salmon and all fish actually get the omega 3s from algae. They're loaded with omega 3s because algae are a stable in their diet. I'm allergic to ALL fish anyways. So, if I eat a fish, I'll die. No dice for me. Chia seeds, &lt;a href="https://juicedr.org/chia-seeds-fish-oil-better-source-omega-3/"&gt;gram for gram&lt;/a&gt;, have 8x more omega 3s then salmon. There's a catch, Chia's omega 3s are ALA while Salmon is mostly DHA. Our bodies are less efficent at converting ALA to EPA to DHA, which is what we need. You can also get an &lt;a href="https://www.healthline.com/nutrition/algae-oil#nutrition"&gt;algea supplement&lt;/a&gt; to get enough EPA and DHA in your diet. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cheese? Or Yogurt? Or Milk?&lt;/em&gt;: Cheese, yogurt and milk are not health foods. Yeah, whole foods does sell them, but they aren't healthy. It's unnatural to get milk after about 2 years old. We're againt the only species on earth that drinks the milk of other animals. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;What are you going to eat?&lt;/em&gt; Plants. Whole food, plant-based diet. Lots of veggies, beans, legumes, rice and fruit. Minimally processed, ideally if it's in a box on the shelf, it's not going in my belly. &lt;/p&gt;

&lt;h1&gt;
  
  
  Results
&lt;/h1&gt;

&lt;p&gt;I've been losing weight since November 20, 2020. About 22 days into the weightloss journey, and I've lost 27 pounds. A little more than a pound a day. I need to take after pictures, but I'm also not done. 27 pounds is 27% towards my goal. I did lose a few pounds before I started the potato diet, but not much. Most of the 27 was from eating potatoes. &lt;/p&gt;

&lt;h1&gt;
  
  
  Potato diet take away
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Microwaving potatoes sucks because it dries them out. &lt;/li&gt;
&lt;li&gt;Crock pot potatoes are good, throw in some pepper, salt, rosemary, onion and garlic for flavor and you won't get enough of the potatoes. &lt;/li&gt;
&lt;li&gt;Potatoes are boring but doing point 2 will make them so much better. &lt;/li&gt;
&lt;li&gt;Drinking black coffee, eating potatoes and drinking tons of water helps you lose weight.&lt;/li&gt;
&lt;li&gt;Fasting became easier once I started potatoes. I went 3 days (not in a row) wihtout any food until dinner. &lt;/li&gt;
&lt;li&gt;My only "cheat" was the small bag of sweet potato chips from Starbucks when I forgot to eat until 3 pm. &lt;/li&gt;
&lt;li&gt;Its normal not to lose weight for a day or two. &lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  What's next
&lt;/h1&gt;

&lt;p&gt;Whole food, plant-based diet. Basically, I'm taking recipes from &lt;a href="https://www.forksoverknives.com/how-tos/plant-based-primer-beginners-guide-starting-plant-based-diet/"&gt;Forks Over Knives&lt;/a&gt;, &lt;a href="https://www.drfuhrman.com/get-started/quick-start"&gt;nutritarian diet&lt;/a&gt;, &lt;a href="https://healthspansolution.com"&gt;The Healthspan Solution&lt;/a&gt;, &lt;a href="https://happyherbivore.com"&gt;Happy Herbie&lt;/a&gt; and &lt;a href="https://www.doctorklaper.com/about"&gt;Dr. Klaper&lt;/a&gt; to form the basis of my new WFPB (Whole Food, Plant Based) diet. &lt;/p&gt;

&lt;p&gt;Things that I'll be eating, include but not limited to: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every veggie you can think of, including potatoes, carrots, green beans, lettuce, spinach, celery etc... &lt;/li&gt;
&lt;li&gt;All fruit, oranges, blue berries, apples, dates; less of this as it can harm weight loss&lt;/li&gt;
&lt;li&gt;Grains like Oats, Rice or Quinoa&lt;/li&gt;
&lt;li&gt;Beans, legumes etc...&lt;/li&gt;
&lt;li&gt;Lots of spices&lt;/li&gt;
&lt;li&gt;Heavy on the Indian, Mexican and light on the American style of eating &lt;/li&gt;
&lt;li&gt;Some seeds, chia and flax&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Things I won't be eating: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nuts (allergy)&lt;/li&gt;
&lt;li&gt;Meat&lt;/li&gt;
&lt;li&gt;Cheese&lt;/li&gt;
&lt;li&gt;Fish&lt;/li&gt;
&lt;li&gt;Crackers&lt;/li&gt;
&lt;li&gt;Things that come out of a box&lt;/li&gt;
&lt;li&gt;Corn, peas and other irritants (these aren't bad, just my body doesn't like them)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I decided to take a technique I learned listening to a podcast; basically, compile a list of all the foods I eat. Then I rotate through this list of 15-20 items to have variety in your diet. I did this before I started this because it was hard to come up with new meal ideas every week. Well, using this approach, I now do it for the Veggie dishes I plan to make. I also plan to go through all my cookbooks and look at the sides as most are vegiterian if not vegan. &lt;/p&gt;

&lt;p&gt;So here's what's on my list for things to eat, mostly for dinners. For breakfast I eat oats, quinoa or nothing, lunch will be soup or salad and here's my dinner options: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://minimalistbaker.com/sweet-potato-coconut-curry-soup/"&gt;Sweet Potato &amp;amp; Curry Soup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.straightupfood.com/blog/2020/10/05/wild-rice-mushroom-soup/"&gt;Wild Rice and Mushroom Soup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://veganhuggs.com/creamy-vegan-potato-leek-soup/"&gt;Creamy Vegan Potato Leek Soup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mykitchenlove.com/hasselback-butternut-squash/"&gt;HASSELBACK BUTTERNUT SQUASH&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://veganhuggs.com/vegan-french-onion-soup/"&gt;Vegan French Onion Soup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://laurencariscooks.com/roasted-garlic-leek-soup/"&gt;Roasted Garlic and Leek Soup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://laurencariscooks.com/mushroom-lentil-soup-miso/"&gt;Mushroom and Lentil Soup with Miso&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.forksoverknives.com/recipes/vegan-soups-stews/lentil-vegetable-soup/"&gt;Lentil Vegetable Soup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.forksoverknives.com/recipes/vegan-soups-stews/8-ingredient-slow-cooker-chili/"&gt;8-Ingredient Slow Cooker Chili&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.forksoverknives.com/recipes/vegan-salads-sides/zucchini-and-chickpea-saute/"&gt;Italian-Style Zucchini and Chickpea Sauté&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://simple-veganista.com/chickpea-tikka-masala/"&gt;Chickpea Tikka Masala&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://simple-veganista.com/greek-chickpea-quinoa-salad/"&gt;GREEK QUINOA SALAD&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://simple-veganista.com/vegan-burrito/#tasty-recipes-38209"&gt;VEGAN BURRITO&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://simple-veganista.com/mushroom-bourguignon_10/"&gt;MUSHROOM BOURGUIGNON&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://simple-veganista.com/mexican-hot-chocolate/"&gt;MEXICAN HOT CHOCOLATE&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://simple-veganista.com/quinoa-stuffed-bell-peppers/"&gt;QUINOA STUFFED PEPPERS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://simple-veganista.com/red-hot-miso-noodle-bow/"&gt;RED HOT MISO NOODLE BOWL&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'll keep you posted until then I'm going eat more plants because c'est la vie. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.adambourg.com/fat/lifestyle/health/fitness/potato-diet/2020/12/12/I-used-to-be-fat.html"&gt;Originally posted on my blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>lifestyle</category>
      <category>health</category>
    </item>
    <item>
      <title>Can I really be an engineer?</title>
      <dc:creator>Adam</dc:creator>
      <pubDate>Fri, 18 Sep 2020 18:48:22 +0000</pubDate>
      <link>https://forem.com/snowmac/can-i-really-be-an-engineer-2d61</link>
      <guid>https://forem.com/snowmac/can-i-really-be-an-engineer-2d61</guid>
      <description>&lt;p&gt;A friend of mine recently got in touch with me, I was catching up with him and we were talking about our lives and careers. He's struggling to make a living without much clear direction, I suggested he should become an engineer because the starting salaries are really good and you can build cool stuff. He's a creative so it makes a lot of sense. &lt;/p&gt;

&lt;p&gt;He posed the above question to me. I answered, with a question:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Suppose Santiago was a shepherd. 
He sold a bunch of his sheep to his friend, then he sold, 10% of his flock, 6 sheep to a merchant in town. 
He took the proceeds to travel a journey to find a lost treasure near the pyramids of Egypt. 
How many sheep did he have in his whole flock?
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Yes, that is Santiago from the Alchemist. This is a basic word problem, to solve it, you need to use basic Algebra.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Y is the size of the flock,
y * .1 = 6

X is the number of sheep he sold to his friend
y - 6 = x 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Y is the flock size, .1 is 10% in decimal form and 6 are the number of sheep that Santiago already has. It becomes a simple problem from here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;y * .1 = 6
(y * .1)/.1 = 6/.1
y = 6/.1
y = 60

His flock was 60 sheep

y - 6 = x
60-6 = x
54 = x 

He sold 54 sheep to his friend
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I told him, if you can solve that problem, you can be an engineer. Why?&lt;/p&gt;

&lt;h1&gt;
  
  
  Why can you be an software engineer?
&lt;/h1&gt;

&lt;p&gt;I argue that if you can solve the above problem you have the basic skills to move from joe plumber to joe programmer. Here's why: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Solving word problems are a lot like solving real business problems. You need to analyze the problem and determine some kind of out come. It's logical, step by step, algorithmic thinking. &lt;/li&gt;
&lt;li&gt;"Coding" is only one part of the job, sure for some people it's 80-100% of the job, but it's not the only thing. Back when I was doing "Agile" scrum development, I would routinely spend 2-3 hours a day in meetings. I wasn't even in management. Often times, developers spend a part of their time: reviewing requirements, asking for clarification, writing tests, arguing with QA and writing some code. &lt;/li&gt;
&lt;li&gt;Reading comprehension is vitally important. If you can solve the above problem it shows that you understand the problem and know how to translate it into a solution. Reading is important and often overlooked by many developers. I can't count the number of times a senior colleague came to me when the answer was easily explained in the documentation!&lt;/li&gt;
&lt;li&gt;You spend most of your day reading code, trying things and debugging, more then you will (normally, unless it's a new product) writing a bunch of new code. Thingy X has to work with Thingy Y and can't break feature A or B while using C. That sort of thing. &lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  What are the basic competencies a developer needs?
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Ability to read, understand requirements and work with a team to build those things. &lt;/li&gt;
&lt;li&gt;Ability to work on a team and with other people. &lt;/li&gt;
&lt;li&gt;Ability to program in 1 language, ideally several. &lt;/li&gt;
&lt;li&gt;Ability to think logically. &lt;/li&gt;
&lt;li&gt;Ability and desire to learn &amp;amp; grow&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you have the desire to learn and grow, the ability to read and work with other people and finally knowledge of at least 1 language; probably would be good to know a framework too. Then you can become a professional software engineer. &lt;/p&gt;

&lt;p&gt;You probably won't be building software systems to shoot rockets into outer space, or solving biomedical research issues; you'll probably join the corporate rank and file building next generation APIs, data storage and learning all the buzz words of your new industry. You can make a lot of money and you can have a lot of fun doing it. &lt;/p&gt;

&lt;p&gt;Originally &lt;a href="http://www.adambourg.com/engineer/starting-out/development/2020/09/16/Can-I-really-be-an-engineer.html"&gt;posted on my blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>basics</category>
      <category>junior</category>
      <category>math</category>
    </item>
    <item>
      <title>Linkedin Book for Developers</title>
      <dc:creator>Adam</dc:creator>
      <pubDate>Thu, 03 Sep 2020 05:40:04 +0000</pubDate>
      <link>https://forem.com/snowmac/linkedin-book-for-developers-268k</link>
      <guid>https://forem.com/snowmac/linkedin-book-for-developers-268k</guid>
      <description>&lt;p&gt;July 30, that is the last day you posted. Now 3 posts in 3 days? What is going on MAN? Glad you asked, rather I asked it for you. August was a whirlwind of things: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Forming a new business &lt;/li&gt;
&lt;li&gt;Parenting a now 13 month old (who ALWAYS wants Dada's attention)&lt;/li&gt;
&lt;li&gt;Working&lt;/li&gt;
&lt;li&gt;Car issues ($4k of issues: AC went out, timing belt, motor mounts ... other general maintence build up; no I don't do my own AC or timing)&lt;/li&gt;
&lt;li&gt;Wife going back to work (teacher; to germ factories!!!)&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  BUT WAIT THERES MORE
&lt;/h1&gt;

&lt;p&gt;On top of all of that, I'm working on a book... Sort of. I've written 3 rough chapter drafts to 12 or more chapter manuscript. Basically, recruiters, new recruiters, boom camp grads and all kinds of people want to pick deal ole Adam's brain about the industry, working with developers and getting hired. Well, other then a bunch of ear wax and guesses, there isn't much up there but people always find something valuable out of me. I like helping people, so I decided to write an E-book. &lt;/p&gt;

&lt;p&gt;This is the 3rd book I've "decided to write". The first one was going to be a fiction about a chemist who decides to turn his lab into a meth production facility then use the dark web to sell and get rich. Dead drops and bit coins, all that fun stuff. Lets just say, I watched a bit to much breaking bad and listened to many crime novels while I was working on that idea. I wrote an introduction / high level plot. My wife thought it sounded crazy... and out there...&lt;/p&gt;

&lt;p&gt;My second idea was about a criminal with a badass car, not the bat mobile, but basically a highspeed chase through the city of Denver. It might be able to shape shift, I'm not really sure. I had written about a chapter on this one too.&lt;/p&gt;

&lt;p&gt;Why do I want to write books? Well, I read about 1-3 a week of fiction and I love the spy, crime, techno thriller genre so why not? Never mind I do not have any experience writing fiction and I do not like writing poems or short stories. I do however love blogging. &lt;/p&gt;

&lt;p&gt;Why a non fiction? Two reasons: Share knowledge and add something to the resume. I mean if you self publish a 200 page guide on Linkedin, well buddy that shows inititave. It sells a brand man, it sells Adam Bourg as a go gitter, someone serious about his craft and passionate about it to talk to anyone about it. So passionate he'll waste months working on a book that might only sell a few copies. &lt;/p&gt;

&lt;h1&gt;
  
  
  My book
&lt;/h1&gt;

&lt;p&gt;It's flushed out, I have a mind map for it. Basically its a linkedin marketing book for developers. It'll have recruiter interviews, linkedin profile configurations, tips &amp;amp; tricks, how to get noticed, how to build a network etc... It comes from the perspective of nearly every job I've gotten in the last 10 years has come from my contacts on Linkedin, new and old. How to leverage the platform to get the results you want from your career. &lt;/p&gt;

&lt;p&gt;The goal is an early January release, but I'm a software engineer and you know how most of us are with estimation and deadlines. &lt;/p&gt;

&lt;p&gt;Please let me know if you'd review it and read it. &lt;/p&gt;

&lt;p&gt;Loading…&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Let's stop being stupid about security</title>
      <dc:creator>Adam</dc:creator>
      <pubDate>Wed, 02 Sep 2020 17:03:04 +0000</pubDate>
      <link>https://forem.com/snowmac/let-s-stop-being-stupid-about-security-4ne8</link>
      <guid>https://forem.com/snowmac/let-s-stop-being-stupid-about-security-4ne8</guid>
      <description>&lt;p&gt;I hate it when I run across what is reported to be an epic hack involving Russians, Chinese or spies only it turns out the hacking victims were not taking any form of basic security seriously. Its like asking Bonnie and Clyde to rob a bank where the combo is printed on a large banner outside the vault and there are no keys to any safe deposit boxes. Or it's like letting the fox get inside the hen house. &lt;/p&gt;

&lt;p&gt;Unfortunately the victims in this case seem to be the US Government. The article is titled: &lt;a href="https://abc7chicago.com/russia-russian-hacking-elections-illinois/3778816/"&gt;"How the Russians penetrated Illinois election computers - ABC7 Chicago"&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What was the hack? SQL injection. SQL INJECTION!!@!@!! What the #$%@? Are we living in the 90s? What the heck are developers doing? Sadly, I've encountered the problem on projects I've worked on within the last YEAR. WTF is wrong with people? Are we lazy or stupid or a bit of both? &lt;/p&gt;

&lt;h1&gt;
  
  
  Let me educate you on SQL Injection
&lt;/h1&gt;

&lt;p&gt;Here's an innocent query; let's say we're using Postgres and NodeJS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lastName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="k"&gt;From&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;"adam@adambourg.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Not bad, but lets see how we can build it in Javascript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;lookupUserByEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;emailAddress&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;emailAddress&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Email address is required!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`SELECT firstName, lastName, email From users where email = "&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;emailAddress&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There is a simple method to ensuring we have an email and fetching a user record from the database. The trouble is, we're doing string interpolation, meaning we take that query and inject ANYTHING from the emailAddress variable. No big deal, right? &lt;/p&gt;

&lt;p&gt;What if email address is this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;OR&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That means it would match on the first value, 1, which probably won't match anything or on 1=1 which is literally interpreted by SQL as does 1 equal 1? Which is always true. Thus would return EVERY record in the system. &lt;/p&gt;

&lt;h1&gt;
  
  
  How could someone use SQL Injection to do harm?
&lt;/h1&gt;

&lt;p&gt;Assume the hacker has no knowledge of the system and does this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;or&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now I've got a list of all the records in the table; great, what if I want to know what options are present in the system? Well, do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="s1"&gt;'; SELECT c.relname FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN (‘r’,”) AND n.nspname NOT IN (‘pg_catalog’, ‘pg_toast’) AND pg_catalog.pg_table_is_visible(c.oid); 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Version?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="s1"&gt;'; SELECT version();
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Postgres users?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="s1"&gt;'; SELECT usename FROM pg_user;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Users and password hashes? No problem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="s1"&gt;'; SELECT usename, passwd FROM pg_shadow — priv;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here's the thing if you don't sanitize your inputs, you are venerable to so many easy hacks. In fact there are &lt;a href="http://pentestmonkey.net/cheat-sheet/sql-injection/postgres-sql-injection-cheat-sheet"&gt;many&lt;/a&gt;, &lt;a href="http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet"&gt;dozens&lt;/a&gt; of &lt;a href="https://portswigger.net/web-security/sql-injection/examining-the-database"&gt;different&lt;/a&gt; &lt;a href="https://www.netsparker.com/blog/web-security/sql-injection-cheat-sheet/"&gt;guides&lt;/a&gt; on &lt;a href="https://www.sqlinjection.net/table-names/"&gt;any&lt;/a&gt; and &lt;a href="https://download.oracle.com/oll/tutorials/SQLInjection/index.htm"&gt;all&lt;/a&gt; &lt;a href="https://www.blackhat.com/presentations/bh-usa-05/bh-us-05-fayo.pdf"&gt;versions&lt;/a&gt; of &lt;a href="https://docs.microsoft.com/en-us/sql/relational-databases/security/sql-injection?view=sql-server-ver15"&gt;SQL&lt;/a&gt;. &lt;/p&gt;

&lt;h1&gt;
  
  
  How do I protect myself?
&lt;/h1&gt;

&lt;p&gt;Unlike the idiots in Chicago, buying an expensive Cisco Firewall will not do anything to protect you. In fact, it will only cause you to feel more secure thus take more risks. No what you need is real security. Basic security. It's like putting a lock on your door type of security. &lt;/p&gt;

&lt;h1&gt;
  
  
  Enter Parameterized Queries AKA "Prepared statements"
&lt;/h1&gt;

&lt;p&gt;Just about every SQL library supports Parameterized Queries. If they don't you need to find a new lib to use. &lt;/p&gt;

&lt;p&gt;Example in PQ: &lt;/p&gt;

&lt;p&gt;Given our example from above, here's what a safe query would look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;lookupUserByEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;emailAddress&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;emailAddress&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Email address is required!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`SELECT firstName, lastName, email From users where email = "$emailAddress"`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;emailAddress&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Well, that was simple! Basically $ with out the brackets are treated as a normal string, you can keep the string template literal (the back ticks) or use quotes instead; then you're dumping email address into an object that gets passed to the db's any method which does all the work. &lt;/p&gt;

&lt;p&gt;This works:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;lookupUserByEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;adam@adambourg.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This does not work as the hacker expected:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;lookupUserByEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1 or 1=1;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Prepared statements examples
&lt;/h1&gt;

&lt;p&gt;A few examples of the method body in other languages using this safe method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$stmt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$dbh&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT firstName, lastName, email From users where email = (?)"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;bindParam&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$email&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;sqlQuery&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"SELECT firstName, lastName, email From users where email = (?)"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nc"&gt;PreparedStatement&lt;/span&gt; &lt;span class="n"&gt;prepStmt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;conn&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;prepareStatement&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sqlQuery&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;prepStmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"adam@adambourg.com"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;prepStmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;executeUpdate&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="n"&gt;prepStmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;close&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h1&gt;
  
  
  Does your ORM support prepared statements?
&lt;/h1&gt;

&lt;p&gt;Active Record does right out of the box; it's automatic, similar for Sequelize. Should you turn it off, like this &lt;a href="https://medium.com/@devinburnette/be-prepared-7768d1a111e1"&gt;idiot says&lt;/a&gt;? Hell NO!&lt;/p&gt;

&lt;h1&gt;
  
  
  Further reading
&lt;/h1&gt;

&lt;p&gt;If you want to dive more into this topic, &lt;a href="https://www.w3schools.com/sql/sql_injection.asp"&gt;W3 Schools&lt;/a&gt; has a really good guide to injections. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.adambourg.com/security/sql/2020/07/26/Lets-stop-being-stupid-about-security.html"&gt;Originally posted on my blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>sql</category>
      <category>injection</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
