You are on page 1of 9

NETWORK SECURITY

ABSTRACT implemented by web developers using

Typical web sessions can be only JavaScript and simple server-side

hijacked easily by a network logic. Its performance impact is

eavesdropper in attacks that have come to negligible, and all major web browsers

be designated “side jacking.” The rise of are supported. Interestingly, it is

ubiquitous wireless networks, often particularly easy to implement on single-

unprotected at the transport layer, has page AJAX web applications, e.g. Gmail

significantly aggravated this problem. or Yahoo mail, with approximately 200

While SSL can protect against lines of JavaScript and 60 lines of server-

eavesdropping, its usability disadvantages side verification code.

often make it unsuitable when the data is


not considered highly confidential. Most INTRODUCTION
web-based email services, for example, The core component
use SSL only on their login page and are of the World Wide Web, HTTP began its
thus vulnerable to side jacking. We life as a stateless protocol. To provide a
propose Session Lock, a simple approach personalized user experience, early web
to securing web sessions against “sessions” were implemented using
eavesdropping without extending the use tokens inserted into individual URLs.
of SSL. Session Lock is easily Token made web sessions fairly
unreliable. Over the years, in order to • A secure flag, indicating whether this
protect users’ security and privacy, the cookie should
details of cookie handling have become Only be sent back over SSL,
quite intricate, but the basic functionality • The domain, so that foo.example.com
remains: the server assigns the browser a and example.com
token, and the browser sends this token Can share cookies if they so choose,
back to that specific server on every • The path, so that different sections of a
subsequent request. site, e.g. /foo/*and /bar/* can have
1.Web sessions are vulnerable to different cookies.
eavesdropping On every subsequent request, the web
2.Wi-fi networks make things wors client will include all the pertinent name-
3.SSL is not for everyone value pairs it has received from that
4.Better security without SSL specific server. The security of these data
5.Getting Closer to User Intuition is highly dependent on the transport
One goal of Session Lock layer: cookies sent over HTTP are easily
is to make sure that reality matches this accessible to a network eavesdropper.
intuition more closely: having one’s
HTTP traffic overheard is still a concern, 2. Digest Authentication:
but having one’s session Hijacked is not. HTTP offers
protocol-level authentication, including
CURRENT PRACTICES the particularly interesting digest mode in

1.Web Sessions: digest auth, just like in plain auth, the

Maintaining web session web browser provides a distinct user

state requires having the web client interface to prompt the user for her

provide some unique identifier to the web username and password. Unlike in plain

server on every request, so that the server auth, digest auth provides a challenge-

can identity each HTTP request more response mechanism.

precisely. In 1995, web browsers support For sending along the password,

cookies, which allow a web server to send, which ensures that a network

in an HTTP response, a special header: eavesdropper cannot extract the

Set-Cookie: session_id=8b3xdvdf3jg; password. Web services could use digest

This header can also specify a number of auth as a way to secure sessions against

additional fields, including: eavesdropping. Unfortunately, by most

• An expiration date, web services for a number of reasons


HTTP authentication, even in digest the SSL certificate handshake occurs
mode, is not likely to provide a deployable before the browser is able to specify a
defense against eavesdropping. virtual hostname . In addition, an SSL
server must deliver all resources,
3. Locking Sessions to IP Address including static graphical layout elements
One natural that typically require no protection,
reaction to the eavesdropping problem is under computationally intensive SSL in
to bind web sessions to the user’s IP order to prevent browser warnings about
address at the time of session initiation: if mixed content. This typically prohibits
a session token is received from a the use of latency-reducing, geography-
different based caching by content-delivery
IP address, the web server can prompt networks. In addition, web browsers
the user to re-authenticate. behave differently under SSL.

BUILDING BLOCKS
The technical
components are simple and require only
a cursory explanation
1.Fragment Identifier:
The URL specification
defines the fragment identifier, the portion
of the URL that follows the # character.

Figure 1: The Session Lock Protocol As its name implies, the fragment
identifier designates a portion of the
4. SSL
resource. For example, consider the
SSL provides end-to-end
followingURL:
encryption between the web server and
http://host/of/url#paragraph4
browser, clearly foiling passive
Here, #paragraph4 is
eavesdroppers. Unfortunately, SSL
the fragment identifier. When the
requires more work on the server side
primary resource, in this case
and, more importantly, triggers a number
http://host/rest/of/url,is an HTML
of sub-optimal behaviors on the client
document, the fragment identifier tells
side. An SSL server must run on its own
the browser to scroll the viewport to the
IP address (no virtual hosting), because
section of the document that reads:
<div id="paragraph4"> 2. the web browser uses this secret token
... to authenticate, using HMAC, every
</div> subsequent, time-stamped plain HTTP
When no such portion of the document request it makes.
exists, the browser doesn’t scroll, and the 3. the session token is never sent over the
fragment identifier remains in the URL, network in the clear: it is communicated
unused from the SSL login page to the first plain
HTTP page, and to each subsequent plain
2.Authenticating Web Requests with HTTP page hereafter, using the URL
HMAC fragments identifier.
Simple message 4. an attacker limited to eavesdropping
authentication between two parties with a capabilities never sees the session secret
shared secret is easily achievable using a and cannot generate valid HTTP requests
Message Authentication Code (MAC) on behalf of another user’s session, other
algorithm. In particular, HMAC is a than the ones it intercepts.
hash-function-based message We now provide additional detail for the
authentication technique which is easily above outline.
implemented and quite efficient in just
about any programming environment, 1.Generating the Secret Token
including browser-based JavaScript. A Alice visits her web
number of web-based APIs, including mail site, example.com. She is directed to
Google APIs and the Face book Platform a login page over SSL, where she enters
already use HMAC for authenticating her username and password. The server
requests. sets up her session, sets a non-SSL
session_id cookie, then an SSL-only
cookie session secret, and redirects Alice
THE SESSION LOCK
to
PROTOCOLS http://example.com/login/done#[session_s
At a high level, Session Lock ecret]Because this redirect command is
functions as follows: sent to Alice’s browser over SSL, its
1. at login time over SSL, the web server content is secure against eavesdropping.
delivers a session secret to the web Then, when Alice’s browser loads the
browser. new, non-SSL URL, the session_secret
remains secure from eavesdropping,
because is located inside the fragment Once these modifications are done, the
identifier and thus not sent over the event proceeds as initially requested, only
network. with two new parameters that
authenticate the request to the server.
For AJAX requests, JavaScript can
2.Keeping the Session Secret Around intercept all calls toXMLHttpRequest to
To keep the achieve exactly the same task. Once
session_secret around from one page to again, it appears that Session Lock is
another, it must be appended as a easier to implement with AJAX
fragment identifier to every URL the user applications.
navigates within the web application.
Importantly, this cannot be done on the 4.Recovering From Failure
server side, as it would then be available Because of our ad-hoc
to the eavesdropper when the HTML is approach to communicating the session
transferred over plain, unencrypted secret from one page to another, it is
HTTP. The appending of the session conceivable that the session secret will be
secret can only be done on the client side lost. The user might type in a URL
using JavaScript.Thus, upon page load, Manually, click a bookmark, or otherwise
Session Lock JavaScript code traverses access the service without the session
the page, appending the fragment secret in the fragment identifier. To force
identifier to every clickable link and the user to re-login at this point would
every form target. break existing expectations for web
services. Fortunately, it is easy to recover
3.Time stamping and HMAC the session secret, using an IFRAME that

With the session secret accesses a small SSL page that minimally

in JavaScript scope, we must then ensure affects the user experience. The web page,

that every HTTP request is augmented noticing that it does not have a session

with a HMAC.For clickable links and secret, opens up an invisible

form submissions, a JavaScript event IFRAME with the SSL URL

Handler intercepts the user request, https://example.com/login/recover. The

appends a timestamp parameter, document in the IFRAME is tiny:

generates the HMAC on the entire <script language="JavaScript">

request line, and adds a second parameter Document. Location =

with this HMAC as its value. ‘http://example.com/login/recover# [’ +


get_cookie (‘session_secret’) + ‘]’; the HTML, only on the links that
</script> explicitly need authentication:
<a href="next.html"
This code, which runs in the SSL scope, Onclick="sessionlock_patch(this) ;">
simply recovers the session secret from Next page
the SSL-only cookie, and then redirects </a>
the browser to the plain HTTP portion of This approach will increase the size of the
the site with the secret in the fragment HTML a bit while speeding up the
identifier. This recovery protocol is JavaScript execution significantly, since
diagrammed in Figure. no Session Lock code is executed until the
user clicks a links, and even then only a
small amount. In addition, with
application level involvement, only links
that require authentication will be
patched.

2.Local Browser Storage


The latest versions of Internet Explorer
and Firefox, which together cover about
95% of web users , both offer simple
Figure 2: If the secure token is lost for any reason mechanisms for client-side data storage
(1), it can be recovered from the HTTPS cookie
using a dynamically generated IFRAME (2), which that is never automatically sent over the
looks up the cookie and redirects the IFRAME to a
non-SSLURL with the token in the fragment network, respectively window.userData
identifier (3), which can then pass the token back
up to the calling frame (4). In a production and window.globalStorage. In addition,
implementation, the IFRAME would be made
invisible since the it requires no user interaction.
the upcoming HTML5 specification
standardizes this JavaScript API for
EXTENSIONS client-side, domain-specific data storage
The basic Session Lock along the lines of Firefox’s
protocol can be extended to support implementation. Safari, the third
alternate use cases. largestbrowser, is expected to implement
1.Optimizing Link Setup: this API, making clientsidestorage a
If the web application is virtual certainty in the near future. In
built with Session locking mind, then this HTML5, the following JavaScript code
click handler can be added explicitly in
stores data: global storage passing on the secret from one page to the
[‘example.com’].session_key = next uses either the fragment identifier or
‘8xk3jsldf’; which can later be retrieved the local-browser storage as explained
by another page from the same above.
Domain using the following code: 4. if the browser loses its secret, it can re-
do_stuff_with_key perform a Diffie-Hellman key exchange
(GlobalStorage with the server, using a number of XML
[‘example.com’].session_key); Http Request calls.
Local browser storage cannot solve
everything on its own: it cannot be used
Effects of typical web user
to transfer the session secret from the
HTTPS session-setup URL to the HTTP
behavior:
post-login URL,because those two URLs With the session secret now a

are of different origins, and clientsidedata necessary portion of navigation, we must

stored while at an SSL URL cannot be consider the side-effects of carrying this

read by JavaScript from a non-SSL URL, secret as a fragment within every page.

even if they share the same domain.


1.Page Reload:

3.No SSL Whatsoever Page reload is explicitly

We can implement Session supported by SessionLock: the token

Lock without any SSL, even on the login stays in the URL as a fragment identifier,

page. On session setup the following steps and an on load JavaScript event handler

are taken: captures it on reload exactly the way it

1. The server assigns the browser a was captured on first load. In this case, a

session cookie. Session Lock web server returns a

2. The client-side JavaScript code initiates JavaScript page that locally recreates a

a Diffie-Hellman Key-exchange with the freshly time stamped version of the same

server, effectively generating a shared URL, then uses document .location

secret between the browser JavaScript .replace to reload the page with the

scopes and the server. appropriate authentication.

3. This shared secret becomes the HMAC


key used in the Session Lock protocol, 2.Book marking:

with the server storing the secret in a Book marking a page that

server-side session, and the browser uses SessionLockwill include the


timestamp and HMAC at the time of the cannot work without. Thus, Session-
book marking action. When the page is Lock should be reserved for web
later reloaded, it is almost certain that the applications that already require
timestamp will be outdated. In this case, JavaScript.
the Session Lock server can behave
exactly as in the page-reload case, issuing 2.No Defense against Active Attacks:
JavaScript code that, within the browser SessionLock does notprotect
generates a freshly time stamped and against active network attacks. An
HMAC’ed URL. active attacker can trivially inject
code in a plain HTTP URL, steal the
3. Sending to a friend, social book session secret and hijack the session.
marking. We make no attemptto “fix” this issue
If a user sends a Session Lock- in this work: we are solely trying to
augmented link to a friend via email, or addressthe “side jacking” attack,
especially if she posts it to a social book which is far too easy to launch
marking site, she runs the risk of without leaving a trace.
revealing her session secret. If a recipient
of this session secret is also on the same
local network and can find her plain CONCLUSION
HTTP session_id cookie, the user’s Using the existing HTTP
session maybe fully compromised. fragment identifier feature to create a
Although it is unlikely that a user would secure, client-side channel between
post a protected link to a social book HTTPS and HTTP, we have designed and
marking site, this issue merits further implemented Session Lock, a way to
careful consideration. protect plain HTTP sessions from
eavesdropping. We believe our proposal
LIMITATIONS is relatively easy to implement, especially

Session Lock suffers from two important in the case of heavily AJAX-enabled

limitations thatshould be carefully noted. applications such as Gmail. In fact, it


appears that Gmail HTTP sessions can be

1. JavaScript Required: secured with minimal web-application-

SessionLock is entirely level code and negligible performance

dependent on JavaScript: it simply overhead. We note the appeal of


solutions, like Session Lock, which use
only web-application-level modifications:
they can be deployed immediately by web
developers. We hope that exploration of
improved security features using only the
existing Web stack will be informative to
the improvement of the web browser as
an extensible platform for security.

REFERENCES:
1.Whitfield Diffie and Martin E. Hellman.
New directions in cryptography. IEEE
Transactions on Information Theory
http://www.ietf.org/rfc/rfc.txt.

2.Jesse James Garrett. Ajax: A New


Approach to Web Applications

3.Paul Johnston. A JavaScript


implementation of the Secure Hash
Algorithm.
http://pajhome.org.uk/crypt/md5.
4.Message Authentication Code.
http://en.wikipedia.org/wiki/Message_aut
hentication_code.

You might also like