Application Security Weekly for April 15

The Verizon Data Breach Investigations Report is out. It's a good read.

https://www.verizonenterprise.com/verizon-insights-lab/dbir/

 

DARPA (the government organization that created the Internet) is funding research into Human Assisted AI. 

https://www.schneier.com/blog/archives/2018/04/darpa_funding_i.html

 

WebAuthN went to Candidate stage, perhaps leading to the end of passwords on the Internet.  But ... universal federal IDs?  Not sure.

https://arstechnica.com/gadgets/2018/04/practical-passwordless-authentication-comes-a-step-closer-with-webauthn/

 

Motherboard has a REALLY good series on phone cracking.  If you are into mobile, it's worth a look.

https://motherboard.vice.com/en_us/topic/phone-crackers

 

And that's the news

 

Some neat events I'll be participating in this spring

There are some neat developer and security events this spring that I'll be speaking at or otherwise participating in, and I'd love to see all of you there!

On the morning of the 18th, I'll be talking about updated OWASP Projects at the Columbus ISSA meeting.  I know daytime meetings are weird, but come by if you can. There is a small charge for non-members.  https://www.centralohioissa.org/

April 26th, there is an OWASP meetup where we will be following up on Jason Kent's Docker seminar and building some cool python code. This event is at the Idea Foundry, and is a lab environment - bring your machine. I'll get everyone started, but this is mostly team coding. https://www.meetup.com/Columbus-OWASP/

In May, on the 4th, I'll be speaking about the changes to the OWASP Top 10 at Stir Trek, one of the most awesome developer events in the midwest. The content is awesome, the venue is a movie theater, and you get to watch the new Avengers movie the night before the rest of the world! NO SPOILERS. https://stirtrek.com/

May 14th, I have the honor of speaking at one of the most awesome security events in the midwest (I told you this was quite a spring!) It's the Central Ohio InfoSec Summit, and the content is also awesome, although there isn't a movie at the end. If you can go, do so.  It's really a great conference. https://www.infosecsummit.com/

Gonna be a bust few months, but some really great events.  Make sure you catch what you can - attending these events is one of the best ways to stretch your mind and see what skills you should be working on right now.

Application Security Weekly for April 8

