|
AJAX and JavaScript: The Technologies Explained
Fuelled by the increased interest in Web 2.0, AJAX (Asynchronous JavaScript Technology and XML) is attracting the attention of businesses all round the globe.
One of the main reasons for the increasing popularity of AJAX is the
scripting language used – JavaScript (JS) which allows for a number of
advantages including: dynamic forms to include built-in error checking,
calculation areas on pages, user interaction for warnings and getting
confirmations, dynamically changing background and text colours or
"buttons", reading URL history and taking actions based on it, open and
control windows, providing different documents or parts based on user
request (i.e., framed vs. non-framed).
AJAX is not a technology; rather, it is a collection of technologies
each providing robust foundations when designing and developing web applications:
- XHTML or HTML and Cascading Style Sheets (CSS) providing the standards for representing content to the user.
- Document Object Model (DOM) that provides the
structure to allow for the dynamic representation of content and
related interaction. The DOM exposes powerful ways for users to access
and manipulate elements within any document.
- XML and XSLT that provide the formats for data to be manipulated, transferred and exchanged between server and client.
- XML HTTP Request: The main disadvantages of
building web applications is that once a particular webpage is loaded
within the user’s browser, the related server connection is cut off.
Further browsing (even) within the page itself requires establishing
another connection with the server and sending the whole page back even
though the user might have simply wanted to expand a simple link. XML
HTTP Request allows asynchronous data retrieval or ensuring that the
page does not reload in its entirety each time the user requests the
smallest of changes.
- JavaScript (JS) is the scripting language that
unifies these elements to operate effectively together and therefore
takes a most significant role in web applications.
As such, AJAX is meant to increase interactivity, speed, and
usability. The technologies have prompted a richer and friendly
experience for the user as web applications are designed to imitate
‘traditional’ desktop applications including Google Docs and
Spreadsheets, Google Maps and Yahoo! Mail.
At the start of a web session, instead of loading the requested
webpage, an AJAX engine written in JS is loaded. Acting as a
“middleman”, this engine resides between the user and the web server
acting both as a rendering interface and as a means of communication
between the client browser and server.
The difference which this functionality brings about is instantly
noticeable. When sending a request to a web server, one notices that
individual components of the page are updated independently
(asynchronous) doing away with the previous need to wait for a whole
page to become active until it is loaded (synchronous).
Imagine webmail – previously, reading email involved a variety of
clicks and the sending and retrieving of the various frames that made
up the interface just to allow the presentation of the various emails
of the user. This drastically slowed down the user’s experience. With
asynchronous transfer, the AJAX application completely eliminates the
“start-stop-start-stop” nature of interaction on the web – requests to
the server are completely transparent to the user.
Another noticeable benefit is the relatively faster loading of the
various components of the site which was requested. This also leads to
a significant reduction in bandwidth required per request since the web
page does not need to reload its complete content.
Other important benefits brought about by AJAX coded applications
include: insertion and/or deletion of records, submission of web forms,
fetching search queries, and editing category trees - performed more
effectively and efficiently without the need to request the full HTML
of the page each time.
AJAX Vulnerabilities
Although a most powerful
set of technologies, developers must be aware of the potential security
holes and breeches to which AJAX applications have (and will) become
vulnerable.
According to Pete Lindstrom, Director of Security Strategies with
the Hurwitz Group, Web applications are the most vulnerable elements of
an organization’s IT infrastructure today. An increasing number of
organizations (both for-profit and not-for-profit) depend on
Internet-based applications that leverage the power of AJAX. As this
group of technologies becomes more complex to allow the depth and
functionality discussed, and, if organizations do not secure their web
applications, then security risks will only increase.
Increased interactivity within a web application means an increase
of XML, text, and general HTML network traffic. This leads to exposing
back-end applications which might have not been previously vulnerable,
or, if there is insufficient server-side protection, to giving
unauthenticated users the possibility of manipulating their privilege
configurations.
There is the general misconception that in AJAX applications are
more secure because it is thought that a user cannot access the
server-side script without the rendered user interface (the AJAX based
webpage). XML HTTP Request based web applications obscure server-side
scripts, and this obscurity gives website developers and owners a false
sense of security – obscurity is not security. Since XML HTTP requests
function by using the same protocol as all else on the web (HTTP),
technically speaking, AJAX-based web applications are vulnerable to the
same hacking methodologies as ‘normal’ applications.
Subsequently, there is an increase in session management
vulnerabilities and a greater risk of hackers gaining access to the
many hidden URLs which are necessary for AJAX requests to be processed.
Another weakness of AJAX is the process that formulates server
requests. The Ajax engine uses JS to capture the user commands and to
transform them into function calls. Such function calls are sent in
plain visible text to the server and may easily reveal database table
fields such as valid product and user IDs, or even important variable
names, valid data types or ranges, and any other parameters which may
be manipulated by a hacker.
With this information, a hacker can easily use AJAX functions
without the intended interface by crafting specific HTTP requests
directly to the server. In case of cross-site scripting, maliciously
injected scripts can actually leverage the AJAX provided
functionalities to act on behalf of the user thereby tricking the user
with the ultimate aim of redirecting his browsing session (e.g.,
phishing) or monitoring his traffic. |