Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

The Need for Secure Coding

, 25 Jul 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
The reality is that, today’s information security landscape sucks, attacks are becoming more sophisticated, and getting folks involved in producing the software thinking about security seems like a losing battle.

There was recently a survey published in Visual Studio Magazine that stated more then 40% of all software developers globally didn’t adhere to any secure coding practice. This really baffled me, but then again it shouldn’t have because as a developer much before I knew anything about security I wrote a lot of really crappy really insecure code for my employers. I believe I really did them a disservice, there is code running in production that I wrote, which could have disastrous effects for my previous employers if it was ever exploited.

No professional developer should ever be okay with at statement like that. As developers as professional developers we’re not okay with releasing defects in our code that could have potentially disastrous side effects if just the right set of circumstances are reached. Yet we live & work in a culture where that’s exactly what we are setting ourselves up to do. More then 40% of developers don’t employ secure coding practices, very few colleges & universities teach secure development ideas to their students, so it falls to the company & the developer to care & learn about secure development practices, The developer doesn’t have time & the company says it’s to expensive. The reality is that, today’s information security landscape sucks, attacks are becoming more sophisticated, and getting folks involved in producing the software thinking about security seems like a losing battle. It appears that until an organization suffers a significant data breach their security processes remain largely undefined and underfunded.

Secure coding practices go beyond, what security features should we implement in our application, a good practice forces everyone involved in the software process to recognize there are security vulnerabilities in whatever software might be released and to understand the risk associated with each. Then defining a a response plan to how to deal with said security vulnerabilities.

When Should I care about A secure coding process?

All the time, but first if you have any security features in your application, be it a web application, a desktop application, some hybrid. If you have security features like encryption, login, SSL, authentication, anything else. That immediately tells me that you have some information to protect. If you have information to protect somebody somewhere at some point in time will attempt to, break in, steal, change, compromise your data, in the best case scenario just because they can, in the worst case to financially harm the organization you work for, or your customers.

Is it enough to rely on corporate firewalls, routers and other network hardware?

NO! If you write an internal only application that authenticates  against domain credentials that’s never exposed to the outside world, if you’re application is authenticating that means there’s something to protect. Therefore the application and the application developers need to take responsibility for the security in their applications as well. But why?

To answer that, lets consider the security use case of a casino for a minute. When you first enter the casino, you’re met by security to determine that you’re old enough to gain access, and you’re legally entitled to gain access. You may not know it but you’ve just passed 1 level of security, you’ve been authenticated on the domain if you will. However once you’re inside the casino, do you have free will to do whatever you want? Absolutely not, there’s security guards walking around keeping a close eye on you, there’s camera’s & security guards in a control room monitoring you, looking for any suspicious activity, any reason to revoke your access to the casino domain, in order to protect their assets. What’s a casino’s most valuable asset? It’s money, It’s also the casino’s most protected asset, even after you’ve gotten into the casino, passed numerous security checks while you’re in there, you still don’t have a chance of getting anywhere near the money. The money is usually moved by 2 -3 security guards and then another guard, guarding access to a door, once through the door the money asset isn’t considered secure, no its locked up inside the casino’s vault.

So if you were an attacker and wanted to steal the money of a casino, you’d have to accomplish this:

  1. Gain access to the casino
  2. Avoid detection/suspicion of the guards
  3. Take out 2-3 security guards while moving the money/avoid the rest.
  4. Get out without being detected.OR
  5. Take out 1 security guard, gain access to a locked door
  6. Avoid any security guards after through the door
  7. Gain access to the vault
  8. Defeat the vault’s security system
  9. Get out, without being detected.

The casino practices a concept of security in depth. If you can defeat 1 security guard or 1 security measure there are still more you have to defeat. When adopting a secure coding practice this is something that developers should think about.

If the network firewall can be defeated, are the assets, the most trusted assets that my company relies on, still secure because of my program?

If domain authentication can be bypassed/tricked are the assets my application and company care about still secure?

What’s our remediation plan if our security is defeated? The casino’s is the call the police and potentially send some shady characters after you.

What if my application protects nothing, do I still need to think about security?

Without question yes, even if you’re writing a plain old boring text editor application, you still need to think about security. You may think that your application doesn’t protect any assets, however I would challenge that and suggest the customer’s computer your application is running on is an asset in and of itself. If your application has a security hole, that security hole may allow your customer’s computer to be hijacked for a botnet, or worse still, a security hole might be exploited to allow malware to run on your customer’s computer at an elevated privileged because your application requires running under elevated privileged and that malware might take steal, or otherwise compromise other assets running on your customer’s machine.

A secure coding practice would force developers to stop an think about how some their application could be exploited against their clients, even if it were just a text editor. How is that text editor updated, could a dll allow  a remote thread to run, and download & execute some malware, it doesn’t matter how the malware gets there, if it’s on the machine, it could run and exploit a security vulnerability, could an attacker replace on of your application dll’s to execute their own code?

A secure coding policy doesn’t necessarily need to stop all these vulnerabilities before a product is released, products are released all the time with defects in them, which are patched in updates or not patched at all, so too security vulnerabilities can be fixed at a later date if deemed not risky.

Can’t I just release a product and care about security later?

Sure there’s nothing that says you can’t, however there is an ideology within software circles that would suggest early defect detection, leads to cheaper, defect fixes, so too with security, a security vulnerability is just a defect, the earlier you find it the cheaper it is to fix.

My Developers are careful and use common sense!

Do they? I spent 5 years writing software, before I knew anything about security & before I really started to study security and gain some understanding of how an application could be violated. How many other developer out there are just like me? Security wasn’t a concern, making money was! Few colleges & universities teach security so how can the developer have common sense around security? A good secure coding policy will make it a point of training other developers,what  to think and how to think about security.

I’ll just hire a security professional when my products gain enough traction

Sure this attitude works if you’re a big company. You can bring in security consultants later to help retrofit security & add security to your product line, later hopefully before your exploited! However the reality in Canada & many startups ism companies are small, few developers and  that security consultants cost money perhaps lots of money, as well and then it becomes costly to add security after the fact.

 Security Costs Money

Absolutely it does, security & secure coding practices is a lot cheaper if you build security in rather then bolt security on afterwards. You also need to balance a security cost in your application against the loss suffered of because a security hole was exploited. Without a secure coding policy how can a company or their developers ever begin to understand what the cost, of having a security vulnerability exploited if they do not understand the risk associated with some vulnerabilities or are even aware what vulnerabilities exist. A solid secure coding program, allow developers and companies to identify & calculate risk and make informed decisions on the security vulnerabilities in their application. Secure coding training should be part of hiring any new employee.

It’s 2013

Cyber criminals are making applications & selling them that allow computers to get infected software to get exploited. Edmund Burke said “All that is necessary for evil to triumph is for good men to do nothing” One might suggest all that’s needed for evil software to triumph is for good software developers to do nothing. Knowledge of secure coding practices, policies, should be something every software developer whom calls themselves a professional should develop, add to their tool kit and apply, they should also be encouraging their employers to develop formal secure coding polices & practices. Microsoft uses the Security Development Lifecycle.  That may be a good starting place for your organization or it may not, there are many different secure coding practices out there, it’s time that we developers, managers, CEO’s, stood up, adopted and did better for everyone.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

CdnSecurityEngineer
Engineer
Canada Canada
I am a Sr Engineer for a major security firm; I have been developing software professionally for 8 years now; I've worked for start ups, small companies, large companies, myself, education. Currently the company I work for has 7,000+ employees worldwide. I am responsible for our platform security, I write code, implement features, educate other engineers about security, I perform security reviews, threat modeling, continue to educate myself on the latest software. By night, I actively work to educate other developers about security and security issues. I also founded a local chapter of OWASP which I organize and run.
 
I cut my teeth developing in C++ and it's still where my heart is with development, lately I've been writing a lot of C# code & some java, but I do have a project or two coming out in C++ /DiectX 11 whenever I get the time.
 
When I am not developing code I am spending my time with my wife and daughter or I am lost deep in the woods some where on a camping trip with friends. If you can't find me with a GPS and a SPOT device then chances are I am on the Rugby pitch playing Rugby and having a great time doing so.
 

You can find more about me and My thoughts on security
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150129.1 | Last Updated 25 Jul 2013
Article Copyright 2013 by CdnSecurityEngineer
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid