Hello and welcome to the cyber very secure coding course my name miss anywhere. And this is the OAS top 10 for 2013
a one injection mitigations, countermeasures and defenses.
Now an overall view of defenses really center around three main areas. The neutralization of special characters,
the performing of input validation in your application code
and the employing of white listing techniques
now neutralization of special characters. As we saw in the demos, A lot of times payloads by Attackers will include ticks or comments and other special characters specific two languages and databases. And so what do you want to do is you want to neutralize
characters and make them re be received as text or data on Lee,
instead of being interpreted inadvertently by your database or by your operating system, et cetera.
Now I recommend that you go with language specific frameworks if you have them available.
Microsoft has a lot of neutralization techniques available within their framework.
These are also available in Java based frameworks like struts and spring.
However, if you don't have a language specific framework that you can draw from,
a wasp has in HTML sanitizer, which can certainly be used for your output in coding.
Now the next area is performing input validation.
As programmers, we tend to code on the happy path where we don't
We don't code thinking about what could go wrong or,
UH, input that could come into our program that we're not expecting.
And so performing input validation is that very thing. And generally input validation needs to be verified through a manual code review of some type
with others on your development team.
The third area overall for a defense is tthe e.
The implementation of white listing techniques now white listing in general is tthe e excepting of values that are allowed,
and this could be done a number of different ways. You can create a raise or in new Marais shins that have the values that are acceptable to your program. Also, you could set up Constance may be in a header file or some sort of common area, and then
when you receive input
from the command line or from the gooey, you could do a match or comparison against what is received against those constance
regular expression. Pattern matching is also a very common way to employ a white list.
Now, if we look specifically at the particular injection types that we saw in the demos,
the 1st 1 was sequel injection.
Now, for sequel injection, we must perform our input validation, ensuring that we receive what we should really be expecting.
Secondly, we need to neutralize the input from the presentation tear,
and how this is commonly done is through the use of parameter rised queries with bind variables. And I wantto stipulate the
the use of the bind variables. So, for example, if you take a look at the Java code that's presented,
we have a prepared statement.
This prepared statement has a sequel statement within it
of select transaction data from the transaction table, where the batch ideas equal to question mark and customer numbers equal to question mark.
Now you'll notice that
both question marks are then filled with values that are received from the presentation here.
But they've been sanitized through an input validation technique first,
they're actually placed within the sequel statement using bind variables. You see, the one in the two corresponds to each question mark.
What this does is even if the attacker does put some sort of sequel injection into either of these parameters. They're not going to inadvertently be executed by the database. Instead, it's going to be treated just as data.
Now, in regards to command injection prevention,
we definitely need to perform some sort of path validation.
This is usually done by first canonical izing that path, ensuring that it's not a symbolic link,
that it is a full, absolute path and that it matches the operating system.
And then what you want to do is perform your input validation. Make sure that you've got some sort of ray, or even in numerator shin
of the acceptable commands, so that anything that falls outside of that will not be accepted into your program. Finally, for the Jason Injection Prevention,
to ensure that we're not doing any kind of reflective cross site scripting vulnerability in our response.
The OAS Jason Sanitizer is a job, a library that's available for addressing some minor
in coding issues with Jason, and it's also very good at taking in any kind of Jason like content and converting it to an actual, valid or well formed Jason in order to make it easier for parsing