Don’t go wild when you hear you can print wirelessly from your iPod, iPad or iPhone without installing any print drivers or even setting up any printer configurations. Yes, there is a Print icon among all the new standard apps on your i-device, but not only do you have to be running iOS 4.2 or higher, you also have to be within range of a wireless AirPrint compatible printer. And the only printers that fall in that category of being AirPrint compatible add up to less than a dozen models, all from HP. Once you realize that these are the limits within which you’ll be able to print, and you still want to go wild, then go right ahead.

Are you back? Good. The Print icon is beneath the Send To icon — when you tap it, a list of printers you can print to will appear. And, while there are ways to use AirPrint capabilities without an AirPrint compatible printer, which we will get to at the end of this article, let’s stay here a while and take a look at the printers that will be appearing in your AirPrint list on your i-device.

The first set of AirPrint-compatible HP printers are the Photosmart line, basic all-in-one inkjet printers intended for home use.

HP Photosmart e-AiO (D110A)

This basic printer was the first one released as AirPrint-enabled. Still priced well under $100, you can plug it in and immediately print documents, photos or fliers remotely.

HP Photosmart Plus e-AiO (B210a)

Think of this printer as an enhanced D110A that also lets you scan photos and make copies, besides printing remotely via AirPrint and from attached computers.

The next set of HP printers enabled for AirPrint out of the box is the premium Photosmart line.

  • HP Photosmart Premium e-AiO (C310a)
  • HP Photosmart Premium Fax e-AiO (C410a)
  • HP Photosmart eStation All-in-One (C510)

The C310A adds speed and capacity, while the C410a adds faxing capability. With the C510, you get full web browsing from the printer itself, a detachable full-color touchscreen, integrated wireless 802.11b/g/n and a flatbed scanner that lets you scan 3D objects and documents. Individual high-capacity ink cartridges cut down on printing costs. The C510 can even have its own email address, meaning you can email anything to the printer and have it printed immediately or stored for printing, depending on how you configure this feature..

The last set of HP AirPrint-ready printers is the LaserJet Pro line. Though all four of these printers are AirPrint capable, they do require an AirPrint firmware upgrade before becoming fully AirPrint compatible.

  • HP LaserJet Pro CP1525nw
  • HP LaserJet Pro M1536dnf
  • HP LaserJet Pro CM1415FNW
  • HP LaserJet Pro CP1525nw

Equipped with both wireless 802.11b/g/n and Ethernet networking, these energy-saving printers produce high-quality color in both photos and documents. Priced much lower than other laser-jet printers, these HP printers are a bargain, especially when you add in the AirPrint functionality for i-devices and HP’s own ePrint, which works the same as AirPrint for other mobile devices.

Now that we’ve shown you the short list of HP printers capable of AirPrint printing, we’ll turn this whole article on its head by describing how an i-device can print to any printer via use of AirPrint. AirPrint is based on Apple’s own networking protocol Bonjour/Zeroconf, the nature of which allowed reverse-engineering of the AirPrint function in the Linux world to create AirPrint Activator, software that enables AirPrint printing to any printer connected to a Mac.

There’s also an application called Printopia for Mac. This app shares any printer connected to your Mac wirelessly, allowing printing from an iPad or an iPhone. Let me repeat that: “any printer.” You can even print out to a PDF or JPG file, and save it.

So, if the question is, “What printers using AirPrint are the best?,” then the answer has to be, for any Mac user, any printer you consider the best, because you can now use AirPrint to print to any printer. PC and Windows users, however, are not that lucky — if you have an i-device, but no Mac, you’ll have to print directly via AirPrint to the HP printers listed above.

'IT' 카테고리의 다른 글

How to compare two Excel sheets for differences in values  (0) 2016.08.18
basketball  (0) 2012.11.01
Setting the secure flag in the cookie is easy  (0) 2011.12.10
Why Java Will Always Be Slower than C++  (0) 2011.12.09
a  (0) 2011.12.09
Posted by CEOinIRVINE
l

HttpOnly

Hacking 2011. 12. 10. 05:00

HttpOnly

From OWASP

Jump to: navigation, search

Contents

[hide]

Overview

The goal of this section is to introduce, discuss, and provide language specific mitigation techniques for HttpOnly.

Who developed HttpOnly? When?

According to a daily blog article by Jordan Wiens, “No cookie for you!,” HttpOnly cookies were first implemented in 2002 by Microsoft Internet Explorer developers for Internet Explorer 6 SP1. Wiens,[1]

What is HttpOnly?

According to the Microsoft Developer Network, HttpOnly is an additional flag included in a Set-Cookie HTTP response header. Using the HttpOnly flag when generating a cookie helps mitigate the risk of client side script accessing the protected cookie (if the browser supports it).

  • The example below shows the syntax used within the HTTP response header:
Set-Cookie: <name>=<value>[; <Max-Age>=<age>]
[; expires=<date>][; domain=<domain_name>]
[; path=<some_path>][; secure][; HttpOnly]

If the HttpOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script (again if the browser supports this flag). As a result, even if a cross-site scripting (XSS) flaw exists, and a user accidentally accesses a link that exploits this flaw, the browser (primarily Internet Explorer) will not reveal the cookie to a third party.

If a browser does not support HttpOnly and a website attempts to set an HttpOnly cookie, the HttpOnly flag will be ignored by the browser, thus creating a traditional, script accessible cookie. As a result, the cookie (typically your session cookie) becomes vulnerable to theft of modification by malicious script. Mitigating, [2]

Mitigating the Most Common XSS attack using HttpOnly

According to Michael Howard, Senior Security Program Manager in the Secure Windows Initiative group at Microsoft, the majority of XSS attacks target theft of session cookies. A server could help mitigate this issue by setting the HTTPOnly flag on a cookie it creates, indicating the cookie should not be accessible on the client.

If a browser that supports HttpOnly detects a cookie containing the HttpOnly flag, and client side script code attempts to read the cookie, the browser returns an empty string as the result. This causes the attack to fail by preventing the malicious (usually XSS) code from sending the data to an attacker's website. Howard, [3]

Using Java to Set HttpOnly

Sun Java EE supports HttpOnly flag in Cookie interface since version 6 (Servlet class version 3)[4], also for session cookies (JSESSIONID)[5]. Methods setHttpOnly and isHttpOnly can be used to set and check for HttpOnly value in cookies.

For older versions there the workaround is to rewrite JSESSIONID value using and setting it as a custom header[6].

String sessionid = request.getSession().getId();
response.setHeader("SET-COOKIE", "JSESSIONID=" + sessionid + "; HttpOnly");

In Tomcat 6 flag useHttpOnly=True in context.xml to force this behaviour for applications[7], including Tomcat-based frameworks like JBoss[8].

Servlet 3.0 (Java EE 6) introduced a standard way to configure HttpOnly attribute for the session cookie, this can be done by applying the following configuration in web.xml

<session-config>
 <cookie-config>
  <http-only>true</http-only>
 </cookie-config>
<session-config>
Using .NET to Set HttpOnly
  • By default, .NET 2.0 sets the HttpOnly attribute for
    1. Session ID
    2. Forms Authentication cookie


In .NET 2.0, HttpOnly can also be set via the HttpCookie object for all custom application cookies

  • Via web.config in the system.web/httpCookies element
<httpCookies httpOnlyCookies="true" …> 
  • Or programmatically

C# Code:

HttpCookie myCookie = new HttpCookie("myCookie");
myCookie.HttpOnly = true;
Response.AppendCookie(myCookie);

VB.NET Code:

Dim myCookie As HttpCookie = new HttpCookie("myCookie")
myCookie.HttpOnly = True
Response.AppendCookie(myCookie)
  • However, in .NET 1.1, you would have to do this manually, e.g.,
Response.Cookies[cookie].Path += ";HttpOnly";
Using PHP to set HttpOnly

PHP supports setting the HttpOnly flag since version 5.2.0 (November 2006).

For session cookies managed by PHP, the flag is set either permanently in php.iniPHP manual on HttpOnly through the parameter:

session.cookie_httponly = True

or in and during a script via the function[9]:

void session_set_cookie_params  ( int $lifetime  [, string $path  [, string $domain  
                                  [, bool $secure= false  [, bool $httponly= false  ]]]] )

For application cookies last parameter in setcookie() sets HttpOnly flag[10]:

bool setcookie  ( string $name  [, string $value  [, int $expire= 0  [, string $path  
                 [, string $domain  [, bool $secure= false  [, bool $httponly= false  ]]]]]] )

Web Application Firewalls

If code changes are infeasible, web application firewalls can be used to add HttpOnly to session cookies:

  • Mod_security - using SecRule and Header directives[11]
  • ESAPI WAF[12] using add-http-only-flag directive[13]

Browsers Supporting HttpOnly

Using WebGoat's HttpOnly lesson, the following web browsers have been tested for HttpOnly support. If the browsers enforces HttpOnly, a client side script will be unable to read or write the session cookie. However, there is currently no prevention of reading or writing the session cookie via a XMLHTTPRequest.

Note: These results may be out of date as this page is not well maintained. A great site that is focused on keeping up with the status of browsers is at: http://www.browserscope.org/. For the most recent security status of various browsers, including many details beyond just HttpOnly, go to the browserscope site, and then click on the Security Tab on the table at the bottom of the page. The Browserscope site does not provide as much detail on HttpOnly as this page, but provides lots of other details this page does not.

Our results as of Feb 2009 are listed below in table 1.

Table 1: Browsers Supporting HttpOnly
Browser Version Prevents Reads Prevents Writes Prevents Read within XMLHTTPResponse*
Microsoft Internet Explorer 8 Beta 2 Yes Yes Partially (set-cookie is protected, but not set-cookie2, see [14]). Fully patched IE8 passes http://ha.ckers.org/httponly.cgi
Microsoft Internet Explorer 7 Yes Yes Partially (set-cookie is protected, but not set-cookie2, see [15]). Fully patched IE7 passes http://ha.ckers.org/httponly.cgi
Microsoft Internet Explorer 6 (SP1) Yes No No (Possible that ms08-069 fixed IE 6 too, please verify with http://ha.ckers.org/httponly.cgi and update this page!)
Microsoft Internet Explorer 6 (fully patched) Yes Unknown Yes
Mozilla Firefox 3.0.0.6+ Yes Yes Yes (see [16])
Netscape Navigator 9.0b3 Yes Yes No
Opera 9.23 No No No
Opera 9.50 Yes No No
Opera 11 Yes Unknown Yes
Safari 3.0 No No No (almost yes, see [17])
Safari 5 Yes Yes Yes
iPhone (Safari) iOS 4 Yes Yes Yes
Google's Chrome Beta (initial public release) Yes No No (almost yes, see [18])
Google's Chrome 12 Yes Yes Yes
Android Android 2.3 Unknown Unknown No

* An attacker could still read the session cookie in a response to an XmlHttpRequest.

As of 2011, 99% of browsers and most web application frameworks do support httpOnly<ref>Misunderstandings on HttpOnly Cookie</ref>.

Using WebGoat to Test for HttpOnly Support

The goal of this section is to provide a step-by-step example of testing your browser for HttpOnly support.

WARNING

The OWASP WEBGOAT HttpOnly lab is broken and does not show IE 8 Beta 2 with ms08-069 as complete in terms of HttpOnly XMLHTTPRequest header leakage protection. This error is being tracked via http://code.google.com/p/webgoat/issues/detail?id=18.

Getting Started

Figure 1 - Accessing WebGoat's HttpOnly Test Lesson

Assuming you have installed and launched WebGoat, begin by navigating to the ‘HttpOnly Test’ lesson located within the Cross-Site Scripting (XSS) category. After loading the ‘HttpOnly Test’ lesson, as shown in figure 1, you are now able to begin testing web browsers supporting HTTPOnly.

Lesson Goal

If the HttpOnly flag is set, then your browser should not allow a client-side script to access the session cookie. Unfortunately, since the attribute is relatively new, several browsers may neglect to handle the new attribute properly.

The purpose of this lesson is to test whether your browser supports the HttpOnly cookie flag. Note the value of the unique2u cookie. If your browser supports HTTPOnly, and you enable it for a cookie, a client-side script should NOT be able to read OR write to that cookie, but the browser can still send its value to the server. However, some browsers only prevent client side read access, but do not prevent write access.

Testing Web Browsers for HttpOnly Support

The following test was performed on two browsers, Internet Explorer 7 and Opera 9.22, to demonstrate the results when the HttpOnly flag is enforced properly. As you will see, IE7 properly enforces the HttpOnly flag, whereas Opera does not properly enforce the HttpOnly flag.

Disabling HttpOnly
1) Select the option to turn HttpOnly off as shown below in figure 2.
Figure 2 - Disabling HttpOnly
2) After turning HttpOnly off, select the “Read Cookie” button. 
  • An alert dialog box will display on the screen notifying you that since HttpOnly was not enabled, the ‘unique2u’ cookie was successfully read as shown below in figure 3.
