<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Security Viewpoints &#187; Little-known features</title>
	<atom:link href="http://advosys.ca/viewpoints/category/little-known-features/feed/" rel="self" type="application/rss+xml" />
	<link>http://advosys.ca/viewpoints</link>
	<description>Security, operating systems and the IT industry</description>
	<lastBuildDate>Wed, 30 Jun 2010 14:18:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Little known features: HTTP digest authentication</title>
		<link>http://advosys.ca/viewpoints/2006/08/http-digest-authentication/</link>
		<comments>http://advosys.ca/viewpoints/2006/08/http-digest-authentication/#comments</comments>
		<pubDate>Tue, 22 Aug 2006 21:39:49 +0000</pubDate>
		<dc:creator>D Webber</dc:creator>
				<category><![CDATA[Little-known features]]></category>
		<category><![CDATA[Web security]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://advosys.ca/viewpoints/2006/08/http-digest-authentication/</guid>
		<description><![CDATA[Most people are aware they should check for an SSL connection when logging into a banking web site or other sensitive web application. The little yellow padlock and &#34;https://&#34; prefix are supposed to indicate the web site is &#34;secure&#34; and no one can compromise your sensitive data.
SSL is the only choice for protecting web content [...]]]></description>
			<content:encoded><![CDATA[<p>Most people are aware they should check for an SSL connection when logging into a banking web site or other sensitive web application. The little yellow padlock and &quot;https://&quot; prefix are supposed to indicate the web site is &quot;secure&quot; and no one can compromise your sensitive data.</p>
<p>SSL is the only choice for protecting web content in transit and verifying the identity of the server. However, often SSL is used when the only data that must be protected are usernames and passwords. Public discussion forums, public web mail and blogs are examples:&nbsp; the content is already public so encrypting that data with SSL is pointless. All that is really needed for those types of applications is protection against interception of username and passwords.</p>
<p>The encryption routines of SSL seriously tax a web server when under load. Yahoo Mail, for example, avoids this overhead by using SSL only to encrypt the login page then switches to unencrypted HTTP after that.</p>
<p>There are many times when just the login credentials need to be protected. Acquiring a costly SSL server certificate from a certificate authority then writing the web app to use it only for authentication is overkill. Even with SSL is in place, the web application typically stores usernames and passwords in a database in clear text. An attacker breaking into the server has access to the authentication credentials of every user.</p>
<p>HTTP <a title="HTTP Digest authentication" target="_blank" href="http://en.wikipedia.org/wiki/Digest_access_authentication">digest authentication</a> is a little-known standard built into all the major web servers and web browsers. With it, login credentials are never transmitted across the network, nor are they stored on the server in plain text. There is no need to purchase an expensive SSL host certificate each year, nor worry about CPU load due to crypto processing overhead.&nbsp; The web server performs authentication, removing the need to develop that code in the web application itself. The application only has to verify that authentication has taken place.</p>
<p><span id="more-34"></span></p>
<p><!--more--></p>
<p>Digest authentication is not the same as it&#8217;s older, dumber brother <a title="HTTP Basic authentication" href="http://en.wikipedia.org/wiki/Basic_authentication_scheme" target="_blank">Basic authentication</a>. Web servers and browsers have always supported Basic authentication, where username and password are transmitted in easily-decoded Base64 and must be stored on the server in plain text. Digest authentication looks similar from the user&#8217;s perspective&#8230; the browser pops up a dialog box asking for username and password, but under the hood the protocol uses hashes instead of plain text.</p>
<p>Likewise, Digest authentication is not the same as it&#8217;s evil cousin <a title="Microsoft NTLM authentication" target="_blank" href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/1aa70bfa-add5-4f61-9c7b-a095c1bd4306.mspx?pf=true">NTLM authentication</a>. Microsoft&#8217;s proprietary LAN Manager authentication (now dubbed &quot;Integrated Windows Authentication&quot;) doesn&#8217;t transmit credentials in plain text, but requires a continuous TCP connection between server and client, violating the stateless nature of the HTTP protocol. NTLM has a hard time traversing most web proxies and load balancers (ironically, the only reliable way to get NTLM to do that is encapsulate it in SSL). Although it&#8217;s now semi-supported now in non-Microsoft browsers such as Firefox, NTLM is proprietary and not an Internet standard.</p>
<h4>How Digest authentication works</h4>
<p>Digest authentication is a challenge-response mechanism:</p>
<ul>
<li>The browser sends an HTTP request (e.g. a GET) to a web server</li>
<li>The server sees the URL being accessed has been configured to require Digest authentication and replies with a 401 &quot;Authentication Required&quot; status plus a &quot;nonce&quot;: a unique hash of several data items, one of which is a secret key known only to the server.</li>
<li>The browser pops up a dialog box requesting username and password. Once the user enters their information, an MD5 hash of the username, password, nonce and URL are computed and the browser re-sends the original request along with the hash.</li>
<li>The web server compares that hash with it&#8217;s own computation of the same values. If they match, the original HTTP request is allowed to complete.</li>
</ul>
<p>For a complete explanation of Digest authentication see <a title="RFC 2617 - Digest authentication" href="http://www.faqs.org/rfcs/rfc2617.html" target="_blank">RFC 2617</a>, but the idea is that since hashes are used instead of the actual data, an eavesdropper intercepting the communications never sees the username or password.</p>
<p>Replay attacks where the interceptor sends the exact same data at a later time are prevented in several ways. In the Apache web server, a unique nonce is generated for each 401 message and incorporates time and other information to prevent replays.</p>
<h4>How to use it</h4>
<p>Digest authentication is applied to specific URLs or physical directories on your web site. One convenient aspect is that protecting one directory usually results in Digest authentication being automatically applied to all lower directories as well. The specifics of implementing Digest authentication depend on the particular web server:</p>
<ul>
<li><a title="Apache Digest authentication" target="_blank" href="http://httpd.apache.org/docs/1.3/howto/auth.html#digest">Apache Digest authentication</a></li>
<li><a name="IIS 6.0 Digest authentication" target="_blank" href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/1f11d8df-95b6-4e79-b0e3-adaa61e3d3d0.mspx?pf=true">IIS 6.0 Digest authentication</a></li>
</ul>
<p>For Apache, a text file is used to store the username in plain text plus an MD5 hash of the password.  Credentials can also be stored in a database using Apache modules such as mod_authn_dbi from the <a name="Apache 2.1 authentication project" target="_blank" href="http://mod-auth.sourceforge.net/">2.1 Authentication Project.</a></p>
<h4>Rolling your own</h4>
<p>Many web developers try to create their own authentication mechanism rather than use standard mechanism, sometimes for no other reason than they dislike appearance of the browser&#8217;s password pop-up dialog box. Many prominent web sites <a title="A Day in the Life of an Information Security Investigator: Look At All Of These Passwords!" target="_blank" href="http://blogs.ittoolbox.com/security/investigator/archives/look-at-all-of-these-passwords-11240">don&#8217;t even bother</a> to try preventing sending username and password in the clear.</p>
<p>Some developers are more vigilant and try to roll their own hash mechanism to perform authentication. However, this involves writing either Javascript, a Java applet, ActiveX or similar on the client side to compute the hashes, plus a matching component in the server app. Cryptography is tricky. Even when it&#8217;s only using a cryptographic hash to verify credentials it takes care, time and effort to get it right. For example, we show what&#8217;s required to to use HMAC digesting to protect web forms in our paper <a title="Preventing HTML form tampering" target="_blank" href="http://advosys.ca/papers/form-tampering.html">Preventing HTML form tampering</a>.</p>
<p>It&#8217;s much easier and more reliable to use the Digest mechanism that already exists in popular web browsers and servers. The dialog presented to the user is not pretty, but Digest authentication it can be implemented in nearly zero development time, with the added benefit that the implementation is more likely to be free of serious errors.</p>
<p>One recommendation: when writing a web app that relies on the web server to perform authentication, it&#8217;s a very good idea for the application to verify authentication has taken place. The default state for web servers is to allow access to a URL&#8230; only a single configuration directive causes the server to prompt for a username.</p>
<p>In Apache when a user has been authenticated the environment variable &quot;REMOTE_USER&quot; is set with the username. The web app should test for that and display an error if it&#8217;s not present. It&#8217;s too easy for a web server configuration mistake to disable the authentication prompt and allow wide open access to data: an additional check that authentication has occurred should exist in the web application itself.</p>
<h4>Other caveats and gotchas</h4>
<p>Digest authentication is appropriate where you need to protect <em>only</em> the username and password from compromise. When the actual content must be protected (i.e. form data sent from the browser) or when the user needs strong assurance that they are connecting to the right server (e.g. a bank), SSL is required.</p>
<p>Also, Digest authentication is of course single factor and thus subject to all the weaknesses of traditional username / password authentication. If strong authentication of the client is needed, look into implementing SSL client certificates or another two-factor mechanism.</p>
<p>I should also mention (before everyone else does) that the MD5 has algorithm has been shown to be cryptographically weaker than previously thought. A &quot;collision&quot; (an identical hash from different data) can be found in less time than it should. MD5 hashes are still considered strong, but the crypto community sees this discovery as a sign that it&#8217;s time to start moving to other mechanisms like SHA-256. However, because of the way MD5 hashes are used (e.g. combining them with a short-lived nonce), the issue doesn&#8217;t really affect Digest authentication.</p>
<p>Protecting the login credentials is often all that many web applications need. In those situations, Digest authentication provides an good lightweight authentication mechanism. It is a published standard supported by all major web servers and recent browsers, provides good protection against interception, and removes both the need to code your own login mechanism and to store usernames and passwords in plain text on the server.</p>
Copyright &copy; 2010 <a href="http://advosys.ca/">Advosys Consulting Inc.</a>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://advosys.ca/viewpoints/2006/08/http-digest-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing SSL with command line tools</title>
		<link>http://advosys.ca/viewpoints/2006/08/testing-ssl-with-command-line-tools/</link>
		<comments>http://advosys.ca/viewpoints/2006/08/testing-ssl-with-command-line-tools/#comments</comments>
		<pubDate>Wed, 16 Aug 2006 23:16:59 +0000</pubDate>
		<dc:creator>D Webber</dc:creator>
				<category><![CDATA[Little-known features]]></category>
		<category><![CDATA[Vulnerability assessment]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[web security]]></category>

		<guid isPermaLink="false">http://advosys.ca/viewpoints/2006/08/testing-ssl-with-command-line-tools/</guid>
		<description><![CDATA[In an post over at the excellent TaoSecurity blog, Richard writes about discovering nssl, an SSL-capable version of netcat. A reader reminded him that the openssl command line utility can also act as an ad hoc SSL client like so

openssl s_client -connect www.example.com:443

The above lets you connect via SSL to a web server and manually [...]]]></description>
			<content:encoded><![CDATA[<p>In an post over at the excellent <a href="http://taosecurity.blogspot.com/" target="_blank" title="Richard Bejtlich's TaoSecurity blog">TaoSecurity</a> blog, Richard <a href="http://taosecurity.blogspot.com/2006/08/nssl.html" target="_blank" title="TaoSecurity nssl">writes about</a> discovering <a href="http://sourceforge.net/projects/nssl" target="_blank" title="nssl - SSL enabled netcat">nssl</a>, an SSL-capable version of netcat. A reader reminded him that the openssl command line utility can also act as an ad hoc SSL client like so</p>
<blockquote>
<pre>openssl s_client -connect www.example.com:443</pre>
</blockquote>
<p>The above lets you connect via SSL to a web server and manually type HTTP commands just like you can with non-SSL web servers using plain old netcat and telnet.</p>
<p>The OpenSSL command-line utility is a swiss army knife for encryption protocols. You can use it for far more than just generating keys and connecting to SSL servers. But there are also many other command-line tools that are incredibly useful for SSL testing and discovery purposes:<span id="more-27"></span></p>
<ul>
<li>Gnu <a href="http://www.gnu.org/software/wget/" target="_blank" title="GNU wget">wget</a> can fetch HTTPS URLs, if it has been compiled with SSL support. To view the HTTP response headers, try wget -S</li>
<li><a href="http://lynx.browser.org/" target="_blank" title="Lynx text-based web browser">Lynx</a> and <a href="http://elinks.or.cz/" target="_blank" title="eLinks text-based web browser">elinks</a> text-based web browsers (again, assume they have been compiled with SSL support)</li>
<li><a href="http://www.webdav.org/cadaver/" target="_blank" title="Cadaver - WebDAV command-line client">Cadaver</a> for SSL-enabled <a href="http://www.webdav.org/" target="_blank" title="WebDAV publishing protocol">WebDAV</a> servers</li>
<li><a href="http://www.stunnel.org/" target="_blank" title="stunnel SSL tunnel daemon">stunnel</a> for tunnelling any traffic through SSL</li>
<li><a href="http://www.rtfm.com/ssldump/" target="_blank" title="SSLDump SSL traffic sniffer">ssldump</a> for sniffing and decrypting SSL traffic</li>
</ul>
<p>SSL tools like these are valuable for assessing more than just web servers. About a year ago we had a contract to do a security assessment of <a href="javascript:void(window.open('http://www.cisco.com/en/US/products/sw/secursw/ps5057/index.html','','resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no'))" title="Cisco Security Agent host intrusion prevention system">Cisco Security Agent</a> (a host intrusion prevention tool originally developed by &quot;Okena&quot;). After a bit of network sniffing and poking around the server directories, it turned out that CSA client and server communicate using HTTP encrypted with SSL over a non-standard port (a huge number of commercial products use simple HTTP and SSL as their client-server protocol. They just run it on a port other than 443 to disguise the fact).</p>
<p>To evaluate how robust the client and server were to attack, we used ssldump to decrypt and the raw HTTP traffic (this was possible only because the CSA server held the SSL host key).</p>
<p>Once we could capture the raw HTTP and understood how requests were formatted, we used openssl, stunnel and other tools to capture and replay communications between server and client, spoof traffic, impersonate endpoints, and &quot;fuzz&quot; the communications looking for overflows and other obvious vulnerabilities. The product withstood attack fairly well.</p>
<p>Were it not for the availability of these command-line tools, especially ssldump, performing the vulnerability assessment would been much more limited and involved coding a lot of custom SSL clients using something like Perl and the <a href="http://search.cpan.org/~gaas/libwww-perl-5.800/lib/LWP.pm" target="_blank" title="Perl LWP web client module">LWP</a> library.</p>
<p>It always bugs me when vendors use the word &quot;secure&quot; when they really mean &quot;encrypted&quot;. Encryption is only one tool that can be used in security, and usually it&#8217;s not the encryption that&#8217;s the weak point. In other products we&#8217;ve evaluated, a little sniffing and investigation revealed that while SSL was the method of encryption, the key size was 48 bits or lower, making brute force decryption feasible. Worse, some products ignore the authentication features of the SSL protocol, allowing either the client or server to be impersonated by an attacker with ease. There&#8217;s not much point in encrypting traffic when there&#8217;s no authentication of the client or server.</p>
<p>Many vendors use encryption to hide how weak their client-server communications really are. It&#8217;s a good thing that excellent open source tools like the above make vulnerability assessments of SSL-encrypted communications almost the same level of difficulty as assessing non-encrypted ones.</p>
Copyright &copy; 2010 <a href="http://advosys.ca/">Advosys Consulting Inc.</a>

<p><em>Related posts:</em><ul><li><a href='http://advosys.ca/viewpoints/2009/04/owasp-meetings-are-depressing/' rel='bookmark' title='Permanent Link: OWASP meetings are depressing'>OWASP meetings are depressing</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://advosys.ca/viewpoints/2006/08/testing-ssl-with-command-line-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Little known features: Symmetric encryption with PGP/GPG</title>
		<link>http://advosys.ca/viewpoints/2006/07/pgp-symmetric-encryption/</link>
		<comments>http://advosys.ca/viewpoints/2006/07/pgp-symmetric-encryption/#comments</comments>
		<pubDate>Sat, 29 Jul 2006 04:27:58 +0000</pubDate>
		<dc:creator>D Webber</dc:creator>
				<category><![CDATA[Little-known features]]></category>
		<category><![CDATA[Safeguarding data]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[gpg]]></category>
		<category><![CDATA[pgp]]></category>

		<guid isPermaLink="false">http://advosys.ca/viewpoints/2006/07/pgp-symmetric-encryption/</guid>
		<description><![CDATA[A little known feature of both PGP and GPG is that they can do symmetric encryption. Just a passphrase is needed- no public or private keys are involved. It's a quick and dirty way to get strong encryption that even a novice can use.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pgp.com/" target="_blank" title="Pretty Good Privacy strong encryption tool">Pretty Good Privacy</a> (PGP) and the open source <a href="http://www.gnupg.org/" target="_blank" title="GNU Privacy Guard (GPG) strong encryption tool">Gnu Privacy Guard</a> (GPG) are the popular public key encryption tools that don&#8217;t require the complexities of a Public Key Infrastructure. They are excellent tools for strong encryption and non-repudiation using de facto standards.</p>
<p>By default PGP and GPG use public key cryptography which provides a form of two factor authentication: to decrypt, you must know both a passphrase and have the correct private key. If your passphrase is compromised (e.g. by someone shoulder surfing or via a keylogger), the attacker still has to have your private key to decrypt any files.</p>
<p>However, once in a while you need to send a sensitive file to someone who doesn&#8217;t use PGP or GPG regularly and doesn&#8217;t have a public key. Without a public key, you can&#8217;t encrypt so that only that person can decrypt.<span id="more-20"></span></p>
<p>In that situation either you talk the person through the finicky process of creating and publishing a PGP/GPG key pair, or take the easy way out and use weak encryption such as the &quot;password protect&quot; feature of MS Word or WinZip. Word&#8217;s &quot;encryption&quot; is easily cracked. The original Zip encryption is also weak, though products like WinZip have added proprietary ciphers that are stronger.&nbsp;</p>
<p>A little known feature of both PGP and GPG is that they can also do symmetric encryption. Just a passphrase is needed- no public or private keys are involved. It&#8217;s a quick and dirty way to get strong encryption that even a novice can use.</p>
<p>To encrypt a file with symmetric encryption, the syntax is:</p>
<blockquote>
<p><code>pgp --symmetric filename</code></p>
</blockquote>
<blockquote>
<p><code>gpg --symmetric filename</code></p>
</blockquote>
<p>The result is a binary file with the same name as the original and &quot;.pgp&quot; or &quot;.gpg&quot; appended.</p>
<p>If the encrypted file must be pasted into the body of an e-mail message (instead of added as an attachment), you&#8217;ll want to use the plain ASCII form of output:</p>
<blockquote>
<p><code>pgp --symmetric --armor filename</code></p>
</blockquote>
<blockquote>
<p><code>gpg --symmetric --armor filename</code></p>
</blockquote>
<p>The result is a plain text file ending in &quot;.asc&quot;</p>
<p>Decryption is performed using the usual &quot;-d&quot; switch:</p>
<blockquote>
<p><code>pgp -d filename</code></p>
</blockquote>
<blockquote>
<p><code>gpg -d filename</code></p>
</blockquote>
<p>(The documentation for PGP and GPG describe the symmetric encryption option and all the command-line switches available for output formats).</p>
<p>Symmetric encryption with PGP/GPG uses a strong cipher (GPG uses <a href="http://www.gnu.org/software/gnu-crypto/manual/api/gnu/crypto/cipher/Cast5.html" target="_blank" title="CAST5 symmetric encryption">CAST5</a>) so it&#8217;s much more resistant to attack than using application encryption or WinZip. However, the passphase is the weak point: the longer and more complex the passphrase, the more secure the file. A single dictionary word can be brute forced in only a few hours, so use a complex passphrase of mutiple words broken up with letters and symbols.</p>
<p>Getting the passphrase to the recipient is another issue. Key distribution is always tricky with symmetric encryption schemes. If the encrypted file is sent via email, don&#8217;t also use email to send the passphrase (sounds obvious, but you&#8217;d be amazed how often people do that). Use the phone, send a fax, strap it to a pigeon&#8230; whatever method works best for the situation and won&#8217;t let an attacker intercept both the encrypted file and the passphrase.</p>
Copyright &copy; 2010 <a href="http://advosys.ca/">Advosys Consulting Inc.</a>

<p><em>Related posts:</em><ul><li><a href='http://advosys.ca/viewpoints/2006/05/protecting-laptops-with-truecrypt/' rel='bookmark' title='Permanent Link: Protecting laptop data with TrueCrypt'>Protecting laptop data with TrueCrypt</a></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://advosys.ca/viewpoints/2006/07/pgp-symmetric-encryption/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
