Thursday, January 8, 2015

Assignment 2 - Recent Vulnerability

Today I'll discuss Shellshock, or CVE-2014-6271. This is a vulnerability that affected my installation of Cygwin as well as my Arch Linux virtual machine, and potentially affected any Unix system running Bash. A Bash installation can be tested with a simple one-liner:
env x='() { :;}; echo vulnerable' bash -c "echo this is a test"
http://en.wikipedia.org/wiki/Shellshock_%28software_bug%29#Initial_report_.28CVE-2014-6271.29

This vulnerability has potentially existed for decades, but was discovered in September of 2014. It works by essentially confusing the Bash parser into executing more code than it should. An attacker can set an environment variable to be a function, but then append more code after the function that in theory should not be executed or should result in an error.

In the example above, Bash interprets x as an exported function definition. It thinks that somebody defined

x = () { ...

which would then be stored as an environment variable

env x = '() { ...

When a new Bash instance starts, it executes any environment variables in that format, as they are supposed to be exported function definitions. At this point, a vulnerable version of Bash does not check whether x is actually a valid function, but instead executes the entire line regardless, which might contain malicious code of some kind. In the test above, the "malicious code" is simply echo vulnerable. So, if an attacker is able to arbitrarily set the contents of some environment variable on your system, then they are capable of executing arbitrary code.

There were several other related vulnerabilities that were soon discovered after this one was ostensibly patched, but all relate to faulty handling of exported function definitions in environment variables.

Assignment 1 - Laptop Charger

Let's take a look at the charger for my Lenovo Y580. The specs are listed on the charger itself:
The ADP-120LH B charger
From here we can see it outputs 19.5 V at 6.15 A. Ohm's Law, V=IR, gives us approximately 3.17 ohms of resistance.

Multiplying voltage and current, we get 199.93 W of power, or .19993 kW.

BGE tells us the maximum I'll pay for an hour of electricity at this time of year is 11.924 cents per kWh. Multiplying power by price shows that I'm paying a maximum of 2.384 cents for every hour my laptop is plugged in.