<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Security And Caffeine</title>
	
	<link>http://www.securityandcaffeine.com</link>
	<description>something witty here</description>
	<lastBuildDate>Thu, 12 Feb 2009 22:42:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/securityandcaffeine" /><feedburner:info uri="securityandcaffeine" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Twitter “hacked” aka a nice example of CSRF</title>
		<link>http://feedproxy.google.com/~r/securityandcaffeine/~3/Sf2X2F2LZ6o/</link>
		<comments>http://www.securityandcaffeine.com/2009/02/12/twitter-hacked-aka-a-nice-example-of-csrf/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 20:00:08 +0000</pubDate>
		<dc:creator>Mack Staples</dc:creator>
				<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.securityandcaffeine.com/?p=59</guid>
		<description><![CDATA[Today marked an interesting day in Twitter history: a learning opportunity for the masses.  If you use Twitter, you probably saw one of your friends issue a tweet like the following: Don&#8217;t Click: http://tinyurl.com/amgzs6 And, probably like many of the people out there, you clicked the link.  By the way, if you clicked the link [...]]]></description>
			<content:encoded><![CDATA[<p>Today marked an interesting day in <a title="Twitter" href="http://www.twitter.com">Twitter</a> history: a learning opportunity for the masses.  If you use Twitter, you probably saw one of your friends issue a tweet like the following:</p>
<blockquote><p>Don&#8217;t Click: <a href="http://tinyurl.com/amgzs6">http://tinyurl.com/amgzs6</a></p></blockquote>
<p><strong></strong></p>
<p>And, probably like many of the people out there, you clicked the link.  By the way, if you clicked the link above, good job.  You&#8217;re now one of the tens, possibly hundreds, of thousands of Twitter users that clicked that.</p>
<p>And then, you found out that your Twitter account got HACKED!  Even prolific blogger Dooce clicked, and subsequently decided her account had been compromised.  <a title="Dooce's tweet" href="http://twitter.com/dooce/status/1203725230">Her followup tweet</a> was </p>
<blockquote><p>My twitter account got hacked. That last tweet was a hack, not my doing. Apologies for any inconvenience.</p></blockquote>
<p>&#8220;Inconvenience&#8221;?  Your inability to not click an unknown link resulted in all your readers&#8217; accounts being exposed to this.</p>
<p>Here&#8217;s the thing, though: your account is fine.  It wasn&#8217;t compromised.  At least, not in the way you are thinking.  I&#8217;m sure you&#8217;re thinking someone broke in, posted as you, and took off.  Now they have your username, password, measurements, shoe size, and even the length of your&#8230; hair.  I was going to say hair.  I promise.</p>
<p>Well, you&#8217;re wrong.  They don&#8217;t.</p>
<p>What happened?  Well, you clicked the link.  Alright, let&#8217;s get technical.</p>
<p>You&#8217;re on Twitter.  In fact, you&#8217;ve probably logged in to Twitter, so your browser has an authenticated session.  If you don&#8217;t know what that means, it&#8217;s simply that your browser has a piece of information that identifies you as you.  That info allows you access to your account, your tweets, your friends, and so on.  When you clicked the &#8220;Don&#8217;t Click&#8221; link, something happened: you opened a web page.  That&#8217;s all you saw.  The web page, redirected via <a title="TinyURL" href="http://www.tinyurl.com">TinyURL.com</a>, was <a title="So Obama!" href="http://www.umoor.eu/blog/yes-we-can.php">http://www.umoor.eu/blog/yes-we-can.php</a>.</p>
<p>Don&#8217;t worry, both the TinyURL and the yes-we-can.php pages have since been disabled.</p>
<p>Take page contained two thing of note: a button, which you could see, and an iframe, which you could not see.  The button was simple enough:</p>
<blockquote><p>button {position: absolute;top: 10px;left: 10px;z-index: 1;width: 120px;}</p></blockquote>
<p>It just sat there, looking bored.  The iframe was more interesting:</p>
<blockquote><p>iframe {position: absolute;width: 550px;height: 228px;top: -170px;left: -400px;z-index: 2;opacity: 0;filter: alpha(opacity=0);}</p></blockquote>
<p>The CSS, you&#8217;ll notice, sets a size and height, but positions it off to the side and makes it transparent.  You were not supposed to even know it&#8217;s there.  Now, source of the iframe is what matters.  Remember, it&#8217;s hidden, so you see none of this.</p>
<blockquote><p>iframe src=&#8221;http://twitter.com/home?status=Don&#8217;t Click: http://tinyurl.com/amgzs6&#8243; scrolling=&#8221;no&#8221;</p></blockquote>
<p>Since Twitter allows you to set you status by tacking the status on to the &#8220;home&#8221; URL, the iframe made the same request.  Backing up, you were (probably) authenticated to Twitter, so there were no problems simply updating your status.  From there, your friends saw it, clicked the link, and their own status was updated.  And it cascaded.</p>
<p>How bad did it cascade?  Here is the <a href="http://search.twitter.com/search?q=http%3A%2F%2Ftinyurl.com%2Famgzs6">Twitter search for just that URL</a>.</p>
<p>So, did you account get &#8220;hacked&#8221;?  Not exactly.  The account was <em>not</em> compromised or broken into, but it did perform actions on your behalf without you knowing about it.  Do you need to run and change your password?  Not this time.  How about, instead, you find out where links go before you trust them.  Then again, if you&#8217;re an Obama supporter, anything with &#8220;yes-we-can&#8221; in it will probably get you.  By the way, if you take a TinyURL and put &#8220;preview&#8221; in it, you can see where it goes without going there.  So , <a href="http://tinyurl.com/amgzs6"><span>http://tinyurl.com/amgzs6</span></a><span> becomes <a href="http://tinyurl.com/amgzs6">http://preview.tinyurl.com/amgzs6</a>.</span></p>
<p><strong></strong></p>
<p>Now, I want you to think about something: in this case, you were exploited and inadvertently posted to Twitter.  What if, instead of posting to Twitter, the iframe had tried to transfer money from your bank account?</p>
<p>And, most importantly, what can you do about it?  Learn where links are going before you click, and download and use <a title="CSRFblocker" href="http://www.hexsec.com/labs.html">CSRFblocker</a>, which will be available soon from the <a title="Hexagon Security" href="http://www.hexsec.com/">Hexagon Security think-tank</a>.</p>
<p>Credit: <a href="http://twitter.com/reverz">@reverz</a> and <a href="http://twitter.com/nathanhamiel">@nathanhamiel</a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.securityandcaffeine.com%2F2009%2F02%2F12%2Ftwitter-hacked-aka-a-nice-example-of-csrf%2F&amp;linkname=Twitter%20%26%238220%3Bhacked%26%238221%3B%20aka%20a%20nice%20example%20of%20CSRF"><img src="http://www.securityandcaffeine.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/securityandcaffeine?a=Sf2X2F2LZ6o:l126PKPetmQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/securityandcaffeine?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/securityandcaffeine/~4/Sf2X2F2LZ6o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.securityandcaffeine.com/2009/02/12/twitter-hacked-aka-a-nice-example-of-csrf/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.securityandcaffeine.com/2009/02/12/twitter-hacked-aka-a-nice-example-of-csrf/</feedburner:origLink></item>
		<item>
		<title>Stealing data, with Apple’s Blessing</title>
		<link>http://feedproxy.google.com/~r/securityandcaffeine/~3/M1JS9auyPYo/</link>
		<comments>http://www.securityandcaffeine.com/2008/09/11/stealing-data-with-apples-blessing/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 14:07:58 +0000</pubDate>
		<dc:creator>Mack Staples</dc:creator>
				<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://securityandcaffeine.com/?p=28</guid>
		<description><![CDATA[I have a subscription to Pinch Media&#8217;s &#8220;New App&#8221; RSS feed.  As a result, I see literally every single new app that shows up, and I test many if not most of them.  Yesterday, I downloaded a new toy app and gave it a whirl.  The app is called &#8220;A.K.A&#8221;.  It takes your name, and gives [...]]]></description>
			<content:encoded><![CDATA[<p>I have a subscription to <a href="http://www.pinchmedia.com/">Pinch Media&#8217;s</a> <a href="http://feeds.feedburner.com/RecentlyAddedIphoneApplications-PinchMedia">&#8220;New App&#8221; RSS feed</a>.  As a result, I see literally every single new app that shows up, and I test many if not most of them.  Yesterday, I downloaded a new toy app and gave it a whirl.  The app is called &#8220;A.K.A&#8221;.  It takes your name, and gives you your Pirate, Jedi, and Porn Star name.  Very simple little app, and quite entertaining.</p>
<p>If you want to check out the app, <a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=290033763&amp;mt=8">here is the iTunes store link</a>.  Because iTunes conveniently <a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewArtist?id=290033766">provides a link to this information</a>, it&#8217;s easy to tell that the author, Robert de Jong, has not published any other apps.  Further, one <a href="http://whois.net">whois</a> and <a href="http://www.google.com/search?client=safari&amp;rls=en-us&amp;q=robert+de+jong&amp;ie=UTF-8&amp;oe=UTF-8">a google search</a> later, and you can tell that the author, based in Colorado, isn&#8217;t either of the other two Robert de Jongs out there; <a href="http://www.econ.ohio-state.edu/dejong/">one is in Ohio</a>, the <a href="http://www.robertdejong.com/">other in Canada</a>.  Oh, his &#8220;company&#8221; also <a href="http://www.dejoware.com">has a website</a>, though it looks like a sole-proprietership, meaning there has been no paperwork filed with the government to form an LLC or corporation.  Further evidence: I couldn&#8217;t find a DEJOware business listing, according to the Colorado business registry.  On his site, the only contact link is a mailto, which will allow you to send him an email.</p>
<p>So, where does that leave us?  Well, let&#8217;s look at the application itself.  I mentioned earlier that it takes in user input, and gives you back your &#8220;other&#8221; names.  Let&#8217;s give this a whirl, using some fake information (why will be covered in a minute).  Starting the app up, we go immediately to the Pirate name screen.  First and last name are requested.  &#8220;Johnny Appleseed&#8221; is already demo&#8217;d on the iTunes store, so let&#8217;s do another name.  How about &#8220;Robert de Jong&#8221;?  I put it in, and get back the pirate name of &#8220;&#8216;Salty&#8217; Squid Flint&#8221;.  Stripper name time!  Robert de Jong, in the stripper world, would be &#8220;Fantasia Heavencocker&#8221;.  Wow.  Now Jedi name time.  Hitting this tab expands the input, and, again as seen on iTunes, more information is requested.  First, last, mother&#8217;s maiden, and birthplace are requested.  Robert&#8217;s mother&#8217;s maiden name will be, for this demo, &#8220;Wozniak&#8221; (sorry Steve), and his birthplace will be Boulder.  I get back the very Jedi name of &#8220;Dej-Ro Wozbou&#8221;.</p>
<p>Dej-Ro Wozbou is parts of each element of data.  Three from last name, two from first name, three from mother&#8217;s maiden, and three form birthplace.  <strong>de J</strong>ong <strong>Ro</strong>bert <strong>Woz</strong>niak <strong>Bou</strong>lder.  See?</p>
<p>So, why would I use false information here?  Here&#8217;s what just happened: a previously unknown developer has created an application and published it <em>with Apple&#8217;s blessing</em>.  The application asks for your information, and does&#8230; we know not what with it.  The app could send your information, literally, anywhere.  Further, the information is all user-supplied, so there&#8217;s nothing that would make Apple unhappy (like rifling through your address book for your information).  No, we, the users, provide all the information it asks for.  And that&#8217;s the problem.  We just provided First Name, Last Name, Mother&#8217;s Maiden Name, and Birthplace to this application and, potentially, to this developer.  If those four pieces of information sound familiar, it&#8217;s because those are usually what stand between you and retrieving an account password almost anywhere.  &#8220;But he doesn&#8217;t know my username!&#8221; you cry.  Actually, most people will use FirstnameLastname as their account username, if it&#8217;s an important account.  Like banking.  Think about that.</p>
<p>Now, my disclaimer and CYA: I don&#8217;t know any of this for sure.  I haven&#8217;t monitored the network traffic to see if A.K.A is calling home.  I&#8217;m not even accusing A.K.A. or Robert de Jong of doing anything malicious.  The A.K.A. app happens to fit a model that could be used to steal information.  It is also &#8220;trusted&#8221; because Apple has blessed it.  Before you willingly hand any information over to an application, trusted or not, consider what could be done with that information.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.securityandcaffeine.com%2F2008%2F09%2F11%2Fstealing-data-with-apples-blessing%2F&amp;linkname=Stealing%20data%2C%20with%20Apple%26%238217%3Bs%20Blessing"><img src="http://www.securityandcaffeine.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/securityandcaffeine?a=M1JS9auyPYo:qJ0rTEvQMjM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/securityandcaffeine?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/securityandcaffeine/~4/M1JS9auyPYo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.securityandcaffeine.com/2008/09/11/stealing-data-with-apples-blessing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.securityandcaffeine.com/2008/09/11/stealing-data-with-apples-blessing/</feedburner:origLink></item>
		<item>
		<title>Scamming Walmart</title>
		<link>http://feedproxy.google.com/~r/securityandcaffeine/~3/xdSqG_njoRw/</link>
		<comments>http://www.securityandcaffeine.com/2008/09/02/scamming-walmart/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 20:13:13 +0000</pubDate>
		<dc:creator>Mack Staples</dc:creator>
				<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://securityandcaffeine.com/?p=26</guid>
		<description><![CDATA[Let me begin with the following: I have not tried this, nor will I.  Unless they hire me to, hint hint.  This is just a write-up of a scheme I heard about.  The lady telling me about this works as a customer service representative, and specifically handles returns in the customer service area of the [...]]]></description>
			<content:encoded><![CDATA[<p>Let me begin with the following: I have not tried this, nor will I.  Unless they hire me to, hint hint.  This is just a write-up of a scheme I heard about.  The lady telling me about this works as a customer service representative, and specifically handles returns in the customer service area of the store.</p>
<p>There is a nationwide scam being run to steal money form <a href="http://www.walmart.com" target="_blank">Walmart</a>.  This may not seem like much of a revelation, until I describe the method being used.  Undoubtedly, this is also being perpetrated at other stores, but Walmart is a face you know.</p>
<p>Have you watched <a href="http://www.imdb.com/title/tt0333766/" target="_blank">Garden State</a>, starring <a href="http://www.imdb.com/name/nm0000204/" target="_blank">Natalie Portman</a> and <a href="http://www.imdb.com/name/nm0103785/" target="_blank">Zach Braff</a>?  This is not a random divergence.  In fact, that movie has a similar scheme employed in it.  In this movie, the main character&#8217;s friend needs to get some money.  He takes the whole crew with him, before beginning their outing, to the local home and garden store.  There, he grabs a set of knives from the shelves, and takes them to the return counter.  After a brief and indignant argument about how the knives &#8220;aren&#8217;t sharp enough&#8221;, the knives are &#8220;returned&#8221;, and he walks out with cash in hand.  He explains, &#8220;you don&#8217;t need a receipt to return anything under $25.&#8221;  In the real world, the viability of this is suspect; most places would, at best, offer a store credit.  But what about that weak link in the chain, the receipt?</p>
<p>Why is the receipt the weak link?  Two reasons: we perceive them as having a low value (generally), and almost no &#8220;low ticket&#8221; items are individually identifiable.  That is, unless we need to return something or use it for reimbursement or tax write-off, the receipt has virtually no value, and inexpensive items generally don&#8217;t have serial numbers.  Recently, a friend of mine purchased a <a title="I should set up an affiliate link... oh well" href="http://www.amazon.com/Wii-Wireless-Sensor-Bar-nintendo/dp/B000LFJNG6" target="_blank">wireless Wii sensor bar</a>, which broke within a month.  The fault was in the cheap plastic used, but she wanted that same type of sensor bar.  Instead of paying another $21, she purchased a new one, put the old one in the new packaging, and returned it.  She got a new sensor bar, and it was completely undetectable.</p>
<p>The challenge now becomes one of determining how to exploit this.  The Walmart scam takes advantage of the receipt as the weak link, and exploits this perfectly.  It is also very simple, making it surprisingly easy to pull off.  Further, the victim is a major corporation, making it very unlikely that action will be taken, compared to an individual.</p>
<p>The scam runs as follows: the attacker waits for a receipt to be thrown away in the trash outside the door, or dropped in the parking lot.  The receipt is collected.  If the purchase was paid with cash or debit, it can be used; a credit card receipt will only do a refund back to the credit card, not to cash.  Once a viable receipt is collected, all that has to be done is wait.  The waiting is for someone with a return to come in.  When you enter Walmart, you&#8217;re item is tagged with a sticker, showing it came &#8220;in&#8221; from the outside.  Even if a return is processed, the sticker might be left on the item.  If the attacker can then grab either the sticker (to apply to another item), or the entire item, they&#8217;ve got everything they need to get cash in hand: receipt, item, &#8220;official&#8221; sticker.</p>
<p>This attack could, of course, be done a number of different ways: the item could be shoplifted then brought back in, gaining it the &#8220;official sticker&#8221;, or stickers could be printed elsewhere and affixed at the attacker&#8217;s leisure.  The sky&#8217;s the limit; the result is the same: cash.</p>
<p>Brian White over on Bloggingstocks.com has written up his own <a href="http://www.bloggingstocks.com/2008/02/08/the-wal-mart-weekly-customer-returns-process-shows-severe-weakn/" target="_blank">assessment of the Wal-mart return policy</a>.  His research, along with my information, could lead to some very interesting return fraud.</p>
<p><em>Update</em>: While discussing this security issue with various people, both a coworker and a relative gave me the same new information that I would not have discovered on my own, because they have kids. Apparently, the greeters are more than happy to give stickers to kids.  While they usually don&#8217;t barcode the kids, if the Walmart is one of the ones that uses a florescent dot instead of a barcode, the greeters will usually hand those out to small children.  So, walk through a couple times with a couple kids, take their stickers, find a receipt, stick the sticker on the item in the store, take it up front and return it.  Easy as that.  But it&#8217;s so mean&#8230; taking stickers from kids.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.securityandcaffeine.com%2F2008%2F09%2F02%2Fscamming-walmart%2F&amp;linkname=Scamming%20Walmart"><img src="http://www.securityandcaffeine.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/securityandcaffeine?a=xdSqG_njoRw:rAmDpssiVSc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/securityandcaffeine?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/securityandcaffeine/~4/xdSqG_njoRw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.securityandcaffeine.com/2008/09/02/scamming-walmart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.securityandcaffeine.com/2008/09/02/scamming-walmart/</feedburner:origLink></item>
		<item>
		<title>Your Rules Do Not Apply to Me</title>
		<link>http://feedproxy.google.com/~r/securityandcaffeine/~3/2V9mkP5hpEQ/</link>
		<comments>http://www.securityandcaffeine.com/2008/07/07/your-rules-do-not-apply-to-me/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 14:01:20 +0000</pubDate>
		<dc:creator>Mack Staples</dc:creator>
				<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://securityandcaffeine.com/?p=24</guid>
		<description><![CDATA[A couple of days ago, I wanted a barbecue.  Having lived for three years in an apartment in Arizona, I have been completely unable to own a barbecue, under penalty of flogging by the Fire Marshal.  Now, having moved to Florida to an apartment that allows them, I wanted a barbecue. So, I went to [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago, I wanted a barbecue.  Having lived for three years in an apartment in Arizona, I have been completely unable to own a barbecue, under penalty of flogging by the Fire Marshal.  Now, having moved to Florida to an apartment that allows them, I wanted a barbecue.</p>
<p>So, I went to get one.</p>
<p><a href="http://www.walmart.com" target="_blank">Walmart</a> was the destination of choice.  The barbecue I found and wanted was the <a href="http://www.walmart.com/catalog/product.do?product_id=8154152" target="_blank">Char-Broil 2-burner</a>.  Walmart had exactly <a href="http://simple.wikipedia.org/wiki/One" target="_blank">one</a>.  It was the floor display model, but I still wanted it.</p>
<p>So, I grabbed the barbecue, and wheeled it over to the checkout counter near the gardening section.  I was politely informed that the barbecue, being the floor model, would need to be approved for sale by the manager.  The checker called to ask, and <a href="http://images.schuminweb.info/journal/2004/wal-mart-vest.jpg" target="_blank">another associate (image simulated)</a> to check out the grill.  The grill, I was informed, was in perfect working order.  I was also informed, at about the same time, that the manager would not approve the grill to be sold.  The associates put the grill back on the display floor.</p>
<p>Then I took it.</p>
<p>No, I didn&#8217;t steal it.  I just waited for them to be busy with other customers, walked up to it, and wheeled it away.  This time, I headed in the direction of the front of the store, and the main checkout area.  Specifically, I angled toward self-checkout.</p>
<p>The grill had a big sticker on it, complete with <a title="Freaking coolest thing ever" href="http://en.wikipedia.org/wiki/Barcode" target="_blank">barcode</a>.  I peeled it off as I went, got to the self-check, scanned the code, and swiped my card.  It was mine.</p>
<p>Pause.</p>
<p>&#8220;Hold for Assistance&#8221;, the screen read.  The associate monitoring the self-check started walking my way&#8230; and all she wanted was to verify my ID against the name on my card, because the grill was a large line-item on the receipt.</p>
<p>And the grill was mine.</p>
<p>Walmart, your rules do not apply to those people willing to use your own systems against you.  I&#8217;m not talking about laws.  Just your rules.  Enjoy.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.securityandcaffeine.com%2F2008%2F07%2F07%2Fyour-rules-do-not-apply-to-me%2F&amp;linkname=Your%20Rules%20Do%20Not%20Apply%20to%20Me"><img src="http://www.securityandcaffeine.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/securityandcaffeine?a=2V9mkP5hpEQ:17uA8fe4UTs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/securityandcaffeine?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/securityandcaffeine/~4/2V9mkP5hpEQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.securityandcaffeine.com/2008/07/07/your-rules-do-not-apply-to-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.securityandcaffeine.com/2008/07/07/your-rules-do-not-apply-to-me/</feedburner:origLink></item>
		<item>
		<title>Better Form Processing</title>
		<link>http://feedproxy.google.com/~r/securityandcaffeine/~3/lUeUd9wAKvE/</link>
		<comments>http://www.securityandcaffeine.com/2008/06/16/better-form-processing/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 08:03:01 +0000</pubDate>
		<dc:creator>Mack Staples</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://securityandcaffeine.com/?p=22</guid>
		<description><![CDATA[This is a much condensed version of the original post. Usually, processing form data means getting either POST or GET data from a form, and trying to figure out, in code, what you have, and then do something with it.  This can be easy or complicated, depending on how much is being passed in.  Email [...]]]></description>
			<content:encoded><![CDATA[<p>This is a much condensed version of the original post.</p>
<p>Usually, processing form data means getting either POST or GET data from a form, and trying to figure out, in code, what you have, and then do something with it.  This can be easy or complicated, depending on how much is being passed in.  Email address only? Easy.  Checkboxes, optional fields, and so on, all together?  Pain.  Often, a lot of form processing is done with stacks of &#8220;if&#8221; statements.  This sucks.  Here is a better way:</p>
<p>From now on, I want you to name all of your &#8220;real&#8221; form elements (ones that have data that could change, so not buttons) using the name you would have given then, <em>plus an array name</em>, that they will all share.</p>
<p>So,</p>
<pre>&lt;input type="text" name="username" id="username" /&gt;</pre>
<p>becomes</p>
<pre>&lt;input type="text" name="formdata[username]" id="username" /&gt;</pre>
<p>Why?  Instead of having one array ($_POST), you&#8217;ll now have two ($_POST and &#8216;formdata&#8217;, within $_POST).  Your buttons and other &#8220;static&#8221; form elements will still live in $_POST, but everything containing data that needs handling will be in the &#8216;formdata&#8217; array, which you can access as $_POST[formdata].</p>
<p>Why does this rock?  I find I have to go through all of the data in a form, even if I know what and how much is coming in, and that the amount wont change.  For example, it&#8217;s a good idea to clean all user input.  Since users can change any form value, this needs handled.  Why bother with a ton of &#8216;if&#8217; statements when we can just iterate through the &#8216;formdata&#8217; array?</p>
<pre>  foreach ($_POST['formdata'] as $key =&gt; $value)
    $_POST['formdata'][$key] = makesafe($value);</pre>
<p>Cautionary note: this definitely seems ideal for updating data in a database and saving time, doesn&#8217;t it?  Maybe something like (let&#8217;s assume &#8220;$user_id&#8221; is the current user&#8217;s account, and we determined that earlier somehow) :</p>
<pre>  foreach ($_POST['formdata'] as $key =&gt; $value)
    mysql_query("UPDATE info_table SET $key = '$value' WHERE index = $user_id");</pre>
<p>This is a bad thing.  Why?  SQL injection.  At the very least, clean <em>all</em> input, including the field names, if you think something like the above statement is a good idea.  If you don&#8217;t, don&#8217;t say I didn&#8217;t warn you if you get owned.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.securityandcaffeine.com%2F2008%2F06%2F16%2Fbetter-form-processing%2F&amp;linkname=Better%20Form%20Processing"><img src="http://www.securityandcaffeine.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/securityandcaffeine?a=lUeUd9wAKvE:sKVYr8m7-IA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/securityandcaffeine?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/securityandcaffeine/~4/lUeUd9wAKvE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.securityandcaffeine.com/2008/06/16/better-form-processing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.securityandcaffeine.com/2008/06/16/better-form-processing/</feedburner:origLink></item>
		<item>
		<title>U@T Rogue Forums</title>
		<link>http://feedproxy.google.com/~r/securityandcaffeine/~3/g3vyowdAFGw/</link>
		<comments>http://www.securityandcaffeine.com/2008/05/23/ut-rogue-forums/#comments</comments>
		<pubDate>Fri, 23 May 2008 04:18:57 +0000</pubDate>
		<dc:creator>Mack Staples</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://securityandcaffeine.com/?p=11</guid>
		<description><![CDATA[During the Spring Semester of 2007, I worked as the lead developer on the UAT Rogue Forums.  The project was designed and lead by Jordan Womack, a UAT Master&#8217;s Student.  Under him, the Rogue Forums was created as an alternative to UAT&#8217;s intranet forums; general opinion of the intranet forums was quite low. We used and [...]]]></description>
			<content:encoded><![CDATA[<p>During the Spring Semester of 2007, I worked as the lead developer on the <a title="UAT Rogue Forums" href="http://op-server.0x58.com/forums/" target="_blank">UAT Rogue Forums</a>.  The project was designed and lead by Jordan Womack, a UAT Master&#8217;s Student.  Under him, the Rogue Forums was created as an alternative to <a title="University of Advancing Technology" href="http://www.uat.edu" target="_blank">UAT&#8217;s</a> intranet forums; general opinion of the intranet forums was quite low.</p>
<p>We used and modified <a title="phpBB Main Site" href="http://www.phpbb.com" target="_blank">phpBB.</a>  My portion of the project was to re-skin the bulletin board system, act as lead moderator, prevent non-UAT students from registering, and implement the post voting system.  phpBB version 3, RC5 was used and updated to subsequent release candidates.</p>
<p>Two php files were added to the core of phpBB3, one core file was modified, and additional tables were created in the database.  Currently this project only works with phpBB3 on a MySQL database, but I hope to make it database-independent.  Below is a snippet of code from the new files.</p>
<pre>&lt;?php
	$sql = 'INSERT INTO ' . VOTES_TABLE . ' ' . $db-&gt;sql_build_array('INSERT', array(
		'post_id'		=&gt; (int) $post_id,
		'user_id'		=&gt; $user-&gt;data['user_id'],
		'adjust'		=&gt; 1,
		'vote_time'		=&gt; time(),
		'voter_ip'		=&gt; $user-&gt;ip)
	);
?&gt;</pre>
<p>A working example of these modifications in a live phpBB3 environment can be seen at <a title="UAT's Rogue Forums" href="http://op-server.0x58.com/forums/" target="_blank">The Rogue Forums</a>.  Please contact me for a login, as account creation is limited to UAT students only.  The new files associated with this project are linked below.</p>
<p><a title="Zipfile of phpBB3 voting system files" href="http://www.securityandcaffeine.com/projects/phpBB3.zip">pbpBB voting system files</a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.securityandcaffeine.com%2F2008%2F05%2F23%2Fut-rogue-forums%2F&amp;linkname=U%40T%20Rogue%20Forums"><img src="http://www.securityandcaffeine.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/securityandcaffeine?a=g3vyowdAFGw:oIjExYmSlHw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/securityandcaffeine?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/securityandcaffeine/~4/g3vyowdAFGw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.securityandcaffeine.com/2008/05/23/ut-rogue-forums/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.securityandcaffeine.com/2008/05/23/ut-rogue-forums/</feedburner:origLink></item>
		<item>
		<title>CSS Rotate v2</title>
		<link>http://feedproxy.google.com/~r/securityandcaffeine/~3/npRnSCjY9a0/</link>
		<comments>http://www.securityandcaffeine.com/2008/05/08/css-rotate-v2/#comments</comments>
		<pubDate>Thu, 08 May 2008 22:59:10 +0000</pubDate>
		<dc:creator>Mack Staples</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://securityandcaffeine.com/?p=7</guid>
		<description><![CDATA[Background: This projects began as a request from a friend.  His site, acting as a working demo, is at Fried Pope.  He wanted the ability to have different stylesheets govern the look of his site, and be chosen randomly for each visitor.  In short, he wanted to rotate his style sheets. Project: The result from that request, plus [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>Background: This projects began as a request from a friend.  His site, acting as a working demo, is at <a title="Fried Pope" href="http://www.friedpope.com">Fried Pope</a>.  He wanted the ability to have different stylesheets govern the look of his site, and be chosen randomly for each visitor.  In short, he wanted to rotate his style sheets.</p>
<p>Project: The result from that request, plus a major recode, is linked below.  The system is designed to pick a stylesheet from the directory you specify, and redirect the user to it.  It will remember the stylesheet selected for the user for their entire visit, so your site doesn&#8217;t keep changing its look.  That would be confusing.</p>
<p>Compatibility: This project works in all known browsers.</p>
<p>Use: Using this tool is extremely simple.  You must have a web host that supports PHP.</p>
<ol>
<li>Uncompress the source code, and put &#8216;cssrotate2.php&#8217; in your website&#8217;s directory</li>
<li>Open &#8216;cssrotate2.php&#8217; with an HTML editor</li>
<li>If you need to, change the the line under the comments to specify where your styles are ($stylesdir = &#8220;./styles&#8221;;)</li>
<li>Save and close it</li>
<li>Open any pages in your site that you want to have use CSS Rotate</li>
<li>Add a link to it like you would any other stylesheet (&lt;link href=&#8221;./styles/cssrotate2.php&#8221; rel=&#8221;stylesheet&#8221; type=&#8221;text/css&#8221; /&gt;)</li>
<li>Save and close those pages</li>
</ol>
<p><a title="CSS Rotate 2 Download" href="http://www.securityandcaffeine.com/projects/cssrotate2.zip">download css rotate 2</a></div>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.securityandcaffeine.com%2F2008%2F05%2F08%2Fcss-rotate-v2%2F&amp;linkname=CSS%20Rotate%20v2"><img src="http://www.securityandcaffeine.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/securityandcaffeine?a=npRnSCjY9a0:AbIsNvkj9pA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/securityandcaffeine?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/securityandcaffeine/~4/npRnSCjY9a0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.securityandcaffeine.com/2008/05/08/css-rotate-v2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.securityandcaffeine.com/2008/05/08/css-rotate-v2/</feedburner:origLink></item>
		<item>
		<title>PHP, MySQL, and mysql_fetch_array()</title>
		<link>http://feedproxy.google.com/~r/securityandcaffeine/~3/_FQOCHshx9w/</link>
		<comments>http://www.securityandcaffeine.com/2008/04/03/php-mysql-and-mysql_fetch_array/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 03:54:05 +0000</pubDate>
		<dc:creator>Mack Staples</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://securityandcaffeine.com/?p=5</guid>
		<description><![CDATA[Today, I spent a couple hours working on a customer management system for APS Web Design.  Over the course of that work, I discovered a very interesting behavior in a particular function, specifically mysql_fetch_array(). For those not familiar with it, but familiar with PHP, this function takes the results returned by mysql_query(), and turns it into [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I spent a couple hours working on a customer management system for <a title="APS Web Design" href="http://www.apswebdesign.com" target="_blank">APS Web Design</a>.  Over the course of that work, I discovered a very interesting behavior in a particular function, specifically <strong>mysql_fetch_array()</strong>.</p>
<p>For those not familiar with it, but familiar with PHP, this function takes the results returned by <strong>mysql_query()</strong>, and turns it into an array of values.  There are two other functions that do similar things: <strong>mysql_fetch_row()</strong> and <strong>mysql_fetch_assoc()</strong>.</p>
<p><strong>mysql_fetch_row()</strong> &#8221;fetches one row of data from the result associated with the specified result identifier.  The row is returned as an array.  Each result column is stored in an array offset, starting at offset 0&#8243;. <a title="PHP.net Reference for mysql_fetch_row" href="http://us.php.net/mysql_fetch_row" target="_blank"><em>source</em></a></p>
<p>So, first value is <strong>$result[0]</strong>, second is <strong>$result[1]</strong>, and so on.</p>
<p><strong>mysql_fetch_assoc()</strong> &#8220;returns an asociative array of strings that corresponds to the fetched row&#8221;. <a title="PHP.net Reference for mysql_fetch_assoc" href="http://us3.php.net/mysql_fetch_assoc" target="_blank"><em>source</em>  </a>That is, each value that is returned is part of a pair: a &#8220;key&#8221; (index) value, and the actual value.  The &#8220;key&#8221; names correspond to the name of the field in the database.</p>
<p>So, first value is <strong>$result['name']</strong>, second is <strong>$result['email']</strong>, and so on.</p>
<p>When I&#8217;m coding, I like to have access to both the &#8220;key&#8221; values, and the numeric index.  Now, in all honesty, I almost always use &#8220;key&#8221; values, over numeric, but I still like having the option.  This is where <strong>mysql_fetch_array()</strong> comes in.</p>
<p><strong>mysql_fetch_array()</strong> will give you &#8220;an array with both associative and number indices.&#8221; <a title="PHP.net Reference for mysql_fetch_array" href="http://us3.php.net/manual/en/function.mysql-fetch-array.php" target="_blank"><em>source</em></a></p>
<p>Many other languages can do both associative (&#8220;key&#8221; index) and numeric indices by default.  Others are constrained to just numeric.  Here, PHP is giving us both.  </p>
<p>The question: <em>how?</em></p>
<p>The answer: <em>it cheats!</em></p>
<p>Seriously.  It cheats.  What do I mean?  I mean that the numeric indices are not truly referencing the position of the value.  One would expect that &#8220;<strong>$result[0]</strong>&#8221; would reference the value in the first position.  It does not.  This can easily be verified with a handy <strong>print_r()</strong>, or the following loop:</p>
<blockquote><p><strong>$result = mysql_fetch_array($result);<br />
foreach ($result as $key =&gt; $value)<br />
echo $key . &#8216;=&#8217; . $value . &#8216;&lt;br /&gt;&#8217;;</strong></p></blockquote>
<p>The result of that loop, on a data set I was working with, returned the following:</p>
<blockquote><p>0=mack<br />
username=mack<br />
1=1<br />
job_num=1<br />
2=Mack Staples<br />
name=Mack Staples<br />
3=5415551234<br />
phone_num= 5415551234<br />
4=test@example.com<br />
email=test@example.com</p></blockquote>
<p>What do you notice?  Every value is in there twice, and while the &#8217;0&#8242; value is indeed in the first position, the rest of the numbers don&#8217;t correlate.  So what is it doing?</p>
<p><strong>mysql_fetch_array()</strong> is building a larger array (twice the size of either of the other functions) and using the numbers not as true indexes, but as associative &#8220;key&#8221; values.  This means a couple of things.</p>
<p>1 &#8211; You are wasting speed if you reference the values, but don&#8217;t use quotes.  According to <a title="Reinhold Weber's Blog" href="http://reinholdweber.com/?p=3" target="_blank"><em>Reinhold Weber&#8217;s Blog</em></a>:  #17: &#8220;<span>$row[’id’] is 7 times faster than $row[id]&#8220;.  If you&#8217;re doing this a lot, and often&#8230; ouch.</span></p>
<p>2 &#8211; You&#8217;re wasting speed just using it.  From having to initially populate twice the data into an array, to a slowdown copying the array to other memory locations, this can cost you performance.</p>
<p>So, what can we do about it?</p>
<p>1 &#8211; Use quotes!  1/7th of the time to get <strong>$result['2']</strong> compared to <strong>$result[2]</strong>.  Simple speed fix.</p>
<p>2 &#8211; Using <strong>mysql_fetch_array()</strong> is up to you.  For what I usually use database results for, the difference is negligible.  I do small, infrequent queries, and I like having both numeric and associated indices.  To me, it&#8217;s worth the <em>minor</em> performance hit.</p>
<p>Code Safe. Code Smart.  <em>Be paranoid.</em></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.securityandcaffeine.com%2F2008%2F04%2F03%2Fphp-mysql-and-mysql_fetch_array%2F&amp;linkname=PHP%2C%20MySQL%2C%20and%20mysql_fetch_array%28%29"><img src="http://www.securityandcaffeine.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/securityandcaffeine?a=_FQOCHshx9w:fJBeEXIcPkc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/securityandcaffeine?d=yIl2AUoC8zA" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/securityandcaffeine/~4/_FQOCHshx9w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.securityandcaffeine.com/2008/04/03/php-mysql-and-mysql_fetch_array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.securityandcaffeine.com/2008/04/03/php-mysql-and-mysql_fetch_array/</feedburner:origLink></item>
	</channel>
</rss><!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
