<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Safe Strings for Security?</title>
	<atom:link href="http://jessenoller.com/2007/08/17/safe-strings-for-security/feed/" rel="self" type="application/rss+xml" />
	<link>http://jessenoller.com/2007/08/17/safe-strings-for-security/</link>
	<description>python, programming and other things</description>
	<lastBuildDate>Sun, 04 Mar 2012 06:06:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tom Moertel</title>
		<link>http://jessenoller.com/2007/08/17/safe-strings-for-security/comment-page-1/#comment-2597</link>
		<dc:creator>Tom Moertel</dc:creator>
		<pubDate>Thu, 23 Aug 2007 21:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/08/17/safe-strings-for-security/#comment-2597</guid>
		<description>You pose a good question:  Does a static system need run-time help to address non-static strings?  Happily, the answer is no. 

That&#039;s because even though the &lt;em&gt;values&lt;/em&gt; of non-static strings may be unknown until run time, the &lt;em&gt;types&lt;/em&gt; of the strings &lt;em&gt;will&lt;/em&gt; be known at compile time, and that&#039;s enough for the system to do its work.  If the system knows, for example, that some function takes an HTML template and a string representing plain-old text, the system can verify at compile time that the way the function combines the text with the template is safe, even though the system may have no idea what &lt;em&gt;values&lt;/em&gt; the template or the text will take until run time.

