Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding security problems in a given code [closed]

Can some one please tell me an approach for finding security flaws in a given code. For ex: in a given socket program. Any good examples or good book recommendations are welcome.

Thanks & Regards,

Mousey

like image 949
mousey Avatar asked Aug 07 '10 05:08

mousey


People also ask

What can be used to find potential security issues in code?

Static analysis is the most efficient way of uncovering most code vulnerabilities in your applications.

How do you review a security code?

Secure code review is a manual or automated process that examines an application's source code. The goal of this examination is to identify any existing security flaws or vulnerabilities. Code review specifically looks for logic errors, examines spec implementation, and checks style guidelines, among other activities.

Which tool helps identify the security issues in runtime environment?

Dynamic Application Security Testing (DAST) They detect conditions that indicate a security vulnerability in an application in its running state. DAST tools run on operating code to detect issues with interfaces, requests, responses, scripting (i.e. JavaScript), data injection, sessions, authentication, and more.


1 Answers

The lowest hanging fruit in this category would be to simply search the source for functions which are commonly misused or are difficult use safely such as:

  • strcpy
  • strcat
  • sprintf
  • gets

then start looking at ones that are not inherintly too bad, but could be misused. Particularly anything that writes to a buffer can potentially be hazardous if misused.

  • memcpy
  • memmove
  • recv/read
  • send/write
  • the entire printf family should always have a constant for the format string

NOTE: all of these (except gets) can be used correctly, so don't think it's a flaw just because the function is used, instead take a look at how it is used. Also note that gets is always a flaw.

NOTE2: this list is not exhaustive, do a little research about commonly misused functions and how they can be avoided.

As far as tools, I recommend things like valgrind and splint

like image 77
Evan Teran Avatar answered Nov 15 '22 19:11

Evan Teran