Web Attacks and Countermeasures

Web Attacks and Defense

1. Introduction

What is a web application? Why web applications are the first target for hackers? What are the attacks Web applications usually face, how to prevent from these attacks. Lets start from the various web application attacks. This article is divided into three areas including types of attacks, countermeasures and risk factor.

2. ATTACKS

Following are the most common web application attacks.

a. Remote code execution

b. SQL injection

c. Format string vulnerabilities

d. Cross Site Scripting (XSS)

e. Username enumeration

Remote Code Execution

As the name suggests, this vulnerability allows an attacker to run arbitrary, system level code on the vulnerable web application server and retrieve any desired information contained therein. Improper coding errors lead to this vulnerability. At times, it is difficult to discover this vulnerability during penetration testing assignments but such problems are often revealed while doing a source code review. However, when testing Web applications is important to remember that exploitation of this vulnerability can lead to total system compromise with the same rights as the Web server itself is running with.

SQL Injection

SQL injection is a very old approach but it's still popular among attackers. This technique allows an attacker to retrieve crucial information from a Web server's database. Depending on the application's security measures, the impact of this attack can vary from basic information disclosure to remote code execution and total system compromise.

Format String Vulnerabilities

This vulnerability results from the use of unfiltered user input as the format string parameter in certain Perl or C functions that perform formatting, such as C's printf().
A malicious user may use the %s and %x format tokens, among others, to print data from the stack or possibly other locations in memory. One may also write arbitrary data to arbitrary locations using the %n format token, which commands printf() and similar functions to write back the number of bytes formatted. This is assuming that the corresponding argument exists and is of type int *.
Format string vulnerability attacks fall into three general categories: denial of service, reading and writing.

Cross Site Scripting

The success of this attack requires the victim to execute a malicious URL which may be crafted in such a manner to appear to be legitimate at first look. When visiting such a crafted URL, an attacker can effectively execute something malicious in the victim's browser. Some malicious JavaScript, for example, will be run in the context of the web site which possesses the XSS bug.

Username enumeration

Username enumeration is a type of attack where the backend validation script tells the attacker if the supplied username is correct or not. Exploiting this vulnerability helps the attacker to experiment with different usernames and determine valid ones with the help of these different error messages.

3. Countermeasures

Username enumerations:

Display consistent error messages to prevent disclosure of valid usernames. Make sure if trivial accounts have been created for testing purposes that their passwords are either not trivial or these accounts are absolutely removed after testing is over - and before the application is put online.

Cross site scripting:

Input validation, secure programming and usage of good language for dynamic web applications.

SQL Injection:

Avoid connecting to the database as a super user or as the database owner. Always use customized database users with the bare minimum required privileges required to perform the assigned task. Perform input validation and do not give error response on client side.

Format String:

Edit the source code so that the input is properly verified.
Remote code execution:
It is an absolute must to sanitize all user input before processing it. As far as possible, avoid using shell commands. However, if they are required, ensure that only filtered data is used to construct the string to be executed and make sure to escape the output

4. Risk Factors

SQL Injection:
Rating: Moderate to Highly Critical
Remote Code Execution:
Rating: Highly Critical
Cross Site Scripting:
Rating: Less Critical
User Name Enumeration
Rating: Less

5. Summary

This is the short article to develop awareness on web attacks and countermeasures, these are common web application attacks.

Comments: [0] / Post comment:
03 Jan 2009 17:36:35

Dem leaders out of step with voters on Israel's attack on Gaza - Chicago Sun-Times

Times Online Dem leaders out of step with voters on Israel's attack on Gaza Chicago Sun-Times, United States - BY GLEN GREENWALD A new Rasmussen Reports poll -- the first to survey American public opinion specifically regarding the Israeli attack on Gaza -- strongly ... Video: Israel Allows Some Gazans to Flee Bloodshed Gaza Attacks Escalate, Livni Says Israel Determined to Press On Bush blasts Hamas' attacks on Israel -
03 Jan 2009 13:59:32