Cheers! --Tom</description>
		<content:encoded><![CDATA[<p>You pose a good question:  Does a static system need run-time help to address non-static strings?  Happily, the answer is no. </p>
<p>That’s because even though the <em>values</em> of non-static strings may be unknown until run time, the <em>types</em> of the strings <em>will</em> be known at compile time, and that’s enough for the system to do its work.  If the system knows, for example, that some function takes an HTML template and a string representing plain-old text, the system can verify at compile time that the way the function combines the text with the template is safe, even though the system may have no idea what <em>values</em> the template or the text will take until run time.</p>
<p>Cheers! –Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jesse</title>
		<link>http://jessenoller.com/2007/08/17/safe-strings-for-security/comment-page-1/#comment-2585</link>
		<dc:creator>jesse</dc:creator>
		<pubDate>Thu, 23 Aug 2007 18:23:47 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/08/17/safe-strings-for-security/#comment-2585</guid>
		<description>Thank you - more to think about on my part, I still see you having to address unsafe strings at runtime on non-static strings, at the end of the day, baking more safety into the compiler/interpreter/language is never a bad thing.</description>
		<content:encoded><![CDATA[<p>Thank you — more to think about on my part, I still see you having to address unsafe strings at runtime on non-static strings, at the end of the day, baking more safety into the compiler/interpreter/language is never a bad thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Moertel</title>
		<link>http://jessenoller.com/2007/08/17/safe-strings-for-security/comment-page-1/#comment-2584</link>
		<dc:creator>Tom Moertel</dc:creator>
		<pubDate>Thu, 23 Aug 2007 18:12:30 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/08/17/safe-strings-for-security/#comment-2584</guid>
		<description>jesse, thanks for your response.

You are missing something fundamental to the nature of (modern) static type systems.  You wrote that:

&lt;blockquote&gt;[With a compile-type safety system] youâ€™re only protecting a programmer from leveraging an unsafe string during code-compilation time. I think (opinion mind you) that your time would be better spent [...] designing ways to cope with these issues/attacks at runtime.
&lt;/blockquote&gt;

What you are missing is that that compile-time system &lt;em&gt;proves&lt;/em&gt; that these issues &lt;em&gt;cannot&lt;/em&gt; occur at run time.  Once you have that guarantee, you have &lt;em&gt;no need&lt;/em&gt; to attempt to cope with the issue anymore, &lt;em&gt;at all&lt;/em&gt;, let alone at run time. The issue is gone.  

And as far as being &quot;shackled&quot; into the system goes, the only thing you are shacked into is not doing things that would be potentially unsafe if allowed at occur at run-time.  In my &lt;a href=&quot;http://blog.moertel.com/articles/2006/10/18/a-type-based-solution-to-the-strings-problem&quot; rel=&quot;nofollow&quot;&gt;Haskell-based implementation&lt;/a&gt;, for example, it&#039;s no more difficult to write safe-string code than it is to write unsafe everything-is-just-a-string code, but it&#039;s a whole lot safer.

Cheers,
Tom</description>
		<content:encoded><![CDATA[<p>jesse, thanks for your response.</p>
<p>You are missing something fundamental to the nature of (modern) static type systems.  You wrote that:</p>
<blockquote><p>[With a compile-type safety system] youâ€™re only protecting a programmer from leveraging an unsafe string during code-compilation time. I think (opinion mind you) that your time would be better spent […] designing ways to cope with these issues/attacks at runtime.
</p></blockquote>
<p>What you are missing is that that compile-time system <em>proves</em> that these issues <em>cannot</em> occur at run time.  Once you have that guarantee, you have <em>no need</em> to attempt to cope with the issue anymore, <em>at all</em>, let alone at run time. The issue is gone.  </p>
<p>And as far as being “shackled” into the system goes, the only thing you are shacked into is not doing things that would be potentially unsafe if allowed at occur at run-time.  In my <a href="http://blog.moertel.com/articles/2006/10/18/a-type-based-solution-to-the-strings-problem" rel="nofollow">Haskell-based implementation</a>, for example, it’s no more difficult to write safe-string code than it is to write unsafe everything-is-just-a-string code, but it’s a whole lot safer.</p>
<p>Cheers,<br />
Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jesse</title>
		<link>http://jessenoller.com/2007/08/17/safe-strings-for-security/comment-page-1/#comment-2572</link>
		<dc:creator>jesse</dc:creator>
		<pubDate>Thu, 23 Aug 2007 15:09:34 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/08/17/safe-strings-for-security/#comment-2572</guid>
		<description>Thanks - I did get that approach: I was questioning the usefulness of doing this in the compiler. Thank you for the example though</description>
		<content:encoded><![CDATA[<p>Thanks — I did get that approach: I was questioning the usefulness of doing this in the compiler. Thank you for the example though</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ants Aasma</title>
		<link>http://jessenoller.com/2007/08/17/safe-strings-for-security/comment-page-1/#comment-2571</link>
		<dc:creator>Ants Aasma</dc:creator>
		<pubDate>Thu, 23 Aug 2007 15:05:29 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/08/17/safe-strings-for-security/#comment-2571</guid>
		<description>I feel you didn&#039;t get the point of the type based approach. I think that cross-stite scripting bugs are not a case of mixing up unsafe and safe strings, its a case of type mismatch, like adding together feet and meters. So if you have a user supplied &lt;i&gt;string&lt;/i&gt; and you output it to a &lt;i&gt;html&lt;/i&gt; template you need to encode it as an HTML string literal (i.e. escape characters that have special meaning in HTML). You could also have an user supplied html&gt; language fragment (like this commenting systems allows) in which case you want to have a function that interprets the string as html, removes all the dangerous stuff and returns an html fragment. When you have detailed enough type information you have the ability not only to detect type mismatches, but to do type coercion. For the feet and meters example if you add two quantity objects you can do automatic unit conversion when they&#039;re of the same dimension and raise an Exception when, you&#039;re adding a quantity of time to a quantity of distance. For the html example when concatenating html and regular strings it is possible to automatically escape the strings.

I threw together a proof of concept implementation of that a few days ago. It&#039;s currently available at http://dpaste.com/17329/</description>
		<content:encoded><![CDATA[<p>I feel you didn’t get the point of the type based approach. I think that cross-stite scripting bugs are not a case of mixing up unsafe and safe strings, its a case of type mismatch, like adding together feet and meters. So if you have a user supplied <i>string</i> and you output it to a <i>html</i> template you need to encode it as an HTML string literal (i.e. escape characters that have special meaning in HTML). You could also have an user supplied html&gt; language fragment (like this commenting systems allows) in which case you want to have a function that interprets the string as html, removes all the dangerous stuff and returns an html fragment. When you have detailed enough type information you have the ability not only to detect type mismatches, but to do type coercion. For the feet and meters example if you add two quantity objects you can do automatic unit conversion when they’re of the same dimension and raise an Exception when, you’re adding a quantity of time to a quantity of distance. For the html example when concatenating html and regular strings it is possible to automatically escape the strings.</p>
<p>I threw together a proof of concept implementation of that a few days ago. It’s currently available at <a href="http://dpaste.com/17329/" rel="nofollow">http://dpaste.com/17329/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jesse</title>
		<link>http://jessenoller.com/2007/08/17/safe-strings-for-security/comment-page-1/#comment-2360</link>
		<dc:creator>jesse</dc:creator>
		<pubDate>Tue, 21 Aug 2007 02:15:19 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/08/17/safe-strings-for-security/#comment-2360</guid>
		<description>Good points, all of them. 

If you&#039;re going to go as far as to shackle a developer into the SafeString type you&#039;ve defined, you also have to block/deny any sort of object polymorphism as well - I can&#039;t see you able to enforce the compile-time rules without blocking the that as well.

It&#039;s food for thought - although when it comes to most applications, it&#039;s user-input or input-generated from an untrusted third party that most people/programmers concern themselves with. For example, it would be interesting to enforce these style rules within an DB ORM (both to and from)  and things such as networking/other communications layers. It&#039;s this type of hardening that only really exposes itself at runtime in most instances.

I&#039;m wondering about the scope of safety you&#039;re providing by baking in a new safe type into the language - you&#039;re only protecting a programmer from leveraging an unsafe string during code-compilation time. I think (opinion mind you) that your time would be better spent doing exactly what you pointed out as a flaw in my suggestion: designing ways to cope with these issues/attacks at runtime.

If you treat all data (strings) as untrusted data to begin with - both user and programmer generated alike and build into your system a clean/abstracted way of dealing with and capturing dangerous objects your application would be infinitely more secure without the need to enforce it at compiler-time.</description>
		<content:encoded><![CDATA[<p>Good points, all of them. </p>
<p>If you’re going to go as far as to shackle a developer into the SafeString type you’ve defined, you also have to block/deny any sort of object polymorphism as well — I can’t see you able to enforce the compile-time rules without blocking the that as well.</p>
<p>It’s food for thought — although when it comes to most applications, it’s user-input or input-generated from an untrusted third party that most people/programmers concern themselves with. For example, it would be interesting to enforce these style rules within an DB ORM (both to and from)  and things such as networking/other communications layers. It’s this type of hardening that only really exposes itself at runtime in most instances.</p>
<p>I’m wondering about the scope of safety you’re providing by baking in a new safe type into the language — you’re only protecting a programmer from leveraging an unsafe string during code-compilation time. I think (opinion mind you) that your time would be better spent doing exactly what you pointed out as a flaw in my suggestion: designing ways to cope with these issues/attacks at runtime.</p>
<p>If you treat all data (strings) as untrusted data to begin with — both user and programmer generated alike and build into your system a clean/abstracted way of dealing with and capturing dangerous objects your application would be infinitely more secure without the need to enforce it at compiler-time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Moertel</title>
		<link>http://jessenoller.com/2007/08/17/safe-strings-for-security/comment-page-1/#comment-2337</link>
		<dc:creator>Tom Moertel</dc:creator>
		<pubDate>Mon, 20 Aug 2007 20:35:01 +0000</pubDate>
		<guid isPermaLink="false">http://jessenoller.com/2007/08/17/safe-strings-for-security/#comment-2337</guid>
		<description>In response to your question, &quot;Do you really want a compiler to enforce social and domain-specific rules for you?&quot; the answer, as far as security assurances are concerned, is yes. 

While you can certainly implement a run-time system for detecting potentially unsafe string interactions, what sensible options do you have when you detect one?  Remember, what you have just detected is &lt;i&gt;not&lt;/i&gt; that an attacker tried to stuff some nasty code into a form; rather, you have detected a &lt;i&gt;programming error&lt;/i&gt;: the programmer used a string in one place as if it were, say, untrusted user input and in another as if it were, say, part of a trusted, programmer-supplied template.  It&#039;s just that until some user (maybe a bad guy but very possibly a good guy) manged to walk a particular path through your application that exercised both uses of the string, the programming error went undetected.

Now, however, your run-time system has detected it.  The problem is, your system detected it in a live-running application, at the site of a potential unsafe string interaction, &lt;i&gt;not&lt;/i&gt; at the error&#039;s origin in your code, which could be a long ways distant.  That is, this particular string interaction may very well not be the error.  The error may have been caused in the distant past by code that has already executed.  What&#039;s worse, all the code in between the error&#039;s origin and the present site of detection could have been causing side effects: writing to the database, updating session variables, launching the missiles, etc.  How do you safely undo all those effects?

That&#039;s the real problem.

In a compile-time system, when a potentially unsafe string interaction is detected, you have all the time in the world to hunt the problem down to its true source, wherever that may be, and fix it.

In sum, a compile-time system offers you the assurance that none of the checked-for problems can occur at run-time.  A run-time system can only guarantee that, if a checked-for problem occurs, it will be caught.  By then, however, it may already be too late to avoid the consequences.

Cheers. --Tom</description>
		<content:encoded><![CDATA[<p>In response to your question, “Do you really want a compiler to enforce social and domain-specific rules for you?” the answer, as far as security assurances are concerned, is yes. </p>
<p>While you can certainly implement a run-time system for detecting potentially unsafe string interactions, what sensible options do you have when you detect one?  Remember, what you have just detected is <i>not</i> that an attacker tried to stuff some nasty code into a form; rather, you have detected a <i>programming error</i>: the programmer used a string in one place as if it were, say, untrusted user input and in another as if it were, say, part of a trusted, programmer-supplied template.  It’s just that until some user (maybe a bad guy but very possibly a good guy) manged to walk a particular path through your application that exercised both uses of the string, the programming error went undetected.</p>
<p>Now, however, your run-time system has detected it.  The problem is, your system detected it in a live-running application, at the site of a potential unsafe string interaction, <i>not</i> at the error’s origin in your code, which could be a long ways distant.  That is, this particular string interaction may very well not be the error.  The error may have been caused in the distant past by code that has already executed.  What’s worse, all the code in between the error’s origin and the present site of detection could have been causing side effects: writing to the database, updating session variables, launching the missiles, etc.  How do you safely undo all those effects?</p>
<p>That’s the real problem.</p>
<p>In a compile-time system, when a potentially unsafe string interaction is detected, you have all the time in the world to hunt the problem down to its true source, wherever that may be, and fix it.</p>
<p>In sum, a compile-time system offers you the assurance that none of the checked-for problems can occur at run-time.  A run-time system can only guarantee that, if a checked-for problem occurs, it will be caught.  By then, however, it may already be too late to avoid the consequences.</p>
<p>Cheers. –Tom</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Object Caching 680/680 objects using disk: basic

Served from: jessenoller.com @ 2012-05-17 06:25:18 -->