(Yes, last week was indeed an April Fools' joke)

(This week isn't.)

 

Domain names are a blessing and a curse.  It's a lot easier to remember "sempf.net" than "168.62.224.13".  The domain registration system is also on the front lines of fighting spam and malware - and it is under attack by the Powers That Be.  Overreaching privacy law is about to make blue teaming a lot harder.

https://krebsonsecurity.com/2018/03/who-is-afraid-of-more-spams-and-scams/

 

Twitter thread regarding Tmobile Austria storing passwords in plain text. Warning: rough language

https://twitter.com/c_pellegrino/status/981409466242486272

https://motherboard.vice.com/en_us/article/7xdeby/t-mobile-stores-part-of-customers-passwords-in-plaintext-says-it-has-amazingly-good-security?utm_campaign=sharebutton

So, if they store the WHOLE password salted and hashed, but keep the first 4 characters in plain text just to help customer service, it is still a vulnerability?

 

Three Vulnerabilities Discovered in Spring Development Framework. Patchy patchy.

https://t.co/ytHgTw59LU

Critical — RCE Attack (CVE-2018-1270)
High — Directory Traversal Attack (CVE-2018-1271)
Low — Multipart Content Pollution (CVE-2018-1272) https://t.co/3UQj3iD3qO

 

Normally I link to primary sources, but El Reg did such a good job writing up the trustwave report I want to link to them.  Good, tongue-in-cheek breakdown of the TRustwave report, which is pretty ugly (Spoiler: criminals are getting better, and we are not catching up).  Link to the report at the end of the article - there will be a quiz.

https://www.theregister.co.uk/AMP/2018/04/05/trustwave_security_sitrep/

 

And that's the news

Proxy Fiddler Through Burp

I am testing an application that only works on Internet Explorer in compatibility mode.  Before you laugh, it's is EXACTLY these legacy applications that get us into trouble, and they should be tested regularly, and they can be secured using compensating controls.  However, I am on the client's computer, which has enterprise controls on the proxy, which means I can't easily configure IE to use Burp because it uses the system proxy.

Fiddler, however, traps WinINET so it will see the traffic from IE, even with the proxy set to the corporate settings.  Fiddler is only an average-at-best security testing tool though, so I would like to use Burp too. The solution is to chain the proxies, and all of the instructions I am reading online are out of date. Because of this I thought I would add to the corpus because it is quite simple these days.

First it is important to know that Burp Suite listens on localhost, port 8080.  This is what you need to set your browser to in order to have the requests and responses filtered through Burp. We can leave these settings as default.

Fiddler's proxy is localhost, 8888, but that doesn't matter on Windows.  Since it listens on the network channel, we don't have to do anything - Fiddler "Just Works (tm)." You can leave these settings default as well.

The "Gateway" tab in the Options dialog has settings to proxy Fiddler outbound.  It will probably be set to System settings, as it should, but we are going to change that for this exercise.  Just like you would normally do in Chrome, set the proxy to manual, and set the values to localhost, 8080.  (Remember 127.0.0.1 is localhost)

That's it! Now every request and response will go through Fiddler and Burp.  Note that some of your enterprise applications might notice the proxy change and stop working, but at least you can get through your test.  Happy hacking!

Application Security Weekly for April 1

Chinese cell phone manufacturer OnePlus (incidentally my daily carry) plans on including cryptocurrency mining baked into their next release of Oxygen in the OnePlus 6, sparking security concerns.

https://youtu.be/Lj9DcBeer14

 

The IETF floated a new analog protocol for internet traffic in an attempt to get some more security in the system.

https://tools.ietf.org/html/rfc1149

 

 I don't often talk biotech here, but Razer (the gaming hardware maker) is creating a nanobot infused energy drink for gamers.  I am sure that will go well.

https://www.razer.com/campaigns/project-venom-v2

 

Finally some good news - plans to add a security parameter in response headers.  Should be a good move toward better browser level decision making.

https://tools.ietf.org/html/rfc3514

 

And that's been your week in application security.

Application Security Weekly for March 25

HSTS tracking beats even incognito mode in browsers, and it more and more often used by advertisers.  In the most recent edition of OSX, Safari has two mitigations in place for this issue.  Let's hope other browsers follow suit shortly.

https://thehackernews.com/2018/03/hsts-supercookie-tracking.html

 

Here's a really good writeup by as researcher that discovered an XML External Entity vulnerability in Windows Remote Assistance.

https://krbtgt.pw/windows-remote-assistance-xxe-vulnerability/

 

Dropbox and Netflix join the growing group of large technology organizations promising not to sue white hat security researchers.

https://www.theregister.co.uk/AMP/2018/03/22/netflix_bounty_dropbox_promise/

 

Here's another application vulnerability analysis procedure, well written and organized.

https://jdow.io/blog/2018/03/18/web-application-penetration-testing-methodology/

A new blog series: Application Security Weekly

No, I haven't given up on my OTHER blog series about application vulnerability assessment but an opportunity opened up to start publishing my client newsletter on my blog.  It's just usually four stories about appsec that I think are particularly important this week.  Not even a lot of commentary, but if you only have so much time to absorb appsec news, then this could be a great way to fit some news in.

Enough chatting, this weeks stories:

 

Any authenticated user on a Samba 4 Active Directory can change any other users' password via LDAP.  A patch is available.

https://www.theregister.co.uk/2018/03/14/samba_password_bug/

 

Ass we all surmised, there was an app that leveraged Open Graph to download profiles from Facebook for the purposes of crafting the election advertising.

https://www.theguardian.com/news/2018/mar/17/cambridge-analytica-facebook-influence-us-election

I spend a lot of time talking about the Facebook Open Graph, here I am three years ago at Cleveland BSides:

https://www.youtube.com/watch?v=Ze9Pzb1KSFw&feature=youtu.be&t=12m26s

 

Abusing Certificate Transparency logs to get subdomains from an HTTPS website:

https://github.com/UnaPibaGeek/ctfr

 

A nice primer on breaking encryption from MalwareBytes:

https://blog.malwarebytes.com/threat-analysis/2018/03/encryption-101-how-to-break-encryption/

 

Happy hunting!

Live Webinar: Come talk Application Vulnerability Analysis with me and WintellectNOW

I'll be doing a live webinar on Application Vulnerability Analysis on February 8 at 2PM EST - 1 month from today - and it will be a lot of fun! You can hang out in the afternoon and hack some stuff, at least the east coast folks.  West coast people can start their afternoon early.  Europe - you are on your own.  India - you should be sleeping.

Here is the link:

https://www.wintellect.com/webinar/check-security-digging-application-vulnerability-analysis/

We'll talk about a few principles and then work through using an attack proxy to look for insecure direct object references, forced browsing, injection vulnerabilities, and whatever else comes to mind.

Thanks to WintellectNOW for having me on.

Hop to see you there!

Day 6 of C# Advent - Coding for an encrypted service

Welcome to the 6th day of the C# Advent! Let's encrypt some malware.

That sounds horrible, but in security testing, sometimes you have to use the tools of the bad guy to make sure you aren't likely to be susceptible to any attacks. There are many such tools, but a new one - one that takes instructions from an HTTP web server - was developed by Dave Kennedy of TrustedSec. Called TrevorC2, it is a Python Command and Control server with a variety of clients.  The attacker would install the client on the target workstation, and have a server delivering commands.  In this case, it is over HTTP.  And one of the clients is in C#.  And encrypted in AES.

Wait, what?  AES?  Really?  

Yes, really.  Companies look for certain strings that are common in command and control servers moving across their networks.  So, the attackers encrypt things! How do we find it then?  Well, that's not our problem at the moment - we just need to figure out how to replicate what the bad guys are doing.  So, that's the task for this day of the C# Advent - implement AES in C# that will talk nice to a Python command an control server over HTTP.  

Fortunately, most of it I have written.  The communication bits in C# are pretty straightforward, but the encryption piece is not at all.  When I started, I wanted to use System.Security.Cryptography.Aes, but guess what?  It ain't that easy.  The Python client encryption method looks like this:

    def encrypt(self, raw):
        raw = self._pad(AESCipher.str_to_bytes(raw))
        iv = Random.new().read(AES.block_size)
        cipher = AES.new(self.key, AES.MODE_CBC, iv)
        return base64.b64encode(iv + cipher.encrypt(raw)).decode('utf-8')

 

My initial take was something like this for an encrypt method:

        static string Encrypt(string target)
        {
            byte[] result = null;
            try
            {
                if (target == null || target.Length <= 0)
                    throw new ArgumentNullException("plainText");

                using (Aes aesAlg = Aes.Create())
                {
                    aesAlg.Key = Cipher;
                    ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
                    using (MemoryStream msEncrypt = new MemoryStream())
                    {
                        using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                        {
                            using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
                            {
                                swEncrypt.Write(target);
                            }
                            result = msEncrypt.ToArray();
                        }
                    }
                }
            }
            catch(Exception e)
            {
                Console.Write(e.Message);
            }
            return Encoding.ASCII.GetString(result);
        }

That didn't work.  So, I did what any good senior developer would do.  I buckled down, focused, and looked for a library written by someone smarter than me. Fortunately, Adam Caudill is out there with libsodium.net, a C# implementation of the well known NaCl library. There's the solution I needed.

Libsodium.net is a living breathing example of how complicated encryption can be.  NaCl is a very well known implementation of the main encryption protocols ... in C.  Yeah, C.  You can use it in other languages but C is what NaCl is for.

The chem majors among us will recognize that NaCl is table salt.  Thus, Sodium.  Libsodium is a higher level library for C++ and ilk, and then Adam's implementation uses the .NET native libraries to perform the same tasks.  It's a reasonable legacy, and you should consider it if you have to write encryption code, as, well, I do right now.

Anyway, the interface is SUPER easy to use.  The SecretBox holds everything you need, including the abilityto generate the nonce required for the AES encryption, and to do the actual work.

So, my NEW method, after adding libsodium.net, looks like this:

        static string Encrypt(string target)
        {
            try
            {
                var nonce = SecretBox.GenerateNonce();
                var result = SecretBox.Create(target, nonce, Cipher);
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
            return Encoding.ASCII.GetString(result);
        }

Tune back in next week, after I get my Trevor server up and running, and we'll get everything configured and working. (Remember, play with malware on a network that is not your employer's network!) 

 

Reconnaissance

Reconnaissance means something different for pentesters as it does from vulnerability analysts.  It is, truthfully, the first obvious break between the two forms of testing.  For vulnerability analysts, reconnaissance means doing all of the research that is required to understand what one apps does, and how it works.  For pentesters, reconnaissance means doing the vulnerability analysis.  Remember, their job is to exploit the vulnerabilities.  Finding the vulnerabilities is part of the reconnaissance! For vulnerability analysts, though, we have to go a little deeper into research the application itself, in order to find every possibly vulnerability.

I have quite a list - reconnaissance usually takes me a whole day of the week long test.  I recommend not just running a scan - the idea is to get an idea of what the app does, and how well it does it.  If I can, I schedule a chat with the dev lead to talk about what the app should do, and then I write the application summary of the report after I have indexed the app.  But I am getting ahead of myself.

Beginning reconnaissance starts ahead of the application.  Usually when I start, I just have a URL and credentials, just like an attacker would (we'll assume he stole the credentials from a user, cause that's pretty easy).  The absolute first thing I want to do is look at the network and the server. Fortunately, there are two awesome free tools that will help you do this.

However, in order to do these, you will need an environment in which to do so.  If you read my earlier posts you will know that I like Windows 10 for testing - putting me at odds with most of the industry.  I do, however, acknowledge the weaknesses of the platform for some kinds of testing, and Perl and Python scripts are included in that.  Therefore, I usually use a Kali Linux VM for scripts, because nearly everything I use is preinstalled.  And there is a new tool on the horizon, PentestBox, which does everything in a modified command prompt right in Windows.  It's pretty slick.

Start with the network (for one thing, this will give you the IP of the server). Really, we will probably just "network scan" one machine, depending on your scope, but that's OK. The tool you want to use is nmap. It's a fantastic open source vulnerability scanner for the network surrounding the web server in question.  I got a favorite set of parameters from the awesome Jon Welborn, and I recommend it:

nmap -sS -Pn -v --script=default,vuln,safe -oA nameOfOutputFile IPofTarget

For the web server itself, there are a couple of options, and I still like Nikto.  I like Nikto because I have a custom ruleset for Nikto, and no you can't have it because it has client information in it.  That said, there are a LOT of other tools, and there is a very interesting and more updated tool for Windows (see my earlier posts for my thoughts on that) that might suit you better.  That said, Nikto is easy to run, and it does catch a lot of stuff, especially on older installs, and even kinda not that old installs.  It's still pretty slick.

nikto -host IPofTarget

Another part of recon is getting details about the encryption certificate being used to protect communicate with the browser.  If the site is public facing, I use Qualys's free SSL Test.  If the site is in an internal network, SSL Test can't see it, though, so you have to use another script.  My usual go-to is SSLScan, which is also super easy in either Kali or PentestBox.

SSLScan IPofTarget

OK, enough of running scripts.  Next I turn to my proxy.  There are two I use, Burp Suite and ZAP.  Burp Suite is a paid, closed source application with a company backing it, complete with researchers and devs and everything.  It is well supported and has lots and lots of features. ZAP is a free, open source application with a company backing it, complete with researchers and devs and everything.  It is well supported and has lots and lots of features. It's your call.  However, for whatever reason, if you are working for an organization with a standard vulnerability program, the results are expected to be turned in using Burp.  Otherwise, ZAP is a fantastic tool.

What we are going to do with the proxy is index the site.  This works differently in Burp and ZAP, so I am just going to talk generalities here.  First, with the proxy running, exercise the application completely.  Some folks like to make a separate file from the proxy for each role, but I just use the labeling feature to label important interactions with their role.  This is the admin login.  This is the Admin adding a user.  This is a user adding a user.  WHOOPS.  Shouldn't be able to do that.  You get the idea. 

Next we want to write the Application Summary.  This is part of the report that tells what the application does.  Why do we need to tell the developer what the application does? To make sure we are on the same page.  You would not believe the number of times I have had the developer say "Didn't you test the Admin screens?"  WHAT admin screens? That wasn't in the scope? Well, it was supposed to be.  What you do business wise from there is up to you, but it lays a level set as to what the scope really was.

Then it is time to brute force.  I use FuzzDB to get a list of known web directories and files, and then use the brute force tools to implement them.  In ZAP, it's just called Forced Browse in ZAP. but for Burp you need to use Intruder and get fancy.  I load up the first GET (for /) and then put the weird § signs right after, and run a directory scan, then a file scan.  Then I run a file scan on any interesting looking directories. You will not BELIEVE what you will find, sometimes. There are 30,000 words in that Medium directory listing. 

Finally, spidering.  This is just like the old days, or like the Google spider - the proxy will look for any URLs, and attempt to follow them.  Nice thing about attack proxies, they will look in comments, JavaScript, CSS, text files, anything it can for URLs.  Then it adds them to the site map.

Once we have a solid look at the application, we scan.  I don't suggest just right clicking on the host and selecting Active Scan.  It takes forever, makes a crapload of extra stuff in the Burp file, and won't earn you much.  Instead, look for interesting POSTs, or GETs with neat stuff in the URL.  Stuff that gets edited. That's where the magic is.

While the scanning is happening, we do the "insight" portion of the recon.  First, get the comments. In Burp, that's engagement tools, and ZAP uses an addon. Read them. Look for developer names, open source packages, interesting stuff. The hit Google.  No, I'm not kidding.  Look for existing, known vulnerabilities.  Do they have a vulnerable version of JQuery? Look up the devs.  Their LinkedIn, Facebook.  Then get their StackOverflow profile.  Asked any security questions recently?  Any code in there? Are you smelling what I'm cooking here?

This is also the time when you look for weird stuff.  Is there file upload?  Notate it.  Method name in a URL?  Point that out.  Redirects, like a URL in a querystring? Make a note. Encoded strings? Weird hidden HTML INPUT fields? Cookies you've never seen?  Those are all Things That Are Weird.  You need to add them to the file, and check on them in the analysis.

Last thing - need to take apart anything binary.  Flash? Java applets?  ActiveX (pleaseno)? Take them apart.  There are decompilation tools out there, and at least run strings (it's in Kali) to see what's in there.  You'd be amazed.

That's just about it for recon.  I store everything in Evidence, and then step away from the app, even if just overnight.  Fresh eyes and all that.  The analysis part will likely take a bit, so we will break that over several posts.

Bill Sempf

Husband. Father. Pentester. Secure software composer. Brewer. Lockpicker. Ninja. Insurrectionist. Lumberjack. All words that have been used to describe me recently. I help people write more secure software.

PageList

profile for Bill Sempf on Stack Exchange, a network of free, community-driven Q&A sites

MonthList