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

<channel>
	<title>Security and Engineering</title>
	<atom:link href="http://blog.flakks.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.flakks.com</link>
	<description>Computer Security, Ruby and RoR Snippets, OpenSource Software</description>
	<pubDate>Sun, 15 Aug 2010 11:08:39 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>strange ruby syntax issue when using rescue</title>
		<link>http://blog.flakks.com/?p=39</link>
		<comments>http://blog.flakks.com/?p=39#comments</comments>
		<pubDate>Sun, 15 Aug 2010 11:06:44 +0000</pubDate>
		<dc:creator>vetter</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.flakks.com/?p=39</guid>
		<description><![CDATA[irb(main):001:0> x = "value"
=> "value"
irb(main):002:0> x = puts undefined_variable rescue nil
=> nil
irb(main):003:0> x
=> "value"
irb(main):004:0> x = puts(undefined_variable) rescue nil
=> nil
irb(main):005:0> x
=> nil
irb(main):006:0> 
You might understand why this happens when you think about it, but it&#8217;s rather unintuitive, though.
]]></description>
			<content:encoded><![CDATA[<p><code>irb(main):001:0> x = "value"<br />
=> "value"<br />
irb(main):002:0> x = puts undefined_variable rescue nil<br />
=> nil<br />
irb(main):003:0> x<br />
=> "value"<br />
irb(main):004:0> x = puts(undefined_variable) rescue nil<br />
=> nil<br />
irb(main):005:0> x<br />
=> nil<br />
irb(main):006:0> </code></p>
<p>You might understand why this happens when you think about it, but it&#8217;s rather unintuitive, though.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flakks.com/?feed=rss2&amp;p=39</wfw:commentRss>
		</item>
		<item>
		<title>iphone scribble webapp</title>
		<link>http://blog.flakks.com/?p=34</link>
		<comments>http://blog.flakks.com/?p=34#comments</comments>
		<pubDate>Tue, 20 Jul 2010 10:06:29 +0000</pubDate>
		<dc:creator>vetter</dc:creator>
		
		<category><![CDATA[Engineering]]></category>

		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.flakks.com/?p=34</guid>
		<description><![CDATA[As already mentioned through twitter i&#8217;m playing around with the iphone and the canvas element to build a scribble webapp running on the device (and android devices as well). It should be possible to save/upload the scribbled image afterwards. Here&#8217;s a first code snippet






&#60;!DOCTYPE html&#62;

&#60;html&#62;
  &#60;head&#62;
    &#60;script type=&#34;text/javascript&#34; src=&#34;http://code.jquery.com/jquery-1.4.2.min.js&#34;&#62;&#60;/script&#62;
   [...]]]></description>
			<content:encoded><![CDATA[<p>As already mentioned through twitter i&#8217;m playing around with the iphone and the canvas element to build a scribble webapp running on the device (and android devices as well). It should be possible to save/upload the scribbled image afterwards. Here&#8217;s a first code snippet</p>

<a href='http://blog.flakks.com/?attachment_id=36' title='bildschirmfoto-2010-07-20-um-104850'><img src="http://blog.flakks.com/wp-uploads/2010/07/bildschirmfoto-2010-07-20-um-104850-150x150.png" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://blog.flakks.com/?attachment_id=37' title='bildschirmfoto-2010-07-20-um-104924'><img src="http://blog.flakks.com/wp-uploads/2010/07/bildschirmfoto-2010-07-20-um-104924-150x150.png" width="150" height="150" class="attachment-thumbnail" alt="" /></a>
<a href='http://blog.flakks.com/?attachment_id=38' title='bildschirmfoto-2010-07-20-um-104956'><img src="http://blog.flakks.com/wp-uploads/2010/07/bildschirmfoto-2010-07-20-um-104956-150x150.png" width="150" height="150" class="attachment-thumbnail" alt="" /></a>

<pre name="code" class="xhtml">
&lt;!DOCTYPE html&gt;

&lt;html&gt;
  &lt;head&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.4.2.min.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;http://jasonkuhn.net/mobile/jqui/js/jquery.iphoneui.js&quot;&gt;&lt;/script&gt;

    &lt;meta content=&quot;width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;&quot; name=&quot;viewport&quot; /&gt;
    &lt;meta charset=&quot;utf-8&quot;&gt;
  &lt;/head&gt;

  &lt;body style=&quot;margin: 0; padding: 0; -webkit-text-size-adjust: none; padding-left: 10px; padding-top: 10px;&quot;&gt;
    &lt;button id=&quot;save&quot; style=&quot;position: absolute; margin-left: 10px; margin-top: 10px;&quot;&gt;save&lt;/button&gt;

    &lt;script type=&quot;text/javascript&quot;&gt;
      $(document).ready(
        function() {
          $(&quot;body&quot;).append(&quot;&lt;canvas id=&#39;canvas&#39; style=&#39;border: 1px solid #000;&#39;&gt;&lt;/canvas&gt;&quot;);

          $(&quot;#canvas&quot;).attr(&quot;width&quot;, (window.innerWidth ? window.innerWidth : $(window).width()) - 20);
          $(&quot;#canvas&quot;).attr(&quot;height&quot;, (window.innerHeight ? window.innerHeight : $(window).height())- 20);

          $(&quot;#canvas&quot;).addTouch();

          var ctx = $(&quot;#canvas&quot;)[0].getContext(&quot;2d&quot;);

          ctx.lineCap = &quot;round&quot;;
          ctx.lineWidth = 15;

          var start_x = null, start_y = null, drawing = false;

          $(&quot;#canvas&quot;).bind(&quot;mousedown&quot;,
            function(e) {
              drawing = true;

              start_x = e.pageX - $(&quot;#canvas&quot;).offset().left;
              start_y = e.pageY - $(&quot;#canvas&quot;).offset().top;
            }
          );

          $(&quot;#canvas&quot;).bind(&quot;mouseup&quot;,
            function(e) {
              drawing = false;
            }
          );

          $(&quot;#canvas&quot;).bind(&quot;mousemove&quot;,
            function(e) {
              if(!drawing)
                return;

              var x = e.pageX - $(&quot;#canvas&quot;).offset().left;
              var y = e.pageY - $(&quot;#canvas&quot;).offset().top;

              ctx.beginPath();
              ctx.moveTo(start_x, start_y);
              ctx.lineTo(x, y);
              ctx.stroke();

              e.preventDefault();

              start_x = x;
              start_y = y;
            }
          );

          $(&quot;#save&quot;).click(
            function() {
              var data = $(&quot;#canvas&quot;)[0].toDataURL(&quot;image/png&quot;).replace(/^[^,] ,/, &quot;&quot;);

              $.ajax({
                 type: &quot;post&quot;,
                 url: &quot;/images/upload&quot;,
                 data: &quot;image=&quot;   encodeURIComponent(data),
                 processData: false
              });
            }
          );
        }
      );
    &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<p><strong>Step 1: Drawing</strong></p>
<p>Drawing within the canvas is straight forward. We use mousedown, mouseup and mousemove to recognize the mouse events and draw lines between the coordinates.</p>
<p><strong>Step 2: Upload</strong></p>
<p>Uploading the the scribbled image is straight forward too, thanks <code>canvas.toDataURL</code>. toDataURL encodes the canvas using base64 what allows us to upload the encoded image using ajax or a form. </p>
<p>Of couse we need some server side processing. Using rails this could look like</p>
<pre name="code" class="ruby">
class ImagesController < ApplicationController
  def upload
    open("#{RAILS_ROOT}/public/images/upload.png", "w") do |stream|
      stream.write decode64(params[:image])
     end 

    render(:update) { |page| page.alert("saved") }
  end
end
</pre>
<p><strong>Step 3: Iphone</strong></p>
<p>Thanks to <a href="http://jasonkuhn.net/mobile/jqui/js/jquery.iphoneui.js">this jquery plugin</a> getting this to work on the iphone is as easy as including a javascript file. It translates the iphone&#8217;s javascript touch events (touchstart, touchmove, touchend) to mousedown, mouseup, mousemove, &#8230; if you addTouch() to the element. </p>
<p>That&#8217;s it. Maybe it&#8217;s worth to continue working on it and publishing it as a real project, because adding a scribble-webapp (within an iframe maybe?) could be a nice feature for many mobile webapps.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flakks.com/?feed=rss2&amp;p=34</wfw:commentRss>
		</item>
		<item>
		<title>rails plugin testing</title>
		<link>http://blog.flakks.com/?p=33</link>
		<comments>http://blog.flakks.com/?p=33#comments</comments>
		<pubDate>Fri, 16 Jul 2010 11:46:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Engineering]]></category>

		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.flakks.com/?p=33</guid>
		<description><![CDATA[I personally think there is not enough written about rails plugin testing, you have to deal with some problems, though, because you don&#8217;t have the rails environment on your side. I want to give 2 tips.
Tip 1:
When you extend ActionController::Base within your plugin, put your extensions into a module within a separate file. Then create [...]]]></description>
			<content:encoded><![CDATA[<p>I personally think there is not enough written about rails plugin testing, you have to deal with some problems, though, because you don&#8217;t have the rails environment on your side. I want to give 2 tips.</p>
<p><strong>Tip 1:</strong></p>
<p>When you extend ActionController::Base within your plugin, put your extensions into a module within a separate file. Then create another file where you extend ActionController::Base like so</p>
<pre name="code" class="ruby">
require "my_fancy_controller_extension"

class ActionController::Base
  include MyFancyControllerExtension
end
</pre>
<p>The first advantage of doing it this way is: you can make your extensions protected</p>
<pre name="code" class="ruby">
class ActionController::Base
  protected

  include MyFancyControllerExtension
end
</pre>
<p>and you can test your extensions without dealing with permissions: my_fancy_controller_extension_test.rb</p>
<pre name="code" class="ruby">
class MyFancyControllerExtensionTest &lt; Test::Unit::TestCase
  class DummyController
    include MyFancyControllerExtension
  end

  def test_whatever
    assert DummyController.new....

    # oh yeah, the fancy extensions are not protected within these tests
  end
end
</pre>
<p>This leads to</p>
<p><strong>Tip 2:</strong></p>
<p>Don&#8217;t try to load the whole rails environment within your plugin tests. Loading the whole environment is a lot of work, dependencies, paths, &#8230;. Avoid that, where you can. Instead, create dummy controllers, views, models, &#8230; to only build the interface neccessary for testing. Use duck typing! One example:</p>
<pre name="code" class="ruby">
class TestController
  attr_accessor :request, :session, ... # only what your plugin code needs

  class TestRequest
    attr_accessor :host, ...
  end
end

def MyFancyControllerExtensionTest &lt; Test::Unit::TestCase
  def setup
    @controller = TestController.new
  end

  ...
end
</pre>
<p>This helps a lot when you don&#8217;t know where to start your tests.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flakks.com/?feed=rss2&amp;p=33</wfw:commentRss>
		</item>
		<item>
		<title>mobile-fu rjs</title>
		<link>http://blog.flakks.com/?p=32</link>
		<comments>http://blog.flakks.com/?p=32#comments</comments>
		<pubDate>Thu, 15 Jul 2010 14:21:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Engineering]]></category>

		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://blog.flakks.com/?p=32</guid>
		<description><![CDATA[hm&#8230; hm&#8230; hm&#8230; hm
I&#8217;m a bit unsatisfied with mobile-fu for rails. Sure, it&#8217;s great in general, but I want to have different templates for mobile rjs and default rjs and i think it&#8217;s a bit clumsy to do it like that:
application.html.erb

def mobile?
  return session[:mobile_view]
end

# distinct between mobile and non-mobile js (mobile-fu)
# only supports :template [...]]]></description>
			<content:encoded><![CDATA[<p>hm&#8230; hm&#8230; hm&#8230; hm</p>
<p>I&#8217;m a bit unsatisfied with <a href="http://github.com/brendanlim/mobile-fu">mobile-fu</a> for rails. Sure, it&#8217;s great in general, but I want to have different templates for mobile rjs and default rjs and i think it&#8217;s a bit clumsy to do it like that:</p>
<p>application.html.erb</p>
<pre name="code" class="ruby">
def mobile?
  return session[:mobile_view]
end

# distinct between mobile and non-mobile js (mobile-fu)
# only supports :template paramter for mobile-enabled js

def render_mobilized_js(options = nil)
  # if we&#8217;re not mobile =&gt; render like there is no mobile

  unless mobile?
    return render options if options
    return render
  end

  # render mobilized rjs template

  ops = (options || {}).dup

  ops[:template] ||= &#8220;#{controller_name}/#{action_name}&#8221;
  ops[:template] += &#8220;.mobile_js.rjs&#8221;

  return render ops
end
</pre>
<p>but now I&#8217;m able to do this</p>
<pre name="code" class="ruby">
respond_to do |format|
  format.html
  format.js { render_mobilized_js }
end
</pre>
<p>But in an ideal world i don&#8217;t want to call render at all. I want rails or mobile-fu to do it for me:</p>
<pre name="code" class="ruby">
respond_to do |format|
  format.html
  format.js
  format.mobile_js
end
</pre>
<p>Not yet possible - and if it would be possible it would break dependencies. Therefore i keep using my method - unless anyone points me a step towards the elegant solution&#8230; anyone?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flakks.com/?feed=rss2&amp;p=32</wfw:commentRss>
		</item>
		<item>
		<title>ruby spreadsheet library</title>
		<link>http://blog.flakks.com/?p=31</link>
		<comments>http://blog.flakks.com/?p=31#comments</comments>
		<pubDate>Wed, 05 May 2010 10:07:44 +0000</pubDate>
		<dc:creator>vetter</dc:creator>
		
		<category><![CDATA[Engineering]]></category>

		<guid isPermaLink="false">http://blog.flakks.com/?p=31</guid>
		<description><![CDATA[Thumbs up for http://spreadsheet.rubyforge.org/ A ruby library for accessing .xls files. Really comfortable. Just missing a way to access columns by excel-like captions

sheet.row(0)["AA"]

Maybe i just didn&#8217;t find it, but nevertheless you can of course extend String, though

class String
  def to_excel_index
    each_char.collect{ &#124;c&#124; ("A".."Z").to_a.index(c) }.
      inject { [...]]]></description>
			<content:encoded><![CDATA[<p>Thumbs up for http://spreadsheet.rubyforge.org/ A ruby library for accessing .xls files. Really comfortable. Just missing a way to access columns by excel-like captions</p>
<pre name="code" class="ruby">
sheet.row(0)["AA"]
</pre>
<p>Maybe i just didn&#8217;t find it, but nevertheless you can of course extend String, though</p>
<pre name="code" class="ruby">
class String
  def to_excel_index
    each_char.collect{ |c| ("A".."Z").to_a.index(c) }.
      inject { |sum, n| sum + (sum + 1) * 25 + n + 1 }
  end
end
</pre>
<p>and use</p>
<pre name="code" class="ruby">
sheet.row(0)["AA".to_excel_index]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.flakks.com/?feed=rss2&amp;p=31</wfw:commentRss>
		</item>
		<item>
		<title>My article for linux technical review</title>
		<link>http://blog.flakks.com/?p=30</link>
		<comments>http://blog.flakks.com/?p=30#comments</comments>
		<pubDate>Wed, 31 Mar 2010 17:25:18 +0000</pubDate>
		<dc:creator>vetter</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[Virtualization]]></category>

		<guid isPermaLink="false">http://blog.flakks.com/?p=30</guid>
		<description><![CDATA[A few weeks ago I wrote an article on virtualization security. See here http://www.linuxtechnicalreview.de/Vorschau/%28show%29/Themen/Virtualisierung/Sicherheit-in-virtuellen-Umgebungen
]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I wrote an article on virtualization security. See here <a href="http://www.linuxtechnicalreview.de/Vorschau/%28show%29/Themen/Virtualisierung/Sicherheit-in-virtuellen-Umgebungen">http://www.linuxtechnicalreview.de/Vorschau/%28show%29/Themen/Virtualisierung/Sicherheit-in-virtuellen-Umgebungen</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flakks.com/?feed=rss2&amp;p=30</wfw:commentRss>
		</item>
		<item>
		<title>17th dfn cert workshop</title>
		<link>http://blog.flakks.com/?p=29</link>
		<comments>http://blog.flakks.com/?p=29#comments</comments>
		<pubDate>Wed, 31 Mar 2010 17:20:37 +0000</pubDate>
		<dc:creator>vetter</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[Virtualization]]></category>

		<guid isPermaLink="false">http://blog.flakks.com/?p=29</guid>
		<description><![CDATA[I was speaking on the 17th dfn cert workshop on virtualization security. It was quite cool to speak in front of such a large audience. There was quite a good response. Here is the link to the workshop website: http://www.dfn-cert.de/veranstaltungen/workshop.html
Here is the conference room when i arrived in the morning before it was full.

]]></description>
			<content:encoded><![CDATA[<p>I was speaking on the 17th dfn cert workshop on virtualization security. It was quite cool to speak in front of such a large audience. There was quite a good response. Here is the link to the workshop website: <a href="http://www.dfn-cert.de/veranstaltungen/workshop.html">http://www.dfn-cert.de/veranstaltungen/workshop.html</a></p>
<p>Here is the conference room when i arrived in the morning before it was full.</p>
<p><img class="alignnone" src="http://farm5.static.flickr.com/4001/4343357683_c469ba9703.jpg" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flakks.com/?feed=rss2&amp;p=29</wfw:commentRss>
		</item>
		<item>
		<title>hping2 for the nokia n900</title>
		<link>http://blog.flakks.com/?p=25</link>
		<comments>http://blog.flakks.com/?p=25#comments</comments>
		<pubDate>Sun, 10 Jan 2010 12:19:01 +0000</pubDate>
		<dc:creator>vetter</dc:creator>
		
		<category><![CDATA[Engineering]]></category>

		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://blog.flakks.com/?p=25</guid>
		<description><![CDATA[I recently played with the &#8220;sdk&#8221; for my nokia n900. The &#8220;sdk&#8221; is a cross compilation platform built on scratchbox. The n900 runs maemo, a debian based linux for the arm architecture. I wanted to compile netcat for the phone until i found this, which perfectly runs on the phone. Then i decided to compile [...]]]></description>
			<content:encoded><![CDATA[<p>I recently played with the &#8220;sdk&#8221; for my nokia n900. The &#8220;sdk&#8221; is a cross compilation platform built on <a href="http://www.scratchbox.org/">scratchbox</a>. The n900 runs <a href="http://maemo.org/">maemo</a>, a debian based linux for the arm architecture. I wanted to compile netcat for the phone until i found <a href="https://garage.maemo.org/frs/?group_id=237&amp;release_id=544">this</a>, which perfectly runs on the phone. Then i decided to compile <a href="http://www.hping.org/">hping2</a> - and you can <a href="/wp-uploads/2010/01/hping2-rc3.deb">download</a> my package and install it on your n900. I&#8217;ll upload it to the maemo garage, too.</p>
<p><a href="https://garage.maemo.org/projects/hping2/">https://garage.maemo.org/projects/hping2/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flakks.com/?feed=rss2&amp;p=25</wfw:commentRss>
		</item>
		<item>
		<title>Webbased Password Managers</title>
		<link>http://blog.flakks.com/?p=21</link>
		<comments>http://blog.flakks.com/?p=21#comments</comments>
		<pubDate>Tue, 08 Sep 2009 11:36:24 +0000</pubDate>
		<dc:creator>vetter</dc:creator>
		
		<category><![CDATA[Engineering]]></category>

		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://blog.flakks.com/?p=21</guid>
		<description><![CDATA[In this post I&#8217;ll describe problems that arise when you try to develop a webbased password safe.
Imagine an arbitrary company with lots of employees, each using many passwords for many different authentication purposes. Imagine different employees using different operating systems. To avoid them having bad cleartext passwords on their disk, you would like to have [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I&#8217;ll describe problems that arise when you try to develop a webbased password safe.</p>
<p>Imagine an arbitrary company with lots of employees, each using many passwords for many different authentication purposes. Imagine different employees using different operating systems. To avoid them having bad cleartext passwords on their disk, you would like to have a central and universal password manager running on a server keeping the passwords of different users, each having a strong master password to access all his passwords via his browser. You want the password manager to be as secure as possible, beause you have to keep passwords for company related systems and you want it to be as secure as any existing client-wise password manager, of course.</p>
<p>A naive approach, at first. Any attempt to access passwords has to be encrypted, of course, especially when we send passwords over an (insecure) network. Therefore we have to use SSL and the password manager has to enforce HTTPS. If we are trusting the server (that means: we have to ensure that the server won&#8217;t get compromised), we won&#8217;t have to encrypt the passwords on the server and we can store them in simple text files. But if the server ever gets compromised, all passwords are lost. To avoid cleartext passwords saved permanently on disk we have to encrypt them like every password safe does. We decrypt them when a user is authorized and wants us to and we store them within the server&#8217;s memory, but if someone can access the RAM the passwords are lost, too.</p>
<p>A password safe typically only stores passwords of a single user. In contrast, our webbased password safe stores passwords for the whole enterprise. Therefore, a server-compromise is more critical and imagine employees interested into reading other employee&#8217;s private mails, social network accounts and so on (aka insider attacks). We can solve this problem by never keeping a password in cleartext on the server, neither RAM, nor HDD. The encryption has to happen on the client. Therefore, we have to encrypt them on the client (within a browser). The guy compromising the server will get the encrypted files, but he won&#8217;t get the clear text passwords easily. Of course, he can bruteforce the master password, use cryptanalytical methods or just stay behind another employee&#8217;s neck while he is typing the master password, but every password manager has to deal with that possibility (but we have a central login now) and we can enforce strong master passwords and encryption centerally. This paradigm is related to <a href="http://en.wikipedia.org/wiki/Host-proof_hosting">Host-Proof-Hosting</a> (&#8221;<span class="solution"><em><a href="http://ajaxpatterns.org/Host-Proof_Hosting">Host sensitive data in encrypted form, so that clients can only access and manipulate it by providing a pass-phrase which is never transmitted to the server</a></em>&#8220;).</span></p>
<p>The encryption and decryption on the client could be done with javascript (<a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ecma-262</a> and <a href="http://code.google.com/p/clipperz">clipperz</a>), but how secure could, for example, an AES javascript-implementation be (not from a cryptanalytical point)? Is it guaranteed that passwords won&#8217;t be stored for long time within the client&#8217;s RAM, because we have to wait for javascript&#8217;s garbage collector? Usual password safes are written in C and they can manipulate memory directly. A javascript implementation is not able to do that. To show that, lets take a look into our memory while executing this with firefox 3.0.6 in a virtual machine running Debian Lenny and using the KVM - virtual machine monitor:</p>
<pre name="code" class="javascript">
var key = "";

for(var i = 0; i &lt; 3; i++) key += "M";
for(var i = 0; i &lt; 3; i++) key += "1";
for(var i = 0; i &lt; 3; i++) key += "K";
for(var i = 0; i &lt; 3; i++) key += "Y";
for(var i = 0; i &lt; 3; i++) key += "9";

key = "";
</pre>
<p>Suppose, &#8216;key&#8217; is a cryptographic key. We concat the key to be sure that we don&#8217;t have it as a complete string before we&#8217;re using it within the javascript code. We execute it and dump the memory using the kvm monitor mode:</p>
<pre>
pmemsave 0 134217728 memory.dmp
</pre>
<p>If we search for the key MMM111KKKYYY999 within memory.dmp we&#8217;ll find it. No surprise, javascript uses reference semantics, but the garbage collector doesn&#8217;t free the (now) unreferenced string. There is no way we can overwrite the portion of memory &#8216;key&#8217; was using. There are good reasons to let us not do that, because direct memory manipulation with javascript would be a very bad idea.</p>
<p>After we&#8217;ve left the website we dump memory again and this time we won&#8217;t find the key. Firefox 3.0.6, Chrome 2.0.172.43, Internet Explorer 6 and Opera 10 all show this behaviour. Therefore, a webbased password manager should force users to leave the page after a certain amount of time and - maybe - the password manager should only work with approved browser versions (versions that show this behaviour), because it is possible other browser (versions) store it even longer. But that will result in less flexibility.</p>
<p>Some huge problems remain, though. The largest: injecting malicious javascript code into the client. The javascript code is responsible for encryption and decryption on the client, but the code is loaded from the server dynamically. A server compromise is therefore still the biggest issue, because an attacker could inject malicious code into all clients and steal all passwords. Therefore, the code itself has to approved in some way. <a href="http://www.clipperz.com/">Clipperz</a>, for example, is of course aware of this problem and agrees: &#8220;<em><a href="http://groups.google.com/group/clipperz/browse_thread/thread/94846a5544d13a72">there are no perfect solutions to avoid this problem</a></em>&#8220;.</p>
<p>In a nutshell, a webbased password manager could have different levels of security.</p>
<ol>
<li>Security only lies within secure transportation (HTTPS) of passwords to the client to avoid sniffing passwords. Cleartext passwords exist on clients and on the server hosting the passwords, both for an (nearly) arbitrary amount of time.</li>
<li>Cleartext passwords only exist on clients, but for an (nearly) arbitrarty amount of time.</li>
<li>Cleartext passwords only exist on clients for a predefined period of time.</li>
</ol>
<p>Option 3 is the most inflexilible one, because we have to use approved components only (Browser, Javascript implementation, Operating System&#8217;s clipboard implementation, Javascript-Code and so on) and whether we decrypt passwords only on the client or not, we have to trust into the server, because we have to trust into the application and if the server is compromised, an attacker could inject malicious code.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flakks.com/?feed=rss2&amp;p=21</wfw:commentRss>
		</item>
		<item>
		<title>Consolidating Servers securely?</title>
		<link>http://blog.flakks.com/?p=17</link>
		<comments>http://blog.flakks.com/?p=17#comments</comments>
		<pubDate>Thu, 20 Aug 2009 18:47:25 +0000</pubDate>
		<dc:creator>vetter</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[Virtualization]]></category>

		<guid isPermaLink="false">http://blog.flakks.com/?p=17</guid>
		<description><![CDATA[My previous posts showed how virtualization could lower your system&#8217;s security potentially. Virtualization introduces higher risks by means of

Management of virtual environments, like Mobility and Identity of Virtual Machines

How Virtual Machines connect to your physical network
Virtualization-Technology specific Issues, like DMA (see IO-Virtualization) and Complexity (see CPU-Virtualization)
Typical Vulnerabilities, like DoS (see KVM-Thrashing), VM-Escape and Privilege Escalation

Therefore, [...]]]></description>
			<content:encoded><![CDATA[<p>My previous posts showed how virtualization could lower your system&#8217;s security potentially. Virtualization introduces higher risks by means of</p>
<ol>
<li><em><a href="http://blog.flakks.com/?p=15">Management of virtual environments</a></em>, like Mobility and Identity of Virtual Machines<a href="http://blog.flakks.com/?p=15"><br />
</a></li>
<li><em><a href="http://blog.flakks.com/?p=16">How Virtual Machines connect to your physical network</a></em></li>
<li>Virtualization-Technology specific Issues, like DMA (see <em><a href="http://blog.flakks.com/?p=14">IO-Virtualization</a></em>) and Complexity (see <em><a href="http://blog.flakks.com/?p=13">CPU-Virtualization</a></em>)</li>
<li>Typical Vulnerabilities, like DoS (see <em><a href="http://blog.flakks.com/?p=12">KVM-Thrashing</a></em>), VM-Escape and Privilege Escalation</li>
</ol>
<p>Therefore, if an enterprise wants to introduce Virtualization into its systems, it has to enforce measures to enhance security aspects of virtualization technologies and to avoid the pitfalls. As a result of my posts and work, these measures have to be taken:</p>
<ul>
<li><strong>Don&#8217;t consolidate Guests with different security-needs on the same Host-Machine.</strong></li>
</ul>
<p>An intrusion into systems with low security-needs is more likely. After this first step, it would be easier for an Intruder to attack sytems with higher security-needs if these systems are located upon the same VMM. This measure is taken to keep isolation between systems of different needs for security. If you have multiple Demilitarized Zones, keep them physically isolated: don&#8217;t consolidate hosts of different DMZs upon the same VMM and don&#8217;t try to create virtual DMZs instead of physical ones.</p>
<ul>
<li><strong>Choose a low-complexity-VMM as a base for your virtual environment</strong></li>
</ul>
<p>The more complex a VMM, the more likely it&#8217;ll contain vulnerabilities. Different Virtualization-Technologies differ very much in complexity as well. Your important systems require low-complexity-VMMs. Such a VMM should be a Bare-Metal VMM. It should use Virtualization-Extensions of modern CPUs or Paravirtualization instead of more complex technologies, like dynamic Binary Rewriting techniques. It should use an IOMMU to avoid DMA-Issues (see <a href="http://blog.flakks.com/?p=14"><em>Security and IO-Virtualization</em></a>) and it should focus on Virtualization-Purposes only, because the more you put into the VMM-Layer, the more complex it&#8217;ll get. Static allocation of ressources (like RAM) is another way to lower complexity.</p>
<ul>
<li><strong>Maximize VMM/Host-Security</strong></li>
</ul>
<p>If an intruder gains access to a VMM, all Guests of this particular VMM have to be considered as compromised. A VMM is an Operating System. Therefore, you have to apply Best-Practices for this OS to protect it from usual attacks (Remove services you don&#8217;t need, &#8230;) and you have to patch your OS and all applications running upon it. You have to enhance Isolation and lower sharing of ressources.</p>
<ul>
<li><strong>Lower your VMM&#8217;s consolidation-potential</strong></li>
</ul>
<p>A VMM is a Single Point of Failure. Utilization of your VMM&#8217;s Server-Hardware will be much higher, because that is what we want virtualization for: higher utilization. Therefore, we have to prepare for a defect by redundancy, because more systems will be effected by this defect. In addition, to lower the risk of attacks on availability (DoS), we could set a limit for the number of guests a VMM should run, because otherwise the Denial of Service of a single VMM leads to a Denial of Service of an arbitrary number of Systems. If you want to take this measure to the next level, don&#8217;t consolidate Guests, which don&#8217;t need each other to operate, on the same VMM. Indepent systems are no longer independent in terms of VMM-Availability, if they run on the same VMM. But you have to choose measures appropiate for your purposes, of course.</p>
<ul>
<li><strong>Don&#8217;t lower/remove your already established security measures</strong></li>
</ul>
<p>Virtual Machines contain the same vulnerabilities like physical machines. Therefore, you have to enforce your existing security measures in virtualized environments as well (patch, harden, monitor them &#8230;).</p>
<ul>
<li><strong>Less People to administer a VMM</strong></li>
</ul>
<p>A VMM&#8217;s admin has privileged access to every guest running upon it. Therefore, a VMM&#8217;s admin has to be considered as trustworthy and you have to lower the number of people to administer a VMM. This measure will lower the risk of insider attacks primarily.</p>
<ul>
<li><strong>Less Mobility of Virtual Machines</strong></li>
</ul>
<p>Deny arbitrary relocation of virtual machines, because a VMM&#8217;s admin has privileged access to every Guest. Moving Guests should only be possible where the admin of the source VMM is the admin of the destination VMM as well - or if the admins belong to the same group. In addition, the destination VMM has to enforce a same set of security-measures as the source VMM.</p>
<ul>
<li><strong>Define processes for deployment and maintainance of Guests</strong></li>
</ul>
<p>These processes avoid sporadically used guests, without any associated patch cycle. Every guest has to be registered centerally, to be able to clean them if they get infected by malware. Before you&#8217;re using a Roll-Back-Mechanism you have to check for consequences and document such steps (see <a href="http://blog.flakks.com/?p=15"><em>Management of Virtual Machines - Security Concerns</em></a>).</p>
<p>In a nutshell and from a management perspective: the more flexibility and consolidation-potential you are willing to loose, the more secure your virtual environments could get. But, flexibility and consolidation-potential is what we want virtualization for. Therefore, our gains of virtualization are up to a point contrary to our system&#8217;s security-needs and the steps you have to take depend on your systems and their needs - and to which degree you are willing to loose the benefits of virtualization.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flakks.com/?feed=rss2&amp;p=17</wfw:commentRss>
		</item>
	</channel>
</rss>
