Tag: prevent

Exploits, Vulnerabilities

Preventing Session fixation – hijacking

“Session fixation attacks attempt to exploit the vulnerability of a system which allows one person to fixate (set) another person’s session identifier (SID). Most session fixation attacks are web based, and most rely on session identifiers being accepted from URLs (query string) or POST data..” from Wiki. Let’s see some countermeasures we can take to …

MSSQL, PHP

How to prevent sql injection using PHP and SQL Server

Let’s see how we can prevent sql injection attacks in our applications when we are using PHP and Microsoft SQL Server: 1. Use prepared statements – sqlsrv_prepare. 2. Use parameterized queries – PDO. 3. Use stored procedures – mssql_execute. 4. Validate User Input – preg_match. 5. Escape user input – addslashes,  str_replace or preg_replace quotes. …

Buffer Overflows, C/C++

Prevent buffer overflows

A buffer overflow is a form of software security vulnerability. Occurs when a program tries to store more data in a fixed length buffer. The extra data corrupts-overwrites data in memory addresses adjacent to the allocated buffer. This will often cause the program to crash or operate incorrectly. Stack buffer overflow Stack buffer overflow occurs …

Format String Vulnerabilities, PHP, WEB

Prevent Format String Vulnerabilities in PHP

Format string exploits can be used to crash a program (DoS) or to execute harmful code. The use of unfiltered user input in functions such as printf() or sprintf() are the causes of this vulnerability. The attacker could use this kind of vulnerability to land Denial-of-service attacks, use the %x format specifier to print sections …

Cross-Site Scripting, PHP, WEB

Preventing Cross-Site Scripting (XSS) in PHP

Cross-site scripting (XSS) is a type of vulnerability found in web applications. Occurs when a web application gets data from a user and makes use of them without validating, checking, encoding or filtering them. This vulnerability enables attackers to inject malicious client-side scripts into a trusted web site. The end user’s browser will execute the …

PHP

Preventing MySQL Injection in PHP

Security issues like MySQL injection can only be corrected by using two functions mysql_real_escape_string (php manual) and stripslashes (php manual).   Example: $safe_string = mysql_real_escape_string(stripslashes($tainted_string));$safe_string = mysql_real_escape_string(stripslashes($tainted_string));   To make your life a little easier just create a suitable function for this line of code: function checkString($value) {       return mysql_real_escape_string(stripslashes($value));   }function checkString($value) …