Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

One-Click Attacks


One-Click Attacks

What do you believe to be the real reason of most spam messages? What's the motivation of e-mails that invite you to buy colorful pills, drugs, cars, mortgages for impossibly low prices? Just to induce you to click to increase some sort of counter and click-through rate? There's probably more than that. One of the possible answers is one-click attack.

A one-click attack is when a completely unaware user is induced to click on a link to an unknown page. Apparently, the user (you) doesn't see anything special or anything that looks suspicious or blameworthy—ust a normal page. Is that all? If you've just been the ignorant victim of a one-click attack, by clicking to see that page, you triggered a more dangerous process. But not dangerous to you!

Imagine you're a hacker willing to perform an illicit action on a web site that you know very well (and that you can access yourself). You prepare an HTTP post packet with a well-known sequence of input fields—the fields you know the page under attack requires, accepts, and more importantly, processes. You can send this packet in many ways; for example, from a fake page hosted on your web site. In this case, if the attack succeeds, you could be logged.

What if you induce someone else to launch the attack on your behalf? You write a luring click in an e-mail and see if someone swallows the bait.

What are the mechanics of this attack and what's the hole it exploits? The bad news is that there's no patent programming error to avoid—the page has no way to distinguish legitimate traffic from one-click attacks. Yet attacks happen.

One thing you can do is identify potentially critical operations and implement a sort of validation layer to filter incoming requests. A simple but effective approach is checking the referer variable of the request. It has to match your site; if not, you should block the call to be on the safe side. However, in this way, you have chances to block certain totally legitimate calls such as those that originate out of a window.open or document.location script.

A better approach is relying on ASP.NET 1.1 magic (it doesn't work with 1.0) and setting the ViewStateUserKey property on the Page class. In the Init event, you set the property to a string value that is not null and unique to the user—typically, the session ID. What's the effect of this?

The session ID is (normally) a server-side value that an attacker has no way to guess. The best (and only) line of defense against this attack is using input fields whose value can't be guessed or set on the client. Attackers who target ASP.NET pages have to provide a valid viewstate field. If ViewStateUserKey is set, this value is used to generate the MAC key of the viewstate. If the property is set to a server-side, hard-to-guess value (like the session ID), the attacker will have a hard time reproducing it.

For example, if you set ViewStateUserKey to session ID, the attacker has to figure out you're using the session ID, then has to guess the session ID and find a way to inject the bogus call in just that session. It's theoretically possible, but definitely hard and probably enough to discourage attackers.


Dino Esposito is Wintellect's ADO.NET and XML expert, and a trainer and consultant based in Rome, Italy. Dino is a contributing editor to Windows Developer Network and MSDN Magazine, and the author of several books for Microsoft Press including Building Web Solutions with ASP.NET and ADO.NET and Applied XML Programming for .NET. Contact Dino at [email protected].



Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.