Local Mumbai Attacks Survivor Offers Message - MSNBC

Local Mumbai Attacks Survivor Offers Message MSNBC - By Reported By Marc Stewart NASHVILLE, Tenn. - In India, it's known as 26-11. Nov. 26 was the day that Mumbai became the backdrop to a terrorist massacre. ...
03 Jan 2009 13:21:20

Pakistan expresses grave concern over attacks in Gaza - Xinhua

Pakistan expresses grave concern over attacks in Gaza Xinhua, China - 3 (Xinhua) -- Pakistani President Asif Ali Zardari Saturday said Pakistan expressed grave concern over the attacks in Gaza and called for cessation of the ... India asks Pakistan to hand over Mumbai suspects Hand over Mumbai attack masterminds: PM to Pak India urges "sense" in Pakistan over militancy -
03 Jan 2009 11:58:48

Man Covered In Feces Attacks Flight Attendant - MSNBC

Man Covered In Feces Attacks Flight Attendant MSNBC - HOUSTON - An investigation is under way to figure out why a mental health patient was traveling alone on a Continental Airlines flight from Houston to Omaha ...
03 Jan 2009 10:37:26

San Francisco officials want at least $75000 from tiger attack ... - San Jose Mercury News

KCBS San Francisco officials want at least $75000 from tiger attack ... San Jose Mercury News, USA - San Francisco officials want one of the survivors of a Christmas Day 2007 tiger attack at the San Francisco Zoo to pay the city more than $75000 for ... SF wants $75000 back from tiger attack survivor
03 Jan 2009 02:13:56

Gene that predicts risk of heart attack identified by scientists - Telegraph.co.uk

TopNews Gene that predicts risk of heart attack identified by scientists Telegraph.co.uk, United Kingdom - Thousands of heart attacks could be prevented after a gene associated with early hardening of the arteries was identified by scientists. ... Researchers Link Gene To Common Heart Disease
02 Jan 2009 19:18:50

Health Buzz: Smoking Bans Cut Heart Attacks, and Other Health News - U.S. News & World Report

ABC News Health Buzz: Smoking Bans Cut Heart Attacks , and Other Health News U.S. News & World Report, DC - Hospitalizations for heart attacks fell sharply in Pueblo, Colo., after the implementation of a law that banned smoking in public places and workplaces, ... Smoke does not get in their eyes (or their lungs) Dramatic Drop in Heart Attacks Attributed to Smoking Ban Possible link between smoking bans & heart attacks -
02 Jan 2009 18:37:27

EU Forces Foil Pirate Attacks Near Somalia - Voice of America

TVNZ EU Forces Foil Pirate Attacks Near Somalia Voice of America - By VOA News European Union naval forces have foiled attacks by Somali pirates on two merchant ships in the Gulf of Aden over the past two days. ... France hands pirates to Somalia, more attacks foiled EU Naval Forces Foil Piracy Attacks Off Somalia EU force stops attack on Greek tanker -
02 Jan 2009 14:39:09

Israel Launches Fresh Attacks in Seventh Day of Fighting - Washington Post

guardian.co.uk Israel Launches Fresh Attacks in Seventh Day of Fighting Washington Post, United States - By Griff Witte JERUSALEM, Jan. 2 -- Israel bombed a mosque and the homes of at least half a dozen Hamas leaders in the Gaza Strip on Friday and allowed ... Video: Palestinians brave Israeli assault to return home - 2 Jan 08 Foreign residents flee Gaza attacks Shin Bet: Number of terror attacks in Israel shot up in 2008 -
02 Jan 2009 14:17:26

Suspected US Missile Attack in Pakistan Kills 3 Militants - Voice of America

CBS News Suspected US Missile Attack in Pakistan Kills 3 Militants Voice of America - By VOA News Pakistani intelligence officials say a suspected US missile attack has killed at least three militants in northwest Pakistan, near the Afghan ... Attack Brings Military Focus Home Death from above: how Predator is taking its toll on al-Qaeda Three dead in Waziristan rocket attack -

Keywords: