Part 4 Defenses

Video Activity

This lesson focuses on mitigations, countermeasures and defenses. The defenses covered in this lesson include: • Layered security approach • Programmatic checks to be thorough

Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
9 hours 31 minutes
Difficulty
Intermediate
CEU/CPE
10
Video Description

This lesson focuses on mitigations, countermeasures and defenses. The defenses covered in this lesson include: • Layered security approach • Programmatic checks to be thorough

Video Transcription
00:04
Hello and welcome to the Cyberia secure coding course. My name is Sonny Wear, and this is CNN's Top 25 category insecure interaction between components, mitigations, countermeasures and defenses. So, first our defenses overview.
00:22
We're going to look at a layered security approach
00:26
for addressing the unrestricted file upload with dangerous type. This is going to include several defenses because there really are no silver bullets to address this particular area.
00:40
Also, I'm going to take you through some programmatic checks that you can do on the server side. We'll look at some sample code
00:49
but realize that these have to be layered in with other defenses. So first are layered security approach.
00:59
You can see that I have seven steps here, and all of them should be incorporated to provide a layered approach towards
01:08
preventing the types of attacks that we talked about for the unrestricted upload of files.
01:17
So if we take a look at the list we've got create custom validation of content type plus extension, and I'll explain what that means in just a moment.
01:27
Number two used temporary file names. Now this is an interesting one where we basically change the name of the file the idea being the attacker would look for their specific file name in order to execute it. As you saw in the demo,
01:48
the
01:49
the problem with temporary file names is it still may not prevent the attack. So even if you're using your elin coding or some other mechanism to change that name,
02:04
if the file is still accessible and excusable on the server and it doesn't really matter,
02:10
number three the landing Zone change. So this we also saw in the demo where the file was actually uploaded. Two completely different directory. It was called the Uploads Directory.
02:27
You could certainly do this, and
02:30
and my recommendation is to place it in a secured directory, a directory that's been locked down by the Web server so it's not accessible. Or better yet,
02:43
uh, pass it on over to your application server. If that's an option.
02:47
Number four ownership is a lower account, so you when files are generally uploaded, they're gonna be owned by the account that's running the Web server.
03:00
And so, in order to avoid this, you want to make sure that you've got some sort of Scripture code that can do a change. Ownership a CZ well, as a change of executed ble permissions on that file, which is number five, don't allow excusable permissions,
03:19
so this would be something that you want to ensure and your cue a team should check.
03:23
Number six is to use that sandbox directory. That's what I was alluding to for the landing zone change.
03:31
Not only do you want to change where
03:34
the file gets uploaded, but you want to make sure that that particular directory is actually locked down, and that would generally be done
03:43
as a Web server. Configuration change
03:46
and then number seven. If you can afford it,
03:50
try to incorporate the use of malware scanners. Now I know that this may come with some criticism
03:57
that now our scanners can only detect known signatures, and that is true. But for large majority of payloads that are well known medicine, Floyd, payloads and things like that,
04:13
this is certainly a viable solution for up for most companies.
04:19
It's not just realized that it's obviously not going to address zero days
04:25
and realize that it is a reactive kind of defense in that you you have to make sure that your scanners are
04:33
updated regularly with new signatures, etcetera.
04:38
Now programmatic changes.
04:41
What do you want to do? Is you want to at least have some code in there on your server side for checking the file that's coming in Because if you remember, I told you, never accept
04:55
a zip file, right? So that's one of the extensions or
05:00
contents that you never want to allow. You should also not allow files that don't have any extensions at all. This is commonly done by users that,
05:11
you know, don't turn on the the extension viewer in Windows,
05:16
and so you don't want to allow those either. You do want to force the user to provide some kind of dot something.
05:26
Uh, in that, though you basically would create an array
05:30
or an enumeration of the types of extensions that you want to receive,
05:38
and then you would also have an array or an enumeration of the types of content types that you will accept. And if you remember from
05:49
previous slides, I was able to very easily spoof the content type, right, so live. If the extension was of a certain type,
05:59
it will say certain content type, and I could easily spoof that So what you want to do is on the service side on Lee, except certain content types and only certain extension types.
06:11
The combination of this, you need to have a logical and so don't use wth e or statement the logical order.
06:19
And then
06:20
that is just one layer, of course, of protection. Not to be your only means of protection.
06:30
As I mentioned, if you can afford it, purchase a malware scanner. Something that resides on the server itself can also be leveraged. You can make a pee I calls say you already have McAfee's McAfee any virus
06:47
already available on that particular server by default. That's
06:53
part of how the image is made.
06:55
You can actually make a P. I calls into that in leverage it that way.
07:00
And there are some third party products out there, very good products that you can then
07:06
purchase multiple engines to to basically cover more bases. And so
07:14
I encourage you to look into those further
Up Next