- In this lesson 14.7, we're gonna focus in
on secure coding.
Now, secure coding is the practice of writing code
in a way that prioritizes security,
minimizes vulnerabilities or weaknesses
and reduces the risk of exploitation by attackers.
Now, secure coding follows
established coding best practices,
adheres to security principles,
and utilizes secure coding techniques
to build secure, survivable,
remember, that's a system property survivable software.
Now, how do we get there
to a place where we really feel comfortable
and confident that we're really doing secure coding?
Well, there are a couple of precursors.
One is having developer training.
It's important that our developers
understand secure coding techniques,
practices, standards, you know, what they should be doing,
what tools they can use, having very clear requirements,
what are our security requirements
and our privacy requirements?
And doing threat modeling,
which is looking at what are the most likely threats?
What are the threats that we really need to harden
our software against so that it is survivable?
So absolutely critical, right?
That we're defining our security and privacy requirements
not in the middle, not at the end,
but at the beginning of the development cycle.
The beginning of every development cycle,
there should be an agreed upon minimum acceptable level
of security and privacy requirements, and they are codified,
they're documented, that we have key milestones
and deliverables are defined.
Because when security requirements are not identified,
then the security
of the resulting system can't effectively be evaluated.
We can't say,
"Okay are we getting the level of security we want
if we haven't even said what it is we need?"
The threat modeling is used to anticipate threats
to which the software will be subject to
and the attack surface that could be exploited.
Remember, the attack surface is the sum
of all possible entry points, vulnerabilities, and avenues
and attack that an attacker can exploit
to compromise a system or application.
So our threat modeling involves identifying
applicable threats and developing
threat mitigation strategies
that are implemented in our design, in our code,
and in our test cases.
So I wanna share with you some secure coding best practices.
I'd love these best practices, and these actually came
from the Software Engineering Institute at Carnegie Mellon.
Keep it simple, heed security policy,
input validation, output validation,
secure cookies, code signing, effective QA processes,
and sanitize data sent to other systems.
Now, we've talked about some of these already
but one of the reasons I really like these
is because not only they secure coding best practices
but on the most part,
these are best practices for our entire infrastructure.
So number one, keep it simple, right?
Simplicity means fewer errors
and a less complex assessment process.
Everything we're designing,
we should design to keep it simple, right?
It's less errors when we're making it
and it's much easier to assess it.
Heed security policy.
In this case, we're talking about for our code
we wanna architect and design for security requirements.
But isn't that true of everything
from our Windows group policy to how we set our routers
to what we're doing in our wireless networks.
You know, what everything we're doing,
we should be architect and designing
for our security requirements.
The next is input validation,
validating input before passing or processing.
And we talked about input validation a while back
in terms of an injection attack, right?
Injection is when code
or instructions are injected that are then passed
to the processor and executed, right?
And so what is the result?
Well, we saw things like injection attacks,
cross-site scripting, cross-site request forgery,
all very, very dangerous attacks.
And so we wanna make sure
that we are validating all our input
before passing or processing.
We saw that in those attacks.
That's also gonna be true within our code.
The same thing for output validation.
We wanna validate output before returning.
Secure cookies is that we wanna require cookies
to be encrypted in transit.
We can flag it with a secure attribute.
Code signing, we wanna ensure
that we're digitally signing executables
and scripts to confirm authenticity and integrity.
Remember, what's a digital signature?
A digital signature is going to be a hash
or a message digest that is signed with a private key.
We're gonna use effective QA processes.
Well, I think we should be using effective QA processes
in everything we do, right?
We're gonna use effective
and easy to use quality assurance testing
and evaluation processes.
And lastly, trust but verify, right?
We really always wanna sanitize data sent to other systems.
There may be some situations
where we decide it is trustworthy,
but whenever there's the least bit of doubt,
we're going to sanitize.
All great secure coding practices,
all great best practices in general.
All right, that my friends,
brings us two a three-second challenge.
Five challenge questions, three seconds each.
Let's do it.
This process is used to anticipate threats.
One, two, three.
It's gonna be threat modeling.
Number two, the basis of injection attacks.
One, two, three.
It's gonna be poor input validation
or non-existent input validation.
Number three, a cryptographic method
to confirm authenticity and integrity.
One, two, three.
It's gonna be code signing or having a digital signature.
That's really what we mean by code signing.
Number four, property that describes
an application's ability to withstand attack.
One, two, three.
And that's gonna be survivability.
And lastly, number five, all of the points
where an attacker can try to enter or extract data from.
One, two, three.
That's gonna be your attack surface.
All right, let's do a security-in-action.
This one's about our developers and developer training.
You've been tasked
with creating introductory secure coding training
for the application development team.
The first three topics that you're going to introduce
are keep it simple, heed security requirements,
and validate input.
So I want you to be able to really be concise
as you're introducing these topics to these developers.
So in one sentence, I want you to explain
why each one of these topics is important.
Now, trying to explain anything
in one sentence is always a challenge
but if you can boil it down to one sentence,
you really understand the concept.
So go ahead and put me on pause
and then write one sentence about why keep it simple,
heed security requirements and validate input are important.
Then come on back.
Well here's how you might explain
how the topic is important.
Simplicity means fewer opportunities for error
and a less complex assessment process.
Heeding requirements will result
in survivable resilience software that is aligned
with the needs of the organization.
Input validation will prevent dangerous injection,
cross-site scripting,
and cross-site request forgery attacks.
So that's why each one of these topics is important.
Being able to explain that to your developers,
making that relationship, getting them excited
about having secure code, that's pretty awesome.
And that is definitely security-in-action.
There's your word cloud, not too big
but you know what to do.
Make sure just like in every other lesson
before you move on, that you just sort of stare
at this word cloud and then speak them,
speak it out loud, right?
Make sure that you understand the concepts
and the terms and that you're comfortable with them
and confident that you can explain them.
And then when you're ready, well, we've got a quiz to do.
I'll see you there.