Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | Secure Coding

You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Computers & IT > Security & Virus Discussion
Register FAQ Community Calendar

Secure Coding
Reply
 
Thread Tools
Old 19-07-2010, 13:04   #16
Paul
Dr Pepper Addict
Cable Forum Team
 
Paul's Avatar
 
Join Date: Oct 2003
Location: Nottingham
Age: 62
Services: Aquiss FTTP (900M), Sky Q TV, Sky Mobile, Flextel SIP
Posts: 29,654
Paul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered stars
Paul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered starsPaul is seeing silvered stars
Re: Secure Coding

As far as MySQL is concerned, you dont need parameterised queries to be safe, you just need to make sure that if the data is a number then its really numeric (use something like intval(x) to clean it) - and if its text, make sure its escaped (the MySQL/PHP inteface has a built in function to do this).
__________________

Baby, I was born this way.
Paul is offline   Reply With Quote
Advertisement
Old 19-07-2010, 16:23   #17
AntiSilence
Inactive
 
AntiSilence's Avatar
 
Join Date: Jul 2006
Location: Sutton-In-Ashfield
Age: 47
Services: C#/ASP.NET Web Development
Posts: 3,580
AntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronze
AntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronze
Re: Secure Coding

Quote:
Originally Posted by punky View Post
Parameterised queries are unique to ASP.NET
Surely you mean ADO.NET
AntiSilence is offline   Reply With Quote
Old 19-07-2010, 16:33   #18
punky
Inactive
 
Join Date: Jun 2003
Age: 44
Posts: 14,750
punky has a golden aurapunky has a golden aura
punky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aura
Re: Secure Coding

Quote:
Originally Posted by AntiSilence View Post
Surely you mean ADO.NET
I didn't think about that as Raistlin was talking about web-only technologies so defaulted to ASP.NET rather than all of .NET

Which reminds me, I used ADO.NET a while ago to connect my ASP.NET app to MySQL. I wonder if they supports parameterisation? I'm guessing it does as ASP.NET does the work and not the DB engine?
punky is offline   Reply With Quote
Old 19-07-2010, 17:05   #19
Damien
Remoaner
Cable Forum Team
 
Damien's Avatar
 
Join Date: Mar 2004
Posts: 32,731
Damien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver bling
Damien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver bling
Re: Secure Coding

Quote:
Originally Posted by punky View Post
I didn't think about that as Raistlin was talking about web-only technologies so defaulted to ASP.NET rather than all of .NET

Which reminds me, I used ADO.NET a while ago to connect my ASP.NET app to MySQL. I wonder if they supports parameterisation? I'm guessing it does as ASP.NET does the work and not the DB engine?
Like I mentioned previously. The database does require support. This is because the Parametrised Queries are not a query which is then escaped by the ADO.Net Framework.

Instead these are queries which are passed down to the database with the tokens (@whatever) to the database. The MS SQL database does two things, that I know of, first of all it caches a query execution plan. This allows it to perform subsequent operations marginally faster as, because the query has been parametrised , the only variables to the query are those parameters which it does not need yet.

Second; it inserts the parameter values which you pass down from your application.

Try it out. Write a parametrised query from your application and 'forget' to supply a parameter. The error thrown will be from the database and not the .Net framework.
Damien is offline   Reply With Quote
Old 19-07-2010, 17:49   #20
Raistlin
Inactive
 
Join Date: Feb 2004
Location: There's no place like 127.0.0.1
Services: Depends on the person and the price they're offering
Posts: 12,384
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Raistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered starsRaistlin is seeing silvered stars
Re: Secure Coding

To be honest the original query was meant to be platform/language agnostic - so all/any comments/suggestions are being gratefully received

Coding is something I haven't done much of, so whilst I understand the requirement to properly check/santise input and to use parameterised queries etc I've never actually had to do it - hence the reason for the original question.

I want to start coding more, but (being aware of the usual issues that people create for themselves by not doing it properly) I want to get into good secure habits from the start
Raistlin is offline   Reply With Quote
Old 19-07-2010, 17:53   #21
punky
Inactive
 
Join Date: Jun 2003
Age: 44
Posts: 14,750
punky has a golden aurapunky has a golden aura
punky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aura
Re: Secure Coding

Quote:
Originally Posted by Damien View Post
Like I mentioned previously. The database does require support. This is because the Parametrised Queries are not a query which is then escaped by the ADO.Net Framework.

Instead these are queries which are passed down to the database with the tokens (@whatever) to the database. The MS SQL database does two things, that I know of, first of all it caches a query execution plan. This allows it to perform subsequent operations marginally faster as, because the query has been parametrised , the only variables to the query are those parameters which it does not need yet.

Second; it inserts the parameter values which you pass down from your application.

Try it out. Write a parametrised query from your application and 'forget' to supply a parameter. The error thrown will be from the database and not the .Net framework.
You're correct, never realised that before.
punky is offline   Reply With Quote
Old 19-07-2010, 18:26   #22
AntiSilence
Inactive
 
AntiSilence's Avatar
 
Join Date: Jul 2006
Location: Sutton-In-Ashfield
Age: 47
Services: C#/ASP.NET Web Development
Posts: 3,580
AntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronze
AntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronze
Re: Secure Coding

Can't say I've noticed that before either lol. Nice one.
AntiSilence is offline   Reply With Quote
Old 19-07-2010, 19:11   #23
punky
Inactive
 
Join Date: Jun 2003
Age: 44
Posts: 14,750
punky has a golden aurapunky has a golden aura
punky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aura
Re: Secure Coding

Quote:
Originally Posted by AntiSilence View Post
Can't say I've noticed that before either lol. Nice one.
Makes me feel less of a noob then
punky is offline   Reply With Quote
Old 19-07-2010, 19:20   #24
AntiSilence
Inactive
 
AntiSilence's Avatar
 
Join Date: Jul 2006
Location: Sutton-In-Ashfield
Age: 47
Services: C#/ASP.NET Web Development
Posts: 3,580
AntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronze
AntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronzeAntiSilence is cast in bronze
Re: Secure Coding

Quote:
Originally Posted by punky View Post
Makes me feel less of a noob then
Lol, yeah I don't get exceptions which is why I never noticed! LMAO
AntiSilence is offline   Reply With Quote
Old 19-07-2010, 21:23   #25
Damien
Remoaner
Cable Forum Team
 
Damien's Avatar
 
Join Date: Mar 2004
Posts: 32,731
Damien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver bling
Damien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver blingDamien has a lot of silver bling
Re: Secure Coding

I only know it because I have worked with it for a project

But they are a neat feature and one I would hope is supported by modern technologies. I not sure if that PHP one does work correctly and not, as Punky said might be the case, a glorified string.format.

---------- Post added at 21:23 ---------- Previous post was at 21:14 ----------

Quote:
Originally Posted by Raistlin View Post
To be honest the original query was meant to be platform/language agnostic - so all/any comments/suggestions are being gratefully received

Coding is something I haven't done much of, so whilst I understand the requirement to properly check/santise input and to use parameterised queries etc I've never actually had to do it - hence the reason for the original question.

I want to start coding more, but (being aware of the usual issues that people create for themselves by not doing it properly) I want to get into good secure habits from the start
The thing is any book that covers only security might well be far too in-depth for what you need right now. They would be aimed at people trying to lock down an enterprise level application.

What stage are you at? I think that learning best practices in general regarding code reuse, readability, will be of greater benefit you than security. All you need to remember at the moment is DON'T TRUST YOUR USERS INPUT! Then learn the rest as you go...
Damien is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:21.


Server: osmium.zmnt.uk
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum