<?xml version="1.0" ?>
<?xml-stylesheet type="text/css" href="http://www.petefreitag.com/rss/simple_style.css" ?>

<rss version="2.0">
	<channel>
		<title>Pete Freitag's Homepage</title>
		<link>http://www.petefreitag.com/</link>
		<description>Covering ColdFusion, Java, Web Development, and other topics</description>
		<language>en-us</language>
		<lastBuildDate>Fri, 20 Aug 2010 20:21:00 GMT</lastBuildDate>
		<ttl>45</ttl>
		
		<item>
			<title>Howto Install and Run the Android Emulator</title>
			<link>http://www.petefreitag.com/item/763.cfm</link>
			<guid>http://www.petefreitag.com/item/763.cfm</guid>
			<description><![CDATA[ <p>I am in the process of building some mobile apps for one of my clients, and while I'm pretty familiar with running the iPhone simulator and <a href="http://foundeo.com/iphone/">building iPhone apps</a>, I'm pretty new to the Android development tools at this point. So I thought I would give a quick and easy guide for folks to follow, that might be interested in getting started with Android Development and running the Android Emulator.</p>
<p>I should mention that there is also an Eclipse Plugin for Android Development as well that you can use instead. Also, I'm using a Mac, but I think the steps should be pretty close if you are running Windows or Linux.</p>
<h3>Step 1 - Download the Android SKD</h3>
<p><a href="http://developer.android.com/sdk/index.html">Download</a> the Android SDK, and unzip it somewhere. I placed the <code>android-sdk-mac_86</code> folder in my <code>/Applications/</code> folder, but you can put it wherever you want.</p>
<h3>Step 2 - <em>Optional</em> Add to System Path</h3>
<p>Since we are using the command line you might find it useful to add the <code>android-sdk-<em>platform</em>/tools</code> folder to your system path so you can run the android commands from any folder. If your interested in doing that, Google provides instructions <a href="http://developer.android.com/sdk/installing.html">here</a>.</p>
<h3>Step 3 - Install Android Platforms</h3>
<p>At this point, I tried running the <code>emulator</code> command, but the SDK doesn't contain any Android Platforms, the Android platform is essentially Android OS, you need to install at least one version (eg 1.6, 2.1, 2.2, etc) to run the emulator.</p>
<p>To install platforms run the <code>android</code> command located in the <code>tools</code> folder of the SDK (use Terminal.app on a Mac, or the Command Prompt on Windows, Linux folks you know what to do :). This will pop up a window. Select Available Packages, pick some platform versions and install.</p>
<h3>Step 4 - Create a Virtual Device</h3>
<p>Still in the <code>android</code> tool, click on Virtual Devices on the left, and then click New. Here's an example of the settings for the new device:</p>
<div align="center">
<img src="http://www.petefreitag.com/images/blog/android-avd-manager.png" alt="android virtual device manager, create avd file" /></div>
<p>Once you create the avd file, it should show up in the listing of Android Virtual Devices:</p>
<div align="center">
<img src="http://www.petefreitag.com/images/blog/android-virtual-devices.png" alt="android virtual devices listing" style="width:80%; height:80%;" /></div>
<h3>Step 5 - Run the emulator</h3>
<p>Now select the virtual device you just created and click <strong>Start</strong> on the right, and the emulator should start running:</p>
<div align="center">
<img src="http://www.petefreitag.com/images/blog/android-emulator.png" alt="Android Emulator" style="width:70%; height:70%;" /></div>



 ]]></description>
			<pubDate>Fri, 20 Aug 2010 20:21:00 GMT</pubDate>
			<category>Misc</category>
			
			
		</item>
		<item>
			<title>jQuery UI Autocomple IE 6 Select List z-Index Issues</title>
			<link>http://www.petefreitag.com/item/762.cfm</link>
			<guid>http://www.petefreitag.com/item/762.cfm</guid>
			<description><![CDATA[ <p>If you are using jQuery UI's Autocomplete control, your IE6 users may experience some issues when the autocomplete suggestions overlay a HTML <code>&lt;select&gt;</code> list. The autocomplete suggestions show up behind the select list in Internet Explorer 6.</p>
<p>To fix this you need to simply include the <a href="http://plugins.jquery.com/project/bgiframe"><code>bgiframe</code> plugin</a> in a script tag on your page. The jQuery UI autocomplete control will detect bgiframe and use it to fix itself for IE6.</p> ]]></description>
			<pubDate>Mon, 16 Aug 2010 23:31:00 GMT</pubDate>
			<category>Web</category>
			
			
		</item>
		<item>
			<title>Path Traversal Vulnerability Security Hotfix for ColdFusion Released</title>
			<link>http://www.petefreitag.com/item/761.cfm</link>
			<guid>http://www.petefreitag.com/item/761.cfm</guid>
			<description><![CDATA[ <p>Adobe released a security <a href="http://www.adobe.com/support/security/bulletins/apsb10-18.html">hotfix</a> for a path traversal vulnerability in ColdFusion administrator (CVE-2010-2861, APSB10-18). On the Adobe security bulletin page it lists affected software versions: <em>ColdFusion 8.0, 8.0.1, 9.0, 9.0.1 and earlier versions for Windows, Macintosh and UNIX</em>. Take special notice of the <strong>and earlier versions</strong>, so if you are running CF7 you will quite possibly still be vulnerable to this.</p>
<p>This vulnerability allows an attacker to ready any file that ColdFusion has permission to read (on windows this should be limited to the same drive that contains the ColdFusion administrator).</p>
<p>Applying the hotfix is quite simple, just replace a couple files in your ColdFusion administrator directory. So go ahead and take care of this now, it should take less than 5 minutes of your time. Also while your at it, make sure you ColdFusion administrator is not publicly accessible. Add IP restrictions, or a web server password.</p>
<p><strong>HackMyCF Updated</strong></p>
<p>My <a href="http://hackmycf.com/" title="ColdFusion Security Scanner">ColdFusion Security Scanner, HackMyCF</a> has been updated to detect this vulnerability. There are a few conditions however in which it can't detect it, so I encourage you to apply the hotfix regardless of what it says.</p>  ]]></description>
			<pubDate>Thu, 12 Aug 2010 18:01:00 GMT</pubDate>
			<category>ColdFusion</category>
			
			
		</item>
		<item>
			<title>Using AntiSamy with ColdFusion</title>
			<link>http://www.petefreitag.com/item/760.cfm</link>
			<guid>http://www.petefreitag.com/item/760.cfm</guid>
			<description><![CDATA[ <p>How do you protect your code from Cross Site Scripting (XSS) when your business requirements state that the user must be able to input HTML? This can be a difficult problem to solve and XSS is very difficult to filter against because there are hundreds of attack vectors.</p>
<p>Remember that social networking site MySpace? They allow anyone to create profile pages with lots of CSS, and HTML markup. They were concerned about XSS and they had pretty extensive blacklist filters in place to prevent it.</p>
<p>One  clever hacker named <em>Samy</em> figured out a way to embed JavaScript in his MySpace profile page, that would automatically add you as a friend when you viewed his profile. After about 5 hours Samy had roughly 1 million friends! After 6 hours MySpace was shut down for "maintenance"</p>
<p>Back to the problem at hand, how to we prevent this sort of thing? One way is to use a Java Library called <a href="http://code.google.com/p/owaspantisamy/">AntiSamy</a>. AntiSamy uses a XML policy file that defines what HTML tags and attributes are allowed in your application.</p>
<p><strong>Invoking AntiSamy from ColdFusion</strong></p>
<p>AntiSamy requires a couple jar files to run, in order to use the code in a jar file in ColdFusion you need to add the Jar files to your java classpath. Mark Mandel wrote an awesome utility called <a href="http://javaloader.riaforge.org/">JavaLoader</a> which allows us to dynamically load jar files, without modifying the java classpath variables, or copying files to particular locations. I am going to use JavaLoader in my example because it makes things very easy.</p>
<pre>
&lt;cfset policyFile = ExpandPath("./antisamy-slashdot-1.4.1.xml")&gt;
&lt;cfset jarArray = [ExpandPath("lib/antisamy-bin.1.4.1.jar"), 
	ExpandPath("lib/antisamy-required-libs/batik-css.jar"),
	ExpandPath("lib/antisamy-required-libs/batik-util.jar"),
	ExpandPath("lib/antisamy-required-libs/nekohtml.jar"),
	ExpandPath("lib/antisamy-required-libs/xercesImpl.jar")]&gt;
&lt;!--- using Java Loader to avoid adding jar files to classpath ---&gt;
&lt;cfset classLoader = CreateObject("component", "lib.javaloader.JavaLoader").init(jarArray)&gt;
&lt;cfset antiSamy = classLoader.create("org.owasp.validator.html.AntiSamy").init()&gt;
&lt;cfset cleanResults = antiSamy.scan(form.html, policyFile)&gt;
	
&lt;cfoutput&gt;
	&lt;h3&gt;AntiSamy Result:&lt;/h3&gt;
	#cleanResults.getCleanHTML()#
&lt;/cfoutput&gt;
</pre>
<p><a href="http://www.petefreitag.com/downloads/antisamy-coldfusion.zip">Download complete working version</a> - Includes all Jar files, JavaLoader (Requires CF8+ due to array notation, could be modified to work on CF7)</p>
<p>Using AntiSamy in ColdFusion is actually quite simple, you just need to create an instance of the Java object <code>org.owasp.validator.html.AntiSamy</code> and then invoke the <code>scan(<em>htmlContent</em>, <em>policyFileLocation</em>)</code> method. It returns a <code>CleanResults</code> object which has a bunch of nifty methods, such as <code>getCleanHTML()</code> which returns sanitized HTML based on your policy.</p>
<p><strong>Using AntiSamy with ESAPI</strong></p>
<p>Another great Java security API is the OWASP Enterprise Security API (ESAPI), it actually makes use of AntiSamy under the hood as well. One example is in the <code>ESAPI.validatior().isValidSafeHTML(<em>htmlContent</em>)</code> method. I recommend you checkout ESAPI for it's collection of Encoders to protect you against XSS (for outputting variables that should not contain HTML). See my <a href="http://www.petefreitag.com/item/759.cfm">Writing Secure CFML</a> presentation slides from CFUnited 2010 for more on ESAPI.</p>

 ]]></description>
			<pubDate>Thu, 05 Aug 2010 19:12:00 GMT</pubDate>
			<category>ColdFusion</category>
			
			
		</item>
		<item>
			<title>Writing Secure CFML Slides from CFUnited 2010</title>
			<link>http://www.petefreitag.com/item/759.cfm</link>
			<guid>http://www.petefreitag.com/item/759.cfm</guid>
			<description><![CDATA[ <p>As promised I just published the <a href="http://foundeo.com/security/presentations/cfunited-writing-secure-cfml-2010.pdf">slides for my <em>Writing Secure CFML</em></a> presentation at CFUnited 2010.</p>

<p>You can even watch a recording of the presentation brought to you by <a href="http://cfmumbojumbo.com/cf/index.cfm/cfconferences/cfunited-2010/pete-freitag-secure-cfml/">Tim Cunningham of CFMumboJumbo.com</a>:</p>
<div align="center">
<embed src="http://cfmumbojumbo.com/plugins/MuraMediaPlayer_1/cfmediaplayer/player/player.swf" width="480" height="290" allowscriptaccess="always" allowfullscreen="true" flashvars="file=http://c0021363.cdn1.cloudfiles.rackspacecloud.com/cf2010securecfml.mpg.FLV&stretching=fill" /> 
</div> ]]></description>
			<pubDate>Thu, 05 Aug 2010 19:04:00 GMT</pubDate>
			<category>ColdFusion</category>
			
			
		</item>
		<item>
			<title>Locking Down ColdFusion Presentation Slides</title>
			<link>http://www.petefreitag.com/item/758.cfm</link>
			<guid>http://www.petefreitag.com/item/758.cfm</guid>
			<description><![CDATA[ <p>The slides for my 2010 CFUnited presentation <em>Locking Down ColdFusion</em> are now available. The presentation is based on the <a href="http://www.adobe.com/products/coldfusion/whitepapers/pdf/91025512_cf9_lockdownguide_wp_ue.pdf">ColDFusion 9 Lockdown Guide</a> whitepaper that I wrote for Adobe. It covers various techniques to make your ColdFusion installation more secure.</p>
<p>I also presented on <em>Writing Secure CFML</em> at CFUnited which as you can probably gather is more dedicated to the coding side of things. Those slides will be available soon.</p>
<p><a href="http://foundeo.com/security/presentations/cfunited-coldfusion-lockdown-2010.pdf">Click Here to download Locking Down ColdFusion Slides</a></p>  ]]></description>
			<pubDate>Thu, 05 Aug 2010 05:02:00 GMT</pubDate>
			<category>ColdFusion</category>
			
			
		</item>
		<item>
			<title>Cross Domain Data Theft using CSS</title>
			<link>http://www.petefreitag.com/item/757.cfm</link>
			<guid>http://www.petefreitag.com/item/757.cfm</guid>
			<description><![CDATA[ <p>FireFox (3.6.7) released today fixed an interesting security vulnerability called <em>Cross Domain Data Theft using CSS</em> discovered by Google security researcher Chris Evans.</p> 
<p>It works kind of like JSON Hijacking, but uses a cross domain <code>&lt;link /&gt;</code>  tag instead of a cross domain <code>&lt;script /&gt;</code> call to the attacker site.</p>
<p>Here's how it works:</p>
<ol>
 <li>Post a comment on the victim site that looks like this: <code>{}body{background-image:url('http://google.com/</code> - it can be anywhere on the page, doesn't need to be in a <code>style</code> tag or attribute.</li>
 <li>Get the attacker to visit your site which contains a <code>link</code> tag like this: <code>&lt;link rel="stylesheet" href="http://victimsite.example.com/page/with/above/css"&gt;</code></li>
 <li>The attacker site also includes some javascript calling <code>window.getComputedStyle(<em>...</em>)</code> this can be used to steal the content of the page at <code>victimsite.example.com</code></li>

<p>The <code>{}</code> in the CSS resets the CSS parser because up to that point it is very confused (since it's trying to parse the HTML of the page as CSS).</p>

</ol>

<p>To fix this issue Firefox (and WebKit) now reject loading CSS files that meet these conditions:</p>
<ol>
 <li>CSS File is from another domain</li>
 <li>Content type is not text/css</li>
 <li>Page does not start with valid CSS syntax</li>
</ol>
<p>You can find a lot of the interesting details here in this <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=524223">Firefox Bug Report</a>.</p>
 ]]></description>
			<pubDate>Wed, 21 Jul 2010 21:27:00 GMT</pubDate>
			<category>Web</category>
			
			
		</item>
		<item>
			<title>Using jQuery UI Autocomplete with Hidden ID's</title>
			<link>http://www.petefreitag.com/item/756.cfm</link>
			<guid>http://www.petefreitag.com/item/756.cfm</guid>
			<description><![CDATA[ <p>The new <strong>autocomplete</strong> widget in jQuery UI 1.8 is a nice addition. While it works great for basic purposes working with ID / value pairs is not so nice out of the box.</p>
<p>I wanted to use the autocomplete widget to allow someone to select an employee by typing in an employee name into the text box, but I want the form to post the ID of the employee, not the employee name.</p>
<p>First you need to setup your server side search script, I'm using ColdFusion here:</p>
<pre>
&lt;cfparam name="url.term" default=""&gt;
&lt;cfset emp = empDAO.searchByName(url.term)&gt;
&lt;cfset result = ArrayNew(1)&gt;
&lt;cfoutput query="emp"&gt;
	&lt;cfset s = StructNew()&gt;
	&lt;cfset s["label"] = emp.FullName&gt;
	&lt;cfset s["value"] = emp.EE_ID&gt;
	&lt;cfset ArrayAppend(result, s)&gt;
&lt;/cfoutput&gt;
&lt;cfset json = SerializeJSON(result)&gt;
&lt;cfcontent reset="true" type="application/json"&gt;&lt;cfoutput&gt;#json#&lt;/cfoutput&gt;&lt;cfabort&gt;
</pre>
<p>The jQuery UI autocomplete widget sends a variable in the query string called <strong>term</strong> which contains the text the user has typed in. You need to return an array of objects in JSON. For example, your output might look like this:</p>
<pre>[{label:"Pete Freitag", value:1}, {label:"Pete Doe", value:2}]</pre>
<p>Now the HTML code I am using in the form simply looks like this:</p>
<pre>&lt;input type="text" name="EmployeeID" value="" class="employeeAutocomplete" /&gt;</pre>
<p>Next I need to write some jQuery JavaScript that applies the autocomplete widget to any <code>input</code> tag with the <code>employeeAutocomplete</code>, this code would go in your <code>$(document).ready()</code> event handler:</p>
<pre>
$('input.employeeAutocompete').autocomplete({source:'employee-search-json.cfm'});
</pre>
<p>Now this works well up to this point, but when I select an item it put's the employee ID in the text box. From the user perspective this doesn't make any sense. What I want is for the employee's name to be put in the text box, and have a hidden field containing the employee ID passed in the form.</p>
<p>So to accomplish that I need to do a bit more JavaScript, I'm going to do the following:</p>
<ol>
 <li>Change the name on the existing input field to whatever it was plus <code>_autocomplete_label</code></li>
 <li>Create a hidden input field with a name attribute value of the original input element (this will contain my ID value).</li>
 <li>Create a custom <code>select</code> event handler for the given jQuery UI autocomplete instance.</li>
</ol>
<p>So here's my new code:</p>
<pre>
$('input.employeeAutocomplete').each(function() {
	var autoCompelteElement = this;
	var formElementName = $(this).attr('name');
	var hiddenElementID  = formElementName + '_autocomplete_hidden';
	/* change name of orig input */
	$(this).attr('name', formElementName + '_autocomplete_label');
	/* create new hidden input with name of orig input */
	$(this).after("&lt;input type=\"hidden\" name=\"" + formElementName + "\" id=\"" + hiddenElementID + "\" /&gt;");
	$(this).autocomplete({source:'employee-search-json.cfm', 
		select: function(event, ui) {
			var selectedObj = ui.item;
			$(autoCompelteElement).val(selectedObj.label);
			$('#'+hiddenElementID).val(selectedObj.value);
			return false;
		}
	});
});
</pre>
<p>Now when I submit the form the value of the <code>EmployeeID</code> field will be an employee ID, and the text box will simply show the employee name.</p>
<p>Would be cool if this widget supported an option to do what I just did, but it only takes a few additional lines of code to accomplish.</p>
<!-- digg verify key cbe93487fdd74da2804b1e18818fbb23 --> ]]></description>
			<pubDate>Wed, 14 Jul 2010 20:52:00 GMT</pubDate>
			<category>ColdFusion</category>
			
			
		</item>
		<item>
			<title>10 Ideas to Improve Security in ColdFusion 10</title>
			<link>http://www.petefreitag.com/item/755.cfm</link>
			<guid>http://www.petefreitag.com/item/755.cfm</guid>
			<description><![CDATA[ <p>I do a lot of work related to <a href="http://foundeo.com/security/">security in ColdFusion</a> and I've been keeping a list of ideas and features that could make a future version of ColdFusion more secure. Here's 10 ideas in no particular order:</p>
<ol>
 <li><strong>Add an <code>allowedextensions</code> attribute to cffile for action=upload and deprecate the <code>accept</code> attribute</strong> - The <code>accept</code> attribute is useless as far as security goes since the mime types come from the client, you can easily spoof this (<a href="http://www.petefreitag.com/item/701.cfm">example</a>). This new attribute would simply be a list of file extensions that you allow to be uploaded, eg "jpg,png,gif,jpeg".  </li>
 <li><strong>Ask for a Windows Username to run ColdFusion services as during installation</strong> - The ColdFusion installer already does this on a unix install, but not windows. This should setup permissions on the ColdFusion installation directory.</li>
 <li><strong>Update Documentation and verbage related to ScriptProtect so people don't think it completely protects you from XSS</strong> - It's a very weak protection, yet alot of people think it fully protects them. I think this is due to how it is worded in the CF Administrator and documentation.</li>
 <li><strong>Add <code>Application.cfc</code> variables and CF Administrator settings to specify <code>httpOnly</code>, <code>secure</code>, <code>domain</code> for session cookies (CFID, CFTOKEN, jsessionid)</strong></li>
 <li><strong>Allow administrators to change the root ColdFusion Administrator username to something other than admin</strong> - Admin is always the default super user for ColdFusion administrator, it would be nice if you could specify an arbitrary username instead.</li>
 <li><strong>Create an audit log for ColdFusion administrator changes.</strong></li>
 <li><strong>Improve ScriptProtect</strong> - I know this feature will always be insufficient, but alot of people use it. It could be improved quite a bit, it should at least block iframe tags!</li> 
 <li><strong>Remove the possibility of CRLF injection</strong> - Any tag that outputs headers (for example <code>cfheader</code>, <code>cfcontent</code>, <code>cfmail</code> (subject attribute, or cfmailparam)) should strip the CRLF characters, so you can't inject new headers. <a href="http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=83739">Please vote for bug 83739</a></li>
 <li><strong>Make addtoken=false default for cflocation</strong> - Whenever you do a cflocation it puts the session id's in the url query string. Users don't know that if they copy and paste the link somewhere it allows whoever visits the link to be logged in as them.</li>
 <li><strong>Linux Installation scripts should detect SELinux and be able to install on SELinux.</strong> - You can still run ColdFusion on SELinux but it takes some configuration. (I provided some instructions in the <a href="http://www.adobe.com/products/coldfusion/whitepapers/pdf/91025512_cf9_lockdownguide_wp_ue.pdf">ColdFusion 9 Lockdown Guide</a> that I wrote)</li>
</ol>
<p>If you like any of these ideas you can add them to <a href="http://bit.ly/aPjLSN">this survey</a> for ColdFusion 10, and feel free to post some more ideas in the comments!</p> ]]></description>
			<pubDate>Fri, 18 Jun 2010 18:43:00 GMT</pubDate>
			<category>ColdFusion</category>
			
			
		</item>
		<item>
			<title>CFMeetup Thursday: Intro to FuseGuard and Web Application Firewalls</title>
			<link>http://www.petefreitag.com/item/754.cfm</link>
			<guid>http://www.petefreitag.com/item/754.cfm</guid>
			<description><![CDATA[ <p>I will be presenting at the ColdFusion Meetup online user group this Thursday (June 17th) at Noon Eastern Time. The topic: <em>Introduction to FuseGuard and Web Application Firewalls</em>.</p>
<p>I will be discussing some things about Web Application Firewalls in general, and then I will give a demo <a href="http://foundeo.com/security/">FuseGuard</a> a web application firewall built in CFML.</p>
<p><strong><a href="http://www.meetup.com/coldfusionmeetup/calendar/13797480/">RSVP Here</a></strong></p> ]]></description>
			<pubDate>Mon, 14 Jun 2010 22:09:00 GMT</pubDate>
			<category>ColdFusion</category>
			
			
		</item>
	</channel>
</rss>