Figure 3 - Cookie Successfully Read with HttpOnly Off
3) With HttpOnly remaining disabled, select the “Write Cookie”  button.
  • An alert dialog box will display on the screen notifying you that since HttpOnly was not enabled, the ‘unique2u’ cookie was successfully modified on the client side as shown below in figure 4.
Figure 4 - Cookie Successfully Written with HttpOnly Off
  • As you have seen thus far, browsing without HttpOnly on is a potential threat. Next, we will enable HttpOnly to demonstrate how this flag protects the cookie.
Enabling HttpOnly
4) Select the radio button to enable HttpOnly as shown below in figure 5.
Figure 5 - Enabling HttpOnly
5) After enabling HttpOnly, select the "Read Cookie" button.
  • If the browser enforces the HttpOnly flag properly, an alert dialog box will display only the session ID rather than the contents of the ‘unique2u’ cookie as shown below in figure 6.
Figure 6 - Enforced Cookie Read Protection
  • However, if the browser does not enforce the HttpOnly flag properly, an alert dialog box will display both the ‘unique2u’ cookie and session ID as shown below in figure 7.
Figure 7 - Unenforced Cookie Read Protection
  • Finally, we will test if the browser allows write access to the cookie with HttpOnly enabled.
6) Select the "Write Cookie" button.
  • If the browser enforces the HttpOnly flag properly, client side modification will be unsuccessful in writing to the ‘unique2u’ cookie and an alert dialog box will display only containing the session ID as shown below in figure 8.
Figure 8 - Enforced Cookie Write Protection
  • However, if the browser does not enforce the write protection property of HttpOnly flag for the ‘unique2u’ cookie, the cookie will be successfully modified to HACKED on the client side as shown below in figure 9.
Figure 9 - Unenforced Cookie Write Protection
Posted by CEOinIRVINE
l
TechRepublic had an interesting article about the Surf Jack attack. Many people commented, some giving their own solution to the problem. However many of these solutions do not prevent the attack because they do not really address it. Of course, who ever missed the details should check out the paper.

The attack has been addressed quite a while ago, and the solution is easy to implement in many occasions. So no need to reinvent the wheel or create a new solution which has not been peer reviewed yet. Here I'll indicate how to set the secure flag in various languages / web application technologies. The idea is that besides making use of HTTPS instead of HTTP, one needs to set a flag in the cookie so that it cannot be leaked out in clear text.

PHP

bool setcookie ( string $name [, string $value [, int $expire [, string $path [, string $domain [, bool $secure [, bool $httponly ]]]]]] )

Note that the $secure boolean should be set to true.



Cookie helloCookie = new Cookie("name",text);
helloCookie.setSecure(true);

ASP.NET
HttpCookie cookie = new HttpCookie('name');
cookie.Secure = True;
cookie.Value = 'Joe';

Perl with CGI.pm

(added by Noam)
$cookie = cookie(-name=>’sessionID’,
-value=>’xyzzy’,
-expires=>’+1h’,
-path=>’/cgi-bin/database’,
-domain=>’.capricorn.org’,
-secure=>1);

'IT' 카테고리의 다른 글

basketball  (0) 2012.11.01
The Best AirPrint Compatible Printers  (0) 2011.12.23
Why Java Will Always Be Slower than C++  (0) 2011.12.09
a  (0) 2011.12.09
Information Security Interview Questions  (0) 2011.12.05
Posted by CEOinIRVINE
l