Pages

Wednesday, February 5, 2014

CSRF/XSRF Protection in ColdFusion 9

0 comments
Here's another little thing that's come across my desk and I hope my solution can be of some help to others.

I was asked to provide a solution to protect a site from Cross Site Request Forgery (CSRF or XSRF) attacks.  Specifically, there were forms on the site that were considered at-risk for exploitation.  I won't get into great detail on what CSRF is, but basically it's an attack vector that attempts to exploit the trust that a website has in the user's browser to allow malicious actions to take place on the server.  

CF10 has methods for CSRF protection available built in, but the site I was asked to chime in on is on CF9.

So, the forms were vulnerable to a CSRF attack because a malicious user could cause a legitimate, authenticated user to unwittingly submit them.  In order to protect the public facing forms, it's necessary to set up a condition where the server can trust that the form submission is from the legitimate user during their session.  The method CF10 uses is to send a token with the form and check for it on submission.  We can do the same thing by adding just a few lines of code to our forms.

Here's a typical self-posting form:
<cfif structKeyExists(form, 'sendInfo')>
       <p>Your information has been received.</p>
    <cfelse>
      <cfform>
            <label for="fName">First name:</label><cfinput name="fName" type="text"><br>
            <label for="lName">Last name:</label><cfinput name="lName" type="text"><br>
            <input type="submit" value="Submit" name="sendInfo">
      </cfform>
    </cfif>

Let's add a token to the form that the server can check for:
<cfif structKeyExists(form, 'sendInfo')>
       <p>Your information has been received.</p>
    <cfelse>
      <cfset session.foobar = createUUID()>
      <cfform>
            <cfoutput><input type="hidden" name="foobar" value="#session.foobar#"></cfoutput>
            <label for="fName">First name:</label><cfinput name="fName" type="text"><br>
            <label for="lName">Last name:</label><cfinput name="lName" type="text"><br>
            <input type="submit" value="Submit" name="sendInfo">
      </cfform>
    </cfif>


Next, we want the form processor to check for the token:
<cfif structKeyExists(form, 'sendInfo')>    
    <cfif structKeyExists(session, 'foobar') and form.foobar is session.foobar>
       <p>Your information has been received.</p>
       <cfelse>
           <p>The form has a problem</p>
       </cfif>
    <cfelse>
      <cfset session.foobar = createUUID()>
      <cfform>
            <cfoutput><input type="hidden" name="foobar" value="#session.foobar#"></cfoutput>
            <label for="fName">First name:</label><cfinput name="fName" type="text"><br>
            <label for="lName">Last name:</label><cfinput name="lName" type="text"><br>
            <input type="submit" value="Submit" name="sendInfo">
      </cfform>
    </cfif>


And finally, we want to do a little housekeeping by dropping the token from the session when we're done with it:
<cfif structKeyExists(form, 'sendInfo')>    
    <cfif structKeyExists(session, 'foobar') and form.foobar is session.foobar>
       <p>Your information has been received.</p>
       <cfelse>
           <p>The form has a problem</p>
       </cfif>
    <cfset structDelete(session, 'foobar')>
    <cfelse>
      <cfset session.foobar = createUUID()>
      <cfform>
            <cfoutput><input type="hidden" name="foobar" value="#session.foobar#"></cfoutput>
            <label for="fName">First name:</label><cfinput name="fName" type="text"><br>
            <label for="lName">Last name:</label><cfinput name="lName" type="text"><br>
            <input type="submit" value="Submit" name="sendInfo">
      </cfform>
    </cfif>

So there ya' go.  A handful of code and you've got your server recognizing your forms for a one-time post and bouncing them on any attempted re-posting.

Continue reading →
Friday, August 9, 2013

Dude, Where's My Phone (or Tablet)?

0 comments
Earlier this week Google released Android Device Manager, an online tool to locate misplaced Android devices.  This handy little tool will let you:
  • locate your phone or tablet on a map in real time  (if you think you left it somewhere),
  • ring it at max volume (if it’s misplaced - yes, you could call it from another phone, but this will override ‘Silent’ or ‘Vibrate Only’ so it will ring , or
  • erase it (if it's been stolen or is otherwise unrecoverable).
You will need to set up the erase feature on your device, but the locator and ring features work without any setup.

You can read the announcement or just go ahead and play with it.
Continue reading →
Friday, July 26, 2013

Going Hands-On with Google Chromecast

0 comments
OK - let's start with the basics:
Chromecast is a $35 dongle that you plug into an HDMI port on your HDTV and it allows you to use your phone, tablet or laptop to stream (cast) content to your TV screen. It will cast content from Netflix, YouTube, Google Play Movies & TV, and Google Play Music. Google promises more apps, like Pandora, coming soon.

Something that Google doesn't mention is that almost anything that plays natively in a Chrome browser window can be cast to the TV.  So if you've got a file living on your device that will open in Chrome you can probably cast it.  I've easily sent JPG pictures,  MP3 music, and M4V video from my laptop. I haven't yet done an exhaustive test of file types, but I have found that Quicktime (MOV) files are not supported.

As far as devices, it works with Android 2.3+, iOS 6.0+, Windows 7+, Mac OS 10.7+ and Chromebook Pixel, with additional Chromebook support coming soon.

It transmits video content at up to 1080p resolution via its HDMI port and draws power through its USB port from your HDTV or the supplied external power adapter. It supports 2.4-GHz Wi-Fi 802.11 b/g/n.

In the box you get:

  • the Chromecast device
  • an HDMI extension cable
  • a USB power cord
  • a power supply
Setup is quick and easy.  It took just about 3 minutes from opening the box 'til I was casting from my laptop.

  1. Plug the power cord into the dongle and into a USB port on your TV.
    Don't use the Service port.  If your set doesn't have a USB port, use the included power supply.  
  2. Switch your TVs source to the input you plugged the device into
  3. Go to google.com/chromecast/setup to download the app to configure the device
Follow the instructions to get the caster on your WiFi network and your pretty much done. One additional step to cast from your computer.  You'll need to install the Google Cast extension for Chrome.

Once you have Chromecast up and running it is found by your devices' YouTube, Play, etc. apps. Around the castle here, the prince and princesses are all wired up and their iOS and Android tablets, phones and such all can cast without having to install anything.

One thing to note - since all the devices can cast and there's no 'lockout', they can bump each other off the TV screen.  If Princess1 casts from her phone and Princess2 doesn't like the video, Princess2 can start a cast from her tablet and bump Princess1's video off the TV.

Maybe Google would consider a Chromecast Combo Pack including a striped shirt and a whistle?
Continue reading →
Friday, May 3, 2013

Google+ Hangouts Adds Remote Desktop

0 comments
Google has added a couple of new enhancements to the Hangouts.  You can now connect to another user's computer and control it with their permission.  (Think remote TA)

They've also increased the number of telephone connections to a Hangout from 2 to 5.  So now there's more space for people that are away from their connected devices, but have a phone and want to participate.  More details on the Google+ Daily blog.
Continue reading →
Tuesday, April 30, 2013

The Twinkies are Coming!!

1 comments
Okay, so a bit off topic from my usual posts, but you've got to acknowledge the important things in life.

The new Hostess company announced last week that it is going to reopen bakeries in Kansas and Georgia.  They announced today that they'll also be opening bakeries in Illinois and Indiana.  They're starting to staff up now and might have bakeries open by the end of May.  The goal is to have Twinkies, HoHos and all the rest back in stores by late July.
Continue reading →
Friday, April 19, 2013

Hotfix for CF Admin Console Vulnerability

0 comments
Adobe has released a hotfix to address a vulnerability in ColdFusion 10, 9.0.2, 9.0.1 and 9.0 (for Windows, Macintosh and UNIX) whereby an attacker could impersonate an authenticated user and potentially gain access to a secured website/application or ColdFusion’s administrative console.

Take a look at Adobe's Security Bulletin, and  the Tech Note for more information and to download and install the patch.
Continue reading →
Friday, March 22, 2013

Deleting a Printer that Just Won't Go Away

0 comments
Have you ever had a problem deleting a printer?

I'd physically gotten rid of an old printer, but I couldn't delete it from my Windows 7 computer; no matter how many times I tried, it just wouldn't go away.

If you're having a similar problem, here's how I cleared it up.

There was a document in the queue that I'd cancelled, but it wouldn't drop.  That was holding the printer.  I needed to force the print spool to release the document, so the system would drop the printer.  A command file would do the trick.  Here's what to do:

Open notepad and paste in these 4 lines

net stop spooler
del %systemroot%\system32\spool\printers\*.shd
del %systemroot%\system32\spool\printers\*.spl
net start spooler


Save the document as deletePrinter.cmd
Right-click the file you just created and select 'Run as administrator'

You may need to restart your computer afterwards, but that will delete any print jobs and the printer should be gone.




Continue reading →

Labels