<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>HD DVD / Randomness... : WordBlogX</title><link>http://blogs.msdn.com/ptorr/archive/tags/WordBlogX/default.aspx</link><description>Tags: WordBlogX</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Code Repurposing</title><link>http://blogs.msdn.com/ptorr/archive/2003/10/16/56270.aspx</link><pubDate>Thu, 16 Oct 2003 11:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56270</guid><dc:creator>ptorr</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/ptorr/comments/56270.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ptorr/commentrss.aspx?PostID=56270</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ptorr/rsscomments.aspx?PostID=56270</wfw:comment><description>
&lt;p&gt;&lt;span&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;span&gt;[Ed: I've now posted a &lt;a
href="http://blogs.gotdotnet.com/ptorr/commentview.aspx/4304d0d3-ac52-41f6-8137-aac3d380f8cd"&gt;follow
up entry&lt;/a&gt; to this blog that talks about some strategies you can use to
mitigate the kinds of problems outlined in this blog entry]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;lt;sigh&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Code repurposing really blows.
And it sucks. It sucks and it blows. And not necessarily in that order!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This blog could be short, or it
could be long. It depends on how much I ramble and how many side-topics I need
to bring in to talk about this most heinous of concepts. Hope you can stay
along for the ride.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So what is code re-purposing? I
talked about it a bit in a &lt;a
href="http://blogs.gotdotnet.com/ptorr/commentview.aspx/9f6e31e8-937e-4328-b457-132360cd51ed"&gt;previous
blog&lt;/a&gt;, but I'm just going to brain-dump again so please forgive me if I
repeat myself. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Myself.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But before I start, I want to
talk a bit about the difference between &lt;b&gt;dangerous&lt;/b&gt;
code and &lt;b&gt;malicious&lt;/b&gt; code. Eric
touched on this subject in his blog &lt;a
href="http://blogs.gotdotnet.com/ericli/commentview.aspx/8dbf5993-77a1-4718-b562-7a8339a770d7"&gt;a
while ago&lt;/a&gt;, but in case you didn't read it or in case you're still not sure,
I'll start with a bit of a story. I'm doing this is so I can talk about the
difference between installing bad code, and having good code get repurposed
(something that a lot of really smart people don't understand).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;span&gt;[Ed: Word just crashed so I have to re-type this paragraph... argh!]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If I told you that the other
day I discovered some code on my machine that could erase all the files on my
computer and any network shares I have access to, you might be a bit alarmed.
If I told you that I also found some code that could send e-mails to all the
people in my Outlook contacts, you might start getting nervous. If &lt;a
href="http://blogs.gotdotnet.com/ptorr/commentview.aspx/4fc434fe-9295-496e-a528-9042b8f577bd"&gt;Mr.
Paranoid&lt;/a&gt; can't even keep his machine virus-free, then how can the rest of
the world? Run to the hills!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Well... someone just jumped to
a conclusion :-). I never said I had a virus; I said I had software that could
delete files (it's called the &lt;st1:place w:st="on"&gt;&lt;st1:State w:st="on"&gt;&lt;b&gt;DEL&lt;/b&gt;&lt;/st1:State&gt;&lt;/st1:place&gt; command),
and I said I had software that could send e-mail (it's called &lt;b&gt;Outlook&lt;/b&gt;). The &lt;st1:State w:st="on"&gt;&lt;st1:place
 w:st="on"&gt;&lt;b&gt;DEL&lt;/b&gt;&lt;/st1:place&gt;&lt;/st1:State&gt;
command is pretty dangerous -- it deletes data! -- but its operation is well
documented and only trusted entities can use it to delete files. It's not
malicious. Same for all recent versions of Outlook -- it can send mail, but
only when I want it to.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;Installing vs Repurposing&lt;/h3&gt;
&lt;p&gt;&lt;span&gt;At work when we're talking
about security problems, we often invoke a mythical &lt;b&gt;ACTIVEX&lt;/b&gt; &lt;b&gt;CONTROL OF ULTIMATE DESTRUCTION&lt;/b&gt;,
a control that will proceed to format the user's hard drive as soon as it is
initialised.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This control is talked about in
two different contexts:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;![if !supportLists]&gt;&lt;span&gt;&lt;span&gt;1)&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;![endif]&gt;&lt;span&gt;The &lt;b&gt;ACOUD&lt;/b&gt; is not installed on my machine,
but I visit a web site or open a document that attempts to download the control
for malicious purposes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;![if !supportLists]&gt;&lt;span&gt;&lt;span&gt;2)&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;![endif]&gt;&lt;span&gt;The &lt;b&gt;ACOUD&lt;/b&gt; is installed on my machine and I
visit a web site or open a document that attempts to invoke the control for
malicious purposes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There is a significant
difference between these two scenarios, although quite often I have to expend
large amounts of time and effort trying to explain this difference to people to
show why they do (or do not) have a security problem with their designs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In the first case, we assume
that the control is 100% pure evil and has been developed by a hax0r. The
purpose of the control is to be downloaded to your machine and do as much
damage as possible as quickly as possible. When you visit the web page, the
browser attempts to download the control, and one of three things can happen:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;![if !supportLists]&gt;&lt;span&gt;&lt;span&gt;i.&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;![endif]&gt;&lt;span&gt;The control is
blocked by your security settings&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;![if !supportLists]&gt;&lt;span&gt;&lt;span&gt;ii.&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;![endif]&gt;&lt;span&gt;You are prompted
to download the control&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;![if !supportLists]&gt;&lt;span&gt;&lt;span&gt;iii.&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;![endif]&gt;&lt;span&gt;The control
installs without prompts&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The first one is most likely to
occur if the code is unsigned -- it's the default behaviour of IE -- and it's A
Good Thing. It will also happen if you browse the net in &amp;quot;High&amp;quot;
security mode, or if you are not running as an Administrator. In this case you
are safe from the ACOUD because it will never be installed and hence it can
never do its dirty work.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The second one is likely to
occur if the control is signed (remember, &lt;a
href="http://securityresponse.symantec.com/avcenter/venc/data/friendgreetings.html"&gt;the
bad guys can get certificates, too&lt;/a&gt;!) or if you have lowered your security
settings to allow unsigned controls to be downloaded with a prompt (not a good
idea!). In this case, you are prompted for your permission / consent to
download and install the control. If the browser can determine any interesting
security properties about the control (ie, its signature) then it will show you
this information; otherwise it will just kind of shrug its shoulders and go
&amp;quot;eh?&amp;quot; at you. Now if you decide to install and run the ACOUD, &lt;b&gt;then&lt;/b&gt; &lt;b&gt;it's your own fault&lt;/b&gt;! Yes, that's right! You and you alone are
responsible for deciding whether or not to install code on your computer. If
you make a bad trust decision (trusting unsigned code, or code from an
untrustworthy publisher, or code from someone you've never heard of like
&amp;quot;Permissioned Media&amp;quot;) then there's nothing Windows (or any other OS,
for that matter) can do to protect you.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Aside: It's quite funny in a
sad kind of way how all the &lt;a href="http://www.slashdot.org/"&gt;ABMers&lt;/a&gt; (&lt;b&gt;A&lt;/b&gt;nything &lt;b&gt;B&lt;/b&gt;ut &lt;b&gt;M&lt;/b&gt;icrosoft) think
that the point of Palladium (aka &lt;b&gt;NGSC&lt;/b&gt;,
&lt;b&gt;&lt;a
href="http://www.microsoft.com/resources/ngscb/default.mspx"&gt;N&lt;span&gt;ext &lt;/span&gt;G&lt;span&gt;eneration
&lt;/span&gt;S&lt;span&gt;ecure &lt;/span&gt;C&lt;span&gt;omputing &lt;/span&gt;B&lt;span&gt;ase&lt;/span&gt;&lt;/a&gt;&lt;/b&gt;)
is to &lt;b&gt;control what software people
install on their machines&lt;/b&gt;. They think it's some nefarious plot to stop them
installing &lt;a href="http://www.kernel.org/"&gt;Linux&lt;/a&gt; or &lt;a
href="http://www.mozilla.org/"&gt;Mozilla&lt;/a&gt; or &lt;a
href="http://www.openoffice.org/"&gt;OpenOffice.org&lt;/a&gt; or whatever on their PCs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;span&gt;[Ed: Oh dear, he just provided links to competitors' sites.
He'll probably get fired tomorrow!!!]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Boy would I sleep well at
night if I knew people couldn't install bad software on their PCs. No more
viruses or buggy user-written code to worry about! Of course I'd also be out of
a job, because a PC is useless if you can't install arbitrary code on it. Of
course the public just likes to talk about the OS, a browser, and a
productivity suite (usually in the context of &lt;a
href="http://www.microsoft.com/windows/default.mspx"&gt;Windows&lt;/a&gt; / &lt;a
href="http://www.microsoft.com/windows/ie/default.asp"&gt;Internet Explorer&lt;/a&gt; / &lt;a
href="http://www.microsoft.com/office/"&gt;Microsoft Office&lt;/a&gt; vs. Linux / Mozilla
/ OpenOffice) but any given corporation could have tens or hundreds or even &lt;b&gt;hundreds of thousands&lt;/b&gt; (no, that's not a
typo) of custom applications that they need to run their business on every day.
And if they couldn't install or use those applications, they would never move
to the next version of Windows, which would mean I'd be out on my ear and
deported back to &lt;st1:country-region w:st="on"&gt;&lt;st1:place w:st="on"&gt;Australia&lt;/st1:place&gt;&lt;/st1:country-region&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Sure, we could definitely make
the experience much better than the dog-ugly and confusing AuthentiCode dialog
we have today, and it's something we really need to work on in the future, but
at the end of the day the user has to take on some responsibility. Driving a dump
truck into a bank vault and then telling the police &amp;quot;I didn't know how to
use the brakes!&amp;quot; doesn't work very well (go on, prove me wrong!), so installing
malicious software and claiming &amp;quot;I didn't know how to stop myself from doing
it!&amp;quot; shouldn't work well either. (I'm deliberately being harsh here -- I
really do believe we must do a better job of helping users make informed
decisions when it comes to their computer use -- but the fundamental problem
remains: if people want to take actions of questionable merit and / or don't
want to take the time to understand even the basics of computer security,
there's not much we can do to help them).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Anyway, back to the story. If
you tell IE to install the ACOUD then you are toast, plain and simple, and it's
not our fault. Time to &lt;a
href="http://www.cert.org/tech_tips/root_compromise.html"&gt;reformat your machine&lt;/a&gt;
(oh wait, the control already did that for you -- how helpful!) and start
again.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And of course if the third one
happens, it's just like second one except you were saved the inconvenience of
clicking &amp;quot;Yes&amp;quot; :-).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So in this case, the problem is
&lt;b&gt;getting the control on the user's
machine&lt;/b&gt;. If the bad guy can trick the user into installing the bad code, or
they can trick the computer into installing it automatically, they've already
won. What we try to do with our product designs is of course make it impossible
for the attacker to do this without the user being made aware of the possible
consequences. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So far, so good.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;span&gt;[Ed: I just had a really bad espresso experience -- note &lt;b&gt;there is no &amp;quot;x&amp;quot; in
&amp;quot;espresso&amp;quot;&lt;/b&gt;! Although I have a &lt;a
href="http://wholelattelove.com/packages/expobar_mazzer.htm"&gt;pretty decent coffee
machine&lt;/a&gt;, I just switched beans and so the grind wasn't right. Grrrr]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Now the second big scenario I
mentioned was when the ACOUD is already installed on your machine. In this
scenario, we assume that the ACOUD is actually a well-designed piece of software
that you installed and perhaps regularly use. This might sound shocking, but
remember the example of the &lt;st1:State w:st="on"&gt;&lt;st1:place w:st="on"&gt;&lt;b&gt;DEL&lt;/b&gt;&lt;/st1:place&gt;&lt;/st1:State&gt; command.
I as a user may have a common requirement of formatting hard drives (especially
if I'm in a tech support role at a large company) and in order to make my job
easier, I may have written a tool that automatically formats drives without any
kind of prompting or warnings, because only I should be able to access the
tool, and I presumably know what I'm doing. It's actually &lt;b&gt;VERY HARD&lt;/b&gt; to convince people -- even really smart people -- that
the ACOUD is a legitimate piece of software in this instance. It intuitively
seems to go against everything we know about security. &amp;quot;You mean as soon
as I call into this control it formats my hard drive? Without prompting?!? How
can that be a good idea?!?&amp;quot; But trust me, there's nothing wrong with such
a control if it is &lt;b&gt;properly designed and
protected&lt;/b&gt;. (This also applies in the case where you have some &lt;a
href="http://www.eeye.com/html/Research/Advisories/AD20020502.html"&gt;slightly
less risky control that just happens to have an exploitable bug in its
initialisation routines&lt;/a&gt;, but again the absolute coolness of the ACOUD
trumps such a boring example in this case).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So anyway, we have the ACOUD
sitting on our machine, and now the attack we are worried about is a web page
or Office document that somehow manages to create and initialise an instance of
that control &lt;b&gt;without our consent&lt;/b&gt;.
Holy whack exploitable software, Batman. We've got a problem. This is where the
&lt;a
href="http://msdn.microsoft.com/library/default.asp?url=/workshop/components/activex/safety.asp"&gt;Safe
for Initialization&lt;/a&gt; (SFI) attribute is used by Internet Explorer -- by
default it will not try and initialise controls with data embedded in the web
page because, in general, controls are not very good at protecting themselves
against malicious input (overly large values that cause buffer overruns,
spoofed URLs that accept leaked information, etc). So unless a control says
&amp;quot;Yep, it's OK to feed me random garbage!&amp;quot; IE will not initialise a
control with untrusted data. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In this case, the problem is &lt;b&gt;allowing unauthorised agents to access more-privileged
software in unexpected and dangerous ways&lt;/b&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If we design software that
somehow fails to honour the semantics of SFI then we are in deep, deep trouble.
And this is very hard to explain to someone -- &lt;/span&gt;yes &lt;span&gt;the user installed the ACOUD, but it doesn't pose a
security problem until &lt;b&gt;YOUR CODE&lt;/b&gt;
decides to activate it on behalf of &lt;a
href="http://www.hackmeplease_noreallyimbeggingyou.com/"&gt;www.hackmeplease_noreallyimbeggingyou.com&lt;/a&gt;.
Eventually the point is made, often via analogies with knives, scissors, axes,
teddy bears (yes, teddy bears) and other real-world objects, but it takes a
tremendous amount of effort. Which is one of the reasons why I'm writing this.&lt;/span&gt;&lt;span
lang=EN-US&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Another aside -- I initially
tried searching for &lt;a
href="http://www.google.com/search?hl=en&amp;amp;ie=UTF-8&amp;amp;oe=UTF-8&amp;amp;q=site%3Amicrosoft.com+safe+for+initialisation"&gt;Safe
for Initialisation&lt;/a&gt; (the &lt;b&gt;correct&lt;/b&gt; spelling)
and ended up with a bunch of links to research papers, presumably written by
people in Microsoft &lt;st1:place w:st="on"&gt;&lt;st1:country-region w:st="on"&gt;UK&lt;/st1:country-region&gt;&lt;/st1:place&gt;
:-). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So there is a big difference
between a hacker installing malicious code of their own design, and a hacker
coopting otherwise benign software for evil doings of their own design. In once
case we throw up our hands and say &amp;quot;the user made a bad trust
decision!&amp;quot; and there's really nothing else we can do (other than provide
additional mitigations via a defence-in-depth strategy), and in the other case
we throw up our hands and say &amp;quot;Ouch, we gotta fix that before we
ship!&amp;quot; (and also consider other mitigations as part of a defence-in-depth
strategy). For some reason I've started writing &amp;quot;defence&amp;quot; as
&amp;quot;defense&amp;quot;; I don't know why. I wish I would stop doing it, but at
least Word corrects it for me so I don't look silly when this finally goes up
on the web.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;span&gt;[Ed: Don't kid yourself -- you DO look silly]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Anyway, since I've rambled
about random stuff for quite some time now, it only seems fair that I should ramble
some more. Here's a common thread that you might have found on one of the
Microsoft scripting newsgroups a few years ago:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span&gt;FrustratedDev&lt;/span&gt;&lt;/b&gt;&lt;span&gt;: I built a cool
ActiveX control for my company, but it won't load in the browser. I keep
getting security errors. Help!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span&gt;HelpfulPoster1&lt;/span&gt;&lt;/b&gt;&lt;span&gt;:
Just lower your security settings and it will work!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span&gt;Me&lt;/span&gt;&lt;/b&gt;&lt;span&gt;: Nooooo,
don't do that! You'll open yourself up to malicious code in the future.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span&gt;HelpfulPoster2&lt;/span&gt;&lt;/b&gt;&lt;span&gt;:
Just sign your control with a certificate!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span&gt;Me&lt;/span&gt;&lt;/b&gt;&lt;span&gt;: Nooooo,
don't do that! Signatures have nothing to do with whether a control will load
in IE or not; it determines whether the control can be downloaded and installed
or not&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span&gt;HelpfulPoster3&lt;/span&gt;&lt;/b&gt;&lt;span&gt;:
Just mark it &amp;quot;Safe for Scripting&amp;quot;!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;span&gt;Me&lt;/span&gt;&lt;/b&gt;&lt;span&gt;: Nooooo,
don't do that! Your code almost certainly isn't safe for untrusted callers.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The point being, well.... I
forget now. But the moral of the story is don't sign ActiveX controls or mark
them as Safe for Scripting unless you really REALLY need to enable arbitrary
users to download your code and have it run against arbitrary web pages. And unless
you're &lt;a
href="http://www.microsoft.com/windows/windowsmedia/download/default.asp"&gt;Microsoft&lt;/a&gt;
or &lt;a
href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"&gt;Macromedia&lt;/a&gt;
or &lt;a href="http://www.apple.com/quicktime/download/"&gt;Apple&lt;/a&gt; or a similar
type of company trying to reach millions of desktops across the world, and you
have the resources and expertise to thoroughly review your code for security
vulnerabilities that probably means &amp;quot;not you&amp;quot;. (And even if it is
you, you probably missed a bug or two along the way). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In case you care, more info on
building secure ActiveX controls can be found &lt;a
href="http://msdn.microsoft.com/library/default.asp?url=/workshop/components/activex/safety.asp"&gt;here&lt;/a&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;Get to the point already!!!&lt;/h3&gt;
&lt;p&gt;&lt;i&gt;&lt;span&gt;[Ed: Yeah, you rambling fool! Get to the point!]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;OK, so something about
repurposing ActiveX controls. Let's start with an example. A rather extreme example
that is used quite often internally here in our team at Microsoft to get across
the general idea of the badness of repurposing.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Let's say that OTG (our
internal IT department) builds a &amp;quot;Format your Drive&amp;quot; web page, using
a signed control that is marked &amp;quot;Safe for Scripting&amp;quot; (so that it
loads without any errors). When you go to the Helpdesk web site and click on
the &amp;quot;I need to format my drive&amp;quot; link, it downloads the helpful web
page for you. The document has some informational text about what formatting
means, why it is a dangerous thing to do, and so on. It also contains two buttons
labelled &amp;quot;Yes&amp;quot; and &amp;quot;No&amp;quot;, and it links to the code that does
the actual formatting. The code is signed with the internal corporate
signature, so all users at Microsoft implicitly trust it. When the user clicks
the &amp;quot;Yes&amp;quot; button, it calls into the code to format the drive, which
is perfectly acceptable and the right thing to do, since the user has been made
aware of the consequences and has made an informed decisions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The problem is that some pesky
trickster creates a copy of the web page and replaces all the text about hard
drive formatting with some text about downloading pictures of famous
celebrities in various stages of undress. They maintain a link to the original
formatting ActiveX control (which, remember, is signed and trusted), and send a
link to the page around to all the people in their team. An unsuspecting user or
three hundred decides to open the link and click the &amp;quot;Yes&amp;quot; button, in
eager anticipation of seeing Margaret Thatcher in her winter underwear. (My
apologies to those readers who just passed out). This of course invokes the
original &lt;b&gt;FormatDrive()&lt;/b&gt; function in
the trusted control, and the user is toast. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;A more subtle (but perhaps more
realistic) scenario is where a less obviously dangerous piece of code gets
repurposed from another document that is expected to contain code. For example,
let's say that the IT department builds a new kind of budget forecasting web
page that links to custom ActiveX control to implement certain functions
similar to an Excel workbook. Let's also say that the HR department has built a
web page (using another control) that enables users to balance their benefits
(for the non-US people: that means your non-salary compensation, such as a
medical plan, gym / health club membership, life insurance, etc.). And let's
also assume that the HR control takes the URL of the web server it should
contact as a parameter to the &amp;lt;object&amp;gt; tag in the HTML document.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Now assume that malicious user
Bob wants to know how much money Alice earns, so he modifies a copy of the HR web
page so it looks like the budget web page (by formatting so that it looks like
a budget spreadsheet) but he updates the &amp;lt;PARAM&amp;gt; tag to point to his own
web server and sends the document to Alice with a note saying &amp;quot;Please check
these estimates and get back to me&amp;quot;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Now we see the problem. &lt;st1:place
w:st="on"&gt;&lt;st1:City w:st="on"&gt;Alice&lt;/st1:City&gt;&lt;/st1:place&gt; opens the web page,
and instead of the Budget code being executed, the HR code starts executing and
uploads her personal information -- salary, stock options, health coverage,
etc. -- to the web server that Bob controls. Remember the HR code is already
signed and trusted; this is not a malicious code injection attack, but a
repurposing attack. Even assuming that &lt;st1:City w:st="on"&gt;&lt;st1:place w:st="on"&gt;Alice&lt;/st1:place&gt;&lt;/st1:City&gt;'s
machine was setup to prompt before executing code, she &lt;b&gt;expects&lt;/b&gt; the budget web page to execute code and so will most likely
consent to the request, even though it's executing &lt;b&gt;the wrong code&lt;/b&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I'm sure you can imagine other
scenarios. The possibilities are endless! :-)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;span&gt;[Ed: I think that should be &amp;quot;:-(&amp;quot;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As I explained in my &lt;a
href="http://blogs.gotdotnet.com/ptorr/commentview.aspx/9f6e31e8-937e-4328-b457-132360cd51ed"&gt;previous
blog entry&lt;/a&gt;, insofar as VSTO goes we try somewhat to stop this attack from &lt;a
href="http://msdn.microsoft.com/library/en-us/dv_wrcore/html/wrconDeployingSecurely.asp?frame=true"&gt;e-mail
attachments and random web sites&lt;/a&gt;, but it doesn't help if users &lt;a
href="http://msdn.microsoft.com/library/en-us/dv_wrcore/html/wrconWhiteRabbitSecurityModels.asp?frame=true"&gt;copy
documents to their desktop or start publishing such malicious documents to
trusted internal web sites&lt;/a&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And now you know why all my
blogs are posted past &lt;st1:mswterms Hour="0" Minute="00" w:st="on"&gt;midnight&lt;/st1:mswterms&gt;
-- I can't sleep with all these nightmares about code repurposing going on in
my head!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;One last thing for the evening
-- a real life tale of a security bug that could have been... in my very own
WordBlogX!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The current version of WordBlogX
on &lt;a
href="http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=50759CA7-6668-425A-B730-47E9B52B4EDB"&gt;GotDotNet&lt;/a&gt;
is pretty bad, mostly because it is lacking useful features. One feature I've
already added in the build on my machine is the ability to put the URL of the
blog server in a config file, thereby enabling people to post blogs to servers
other than GotDotNet without recompiling the source code. Another feature I
really want to add (but haven't done so yet) is a &amp;quot;remember my
password&amp;quot; feature that &lt;a
href="http://msdn.microsoft.com/library/en-us/security/security/credwrite.asp?frame=true"&gt;securely
stores my credentials&lt;/a&gt; on the local machine so I don't have to type them in
every time I make a post. I'm going to implement this feature RSN (&lt;b&gt;R&lt;/b&gt;eal &lt;b&gt;S&lt;/b&gt;oon &lt;b&gt;N&lt;/b&gt;ow; often used
sarcastically to mean &amp;quot;never&amp;quot; but in this case I really do hope to do
it soon!). &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can anyone see the problem with
this design? Anyone? &lt;a href="http://www.imdb.com/title/tt0091042/"&gt;Beuller&lt;/a&gt;?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The problem is that anyone who
gets a copy of the assembly can put it on a server of their control, modify the
config file to point to a web server of under their control, send an arbitrary
document that links to this code to anyone who uses WordBlogX, and then wait
for the cached passwords to flow in. The attacker simply needs to have a button
on their document with the programmatic name of &lt;b&gt;cmdPost&lt;/b&gt;&lt;/span&gt; and somehow socially engineer the user into clicking
it (&amp;quot;Free life-time supply of dental floss -- click here now!&amp;quot;).&lt;span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;span&gt;[Ed: Note that the root badness here is trusting the URL in the config
file; sending usernames and passwords is just a bad side-effect that drives the
point home]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is this a bad design? Yes, it
is.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Would the average developer,
faced with similar requirements, come up with the same design? Quite probably.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Would this same developer
threat model their code and try to mitigate against this attack? I don't think
so.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Luckily for me I have the
assembly for WordBlogX &amp;quot;installed&amp;quot; in a particular directory on my
system, and it will only ever try to load the configuration file from that
directory. The assembly is not signed and I do not trust it to load from any
other locations (eg, malicious web sites), so I should be safe from this kind
of attack for the time being (as should anyone else who installs WordBlogX in
the future). But if I was the IT department in a large corporation, I'd
probably just sign the code with the corporate certificate, and the code would
be trusted from any location inside the LocalIntranet Zone (or perhaps on a
server where malicious users have some degree of write access), in which case
it wouldn't be long before the code was exploited.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I will probably add a
confirmation dialog box to WordBlogX that displays the remote URL before retrieving
credentials or sending any information to the server just to make sure, but
this will no doubt annoy &lt;a href="http://blogs.gotdotnet.com/robmen/"&gt;some users&lt;/a&gt;
and they will turn off the confirmation. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(A lot of people downplay the
likelihood or severity of internal attacks because, well, you only ever hear
about high-profile public attacks in the news. But don't kid yourself --
attacks from people &lt;b&gt;inside&lt;/b&gt; the
firewall are much more common and much more likely to cost you big money than attacks
from faceless hackers sitting half way across the world).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thus ends tonight's effort.
It's been long and random, and I probably scared the willies out of some
people, but that's the way life is.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;P.S. I managed to talk about
teddy bears in the context of security when talking to a fellow PM about
trusting the &amp;quot;Safe for Scripting&amp;quot; flag on controls. His argument was
that SFS buys you nothing because hackers will always just set that bit and so
therefore you are hosed when the control loads in IE. This is a concrete
example of failing to understand the differences between installing malicious
code and repurposing trusted code, as I tried to outline in the ACOUD example.
Anyway, we had been talking about knives and how he wouldn't trust his young
child with a big kitchen knife, so in a moment of desperation I came up with
&amp;quot;The Teddy Bear Defence&amp;quot;. When you buy a teddy bear from the shop, it
comes with a safety tag that says &amp;quot;suitable for children 3 years and
older&amp;quot; or something similar. As part of the purchasing act, you
(implicitly) trust that the manufacturer is not lying about the toy being
suitable for anyone 3 years of age or older. If the toy was manufactured by an
evil company, all bets are off as to whether it is even safe for ANYONE to have
the teddy bear, no matter what their age -- maybe it spontaneously combusts on
the third Sunday of the month. In this case you made a bad purchasing / trust
decision. But if the toy was manufactured by a responsible company, you can use
the information printed on the warning label to deduce that it is OK to give the
teddy bear to your 5-year-old but not your 2-year-old. And there you have it.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;span&gt;[Ed: This guy is ccccrrrraaaaaaaazzzzzyyyy!]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;P.P.S. Who's this
&amp;quot;Ed&amp;quot; fellow, and why does he keep popping up in my blog?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;&lt;span&gt;[Ed: Mmmmmuahahahahahaaaaa.......!!!!!]&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=56270" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ptorr/archive/tags/Security/default.aspx">Security</category><category domain="http://blogs.msdn.com/ptorr/archive/tags/Office/default.aspx">Office</category><category domain="http://blogs.msdn.com/ptorr/archive/tags/WordBlogX/default.aspx">WordBlogX</category><category domain="http://blogs.msdn.com/ptorr/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>WordBlogX 1.1 Coming Along Nicely...</title><link>http://blogs.msdn.com/ptorr/archive/2003/10/14/56267.aspx</link><pubDate>Tue, 14 Oct 2003 08:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56267</guid><dc:creator>ptorr</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/ptorr/comments/56267.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ptorr/commentrss.aspx?PostID=56267</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ptorr/rsscomments.aspx?PostID=56267</wfw:comment><description>
&lt;p&gt;&lt;span&gt;&lt;a
href="http://blogs.gotdotnet.com/robmen/"&gt;Rob&lt;/a&gt; and I are both working on
WordBlogX tonight. We've got the WordML -&amp;gt; HTML conversion working (needed
to update the namespace declarations from Beta 2 to RTM) and now Rob is
finishing up some Regex hacks to strip the unneeded document elements (&lt;b&gt;&amp;lt;HEAD&amp;gt;&lt;/b&gt;, etc) and to map the
classnames to inline styles (since we don't own the header any more...)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I've
been working on lots of stuff like being able to read blog URLs out of a
configuration file, invoking the &amp;quot;Save As&amp;quot; dialog using a default
filename based off the blog title or created date (based on a config file
setting), some debug forms and a confirmation dialog. I'm about to also add a
&amp;quot;Remember my Password&amp;quot; option, using DPAPI to store the encrypted
password in the registry.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This
entry is still using the hacky copy-to-clipboard HTML conversion because Rob
hasn't checked in his changes yet... but it will be coming soon to a browser
window near you!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=56267" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ptorr/archive/tags/WordBlogX/default.aspx">WordBlogX</category></item><item><title>Updating WordBlogX</title><link>http://blogs.msdn.com/ptorr/archive/2003/10/11/56260.aspx</link><pubDate>Sun, 12 Oct 2003 04:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56260</guid><dc:creator>ptorr</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/ptorr/comments/56260.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ptorr/commentrss.aspx?PostID=56260</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ptorr/rsscomments.aspx?PostID=56260</wfw:comment><description>
&lt;p&gt;&lt;span&gt;I've spent much of this
afternoon playing around with the WordBlogX code, adding a few simple features,
cleaning up the code a lot, and modularising everything.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I keep telling &lt;a
href="http://blogs.gotdotnet.com/robmen/"&gt;Rob&lt;/a&gt; that I feel like I'm
over-engineering everything, but as they say &amp;quot;if it's worth doing, it's
worth doing properly.&amp;quot;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Oh well.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;We actually have it under
source control now. Once I've finished with this cleanup then either Rob or I
will add the code to do the correct WordML --&amp;gt; HTML transform and enable
some richer formatting options, Rob will finalise his setup routines, and then
we'll re-post it to &lt;a href="http://www.gotdotnet.com/"&gt;GotDotNet&lt;/a&gt; in a much
more usable fashion. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then we'll add support for
the configuration files and other such stuff. We may need to setup our own
BlogX test server before too long ;-)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As Rob asked me before,
&amp;quot;Why are you a PM again?&amp;quot; referring to the fact that I like to code,
and PMs (&lt;a href="http://www.microsoft.com/college/fulltime/pm.asp"&gt;Program
Managers&lt;/a&gt;) typically don't write code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span&gt;Oh well. Again.&lt;/span&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=56260" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ptorr/archive/tags/WordBlogX/default.aspx">WordBlogX</category></item><item><title>Two geeks coding</title><link>http://blogs.msdn.com/ptorr/archive/2003/09/30/56236.aspx</link><pubDate>Tue, 30 Sep 2003 11:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56236</guid><dc:creator>ptorr</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/ptorr/comments/56236.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ptorr/commentrss.aspx?PostID=56236</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ptorr/rsscomments.aspx?PostID=56236</wfw:comment><description>
&lt;p&gt;It's Monday night. You come home from work. What do you do?
Sit in the lounge and code, of course! &lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.gotdotnet.com/robmen/"&gt;Rob&lt;/a&gt; is
working on &amp;quot;fixing&amp;quot; (ha) &lt;a
href="http://www.gotdotnet.com/Community/UserSamples/Details.aspx?SampleGuid=50759CA7-6668-425A-B730-47E9B52B4EDB"&gt;WordBlogX&lt;/a&gt;
and actually writing a &amp;quot;real&amp;quot; setup program for it (he can't help
himself, you see. It's a sickness). &lt;/p&gt;
&lt;p&gt;I'm playing around with &lt;a
href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecrypt/html/ceconCryptography.asp"&gt;CryptoAPI
on PocketPC&lt;/a&gt; which is really messy because there's no managed library for it
(&lt;a
href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritycryptography.asp"&gt;System.Security.Cryptography&lt;/a&gt;
was one of the things cut from Compact Framework) and the C++ header files
declare everything as &lt;b&gt;DWORD&lt;/b&gt; when
some are really &lt;b&gt;int&lt;/b&gt;s and some are &lt;b&gt;uint&lt;/b&gt;s... I had to get a mapping file
from someone else here at Microsoft that had the correct &lt;b&gt;DllImport&lt;/b&gt; declarations.&lt;/p&gt;
&lt;p&gt;Rob keeps making these horrible groaning sounds and then
asking me &amp;quot;Where did &amp;lt;insert random variable name&amp;gt; come from?&amp;quot;
and I have to explain about UI in Office docs, or what the codespit for VSTO
does (which is quite complicated and maybe I'll get around to talking about
that a bit one day...).&lt;/p&gt;
&lt;p&gt;And I keep swearing at CryptoAPI or VS (which pegged the CPU
at 100% with a &amp;quot;Property Window&amp;quot; modal dialog, so I had to kill the
process). And now it's late again... hopefully I'll have write an entry soon
that will describe why I'm futzing around with crypto on the PocketPC. Stay
tuned.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://c895fm.com/"&gt;C89.5&lt;/a&gt; played two &lt;a
href="http://petshopboys.co.uk/"&gt;Pet Shop Boys&lt;/a&gt; (requires Flash) songs this
evening - wow, I'm impressed. One was a recent track from &lt;a
href="http://www.amazon.com/exec/obidos/ASIN/B000084TSF/"&gt;Disco 3&lt;/a&gt; named &lt;a
href="http://www.amazon.com/exec/obidos/clipserve/B000084TSF001003/0/002-6078767-6533614"&gt;Try
it (I'm in love with a married man)&lt;/a&gt; (no, not personally; that's the name of
the track) and the other one was an (IMHO) less-than-optimal remix of an
otherwise really good early 80s track, &lt;a
href="http://www.amazon.com/exec/obidos/clipserve/B000002UZ4001003/0/002-6078767-6533614"&gt;Opportunities
(Let's make lots of money)&lt;/a&gt; from their debut &lt;a
href="http://www.amazon.com/exec/obidos/tg/detail/-/B000002U9K/ref=m_art_li_7/002-6078767-6533614?v=glance&amp;amp;s=music"&gt;Please&lt;/a&gt;
(also on &lt;a
href="http://www.amazon.com/exec/obidos/tg/detail/-/B000002UZ4/ref=m_art_li_1/002-6078767-6533614?v=glance&amp;amp;s=music"&gt;Discography:
The Complete Singles Collection&lt;/a&gt;). The remix was the one from &lt;a
href="http://www.amazon.com/exec/obidos/tg/detail/-/B000002UB8/ref=m_art_li_4/002-6078767-6533614?v=glance&amp;amp;s=music"&gt;Disco&lt;/a&gt;,
which is a pretty cool album if you remember it came out in the mid-80s, but I
just don't like the &lt;a
href="http://www.amazon.com/exec/obidos/clipserve/B000002UB8001003/0/002-6078767-6533614"&gt;remix
of Opportunities&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;BTW, did you know that PSB (which many people consider
&amp;quot;one hit wonders&amp;quot;) have actually had 33 top-20 hits in the &lt;st1:place
w:st="on"&gt;&lt;st1:country-region w:st="on"&gt;UK&lt;/st1:country-region&gt;&lt;/st1:place&gt;? &lt;/p&gt;
&lt;p&gt;Anyway, I was just happy they played one tune... but two?!? And
browsing to the PSB site, I just found out a new compilation album is due out
in a few weeks. Where would I be without blog writing?!? &lt;/p&gt;
&lt;p&gt;Anyway, one thing I have to do is answer my own little
question from a few days ago about why we don't install the &lt;b&gt;OfficeDocumentMembershipCondition&lt;/b&gt; in
the GAC by default. It was only meant as a joke question (since there's really
no way anyone could have known the answer), but seems at least one person (you
know who you are &amp;lt;g&amp;gt;) actually tried to find the answer, and they'll go
batty if I don't spill the beans.&lt;/p&gt;
&lt;p&gt;Soooo... the reason we don't install it into the GAC is
because we would not be able to reliably uninstall it. The reason we can't
reliably uninstall it is because if it is used in policy, then removing it
would break all managed code on the machine.&lt;/p&gt;
&lt;p&gt;Yup. All managed code.&lt;/p&gt;
&lt;p&gt;The reason for this is that the CLR needs to instantiate all
the objects used by policy (such as &lt;a
href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritypolicyzonemembershipconditionclasstopic.asp"&gt;ZoneMembershipCondition&lt;/a&gt;
or &lt;a
href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritypolicyzonemembershipconditionclasstopic.asp"&gt;UrlMembershipCondition&lt;/a&gt;
objects) in order to resolve the permissions for assemblies. If it can't create
any one of these objects, it has to fail to load any assemblies because (in
theory) the object that is failing to load could be &lt;b&gt;denying&lt;/b&gt; permissions to an assembly. So it fails to load anything...
including the code that is supposed to manages policy itself! You can't even
display the policy hierarchy using &lt;b&gt;&lt;a
href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrfcodeaccesssecuritypolicyutilitycaspolexe.asp"&gt;caspol
-lg&lt;/a&gt;&lt;/b&gt; if you have references to objects in policy that don't exist in the
&lt;a
href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconglobalassemblycache.asp"&gt;GAC&lt;/a&gt;.
Luckily you can still reset policy with &lt;b&gt;caspol
-all -rs&lt;/b&gt;, but that's a bit drastic.&lt;/p&gt;
&lt;p&gt;So we don't install because we can't uninstall. Maybe we
could have been tricky in our uninstall and checked if you used the condition
in any policies, but then we'd have to check across all users, and what if you
were using the object at runtime (ie, not in persistent policy, but at the &lt;a
href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemappdomainclasstopic.asp"&gt;AppDomain
level&lt;/a&gt;)? Who knows.&lt;/p&gt;
&lt;p&gt;I think that's it for now. &lt;/p&gt;
&lt;p&gt;Sorry for all the PSB gushing; &lt;a
href="http://www.amazon.com/exec/obidos/tg/detail/-/B000002TYI/ref=m_art_li_10/002-6078767-6533614?v=glance&amp;amp;s=music"&gt;I
Get Excited&lt;/a&gt; (grrr no sound sample).&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=56236" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ptorr/archive/tags/Office/default.aspx">Office</category><category domain="http://blogs.msdn.com/ptorr/archive/tags/Randomness/default.aspx">Randomness</category><category domain="http://blogs.msdn.com/ptorr/archive/tags/WordBlogX/default.aspx">WordBlogX</category><category domain="http://blogs.msdn.com/ptorr/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>First real bug</title><link>http://blogs.msdn.com/ptorr/archive/2003/09/09/56162.aspx</link><pubDate>Wed, 10 Sep 2003 03:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56162</guid><dc:creator>ptorr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/ptorr/comments/56162.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ptorr/commentrss.aspx?PostID=56162</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ptorr/rsscomments.aspx?PostID=56162</wfw:comment><description>
&lt;p&gt;Rob found an interesting bug last night that I couldn't
repro... until today. Turns out that when you modify a blog entry, you don't
just need the GUID. Oh no. That would be too easy. You need the GUID &lt;b&gt;and&lt;/b&gt; the original creation date!&lt;/p&gt;
&lt;p&gt;My limited testing of my &amp;quot;Update&amp;quot; mechanism worked
because I had always tried to update on the same day that I created an entry,
but Rob found the bug because we were burning the &lt;st1:time Hour="0" Minute="00"
w:st="on"&gt;midnight&lt;/st1:time&gt; oil and he was trying to modify an entry early on
Tuesday morning (like &lt;st1:time Hour="0" Minute="10" w:st="on"&gt;12:10 am&lt;/st1:time&gt;)
that he had created late Monday night (like 11:30).&lt;/p&gt;
&lt;p&gt;I now found the bug today when I tried to modify last
night's entry to point to Rob's blog. Now I have a fixed version that stashes
the created date along with the GUID into the Word document, but it means the
version I just posted to GotDotNet is broken... &lt;/p&gt;
&lt;span&gt;Isn't
software wonderful? Gotta go now.&lt;/span&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=56162" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ptorr/archive/tags/Office/default.aspx">Office</category><category domain="http://blogs.msdn.com/ptorr/archive/tags/WordBlogX/default.aspx">WordBlogX</category></item><item><title>First real bug</title><link>http://blogs.msdn.com/ptorr/archive/2003/09/09/56182.aspx</link><pubDate>Tue, 09 Sep 2003 10:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56182</guid><dc:creator>ptorr</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/ptorr/comments/56182.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ptorr/commentrss.aspx?PostID=56182</wfw:commentRss><wfw:comment>http://blogs.msdn.com/ptorr/rsscomments.aspx?PostID=56182</wfw:comment><description>
&lt;p&gt;Rob found an interesting bug last night that I couldn't
repro... until today. Turns out that when you modify a blog entry, you don't
just need the GUID. Oh no. That would be too easy. You need the GUID &lt;b&gt;and&lt;/b&gt; the original creation date!&lt;/p&gt;
&lt;p&gt;My limited testing of my &amp;quot;Update&amp;quot; mechanism worked
because I had always tried to update on the same day that I created an entry,
but Rob found the bug because we were burning the &lt;st1:time Hour="0" Minute="00"
w:st="on"&gt;midnight&lt;/st1:time&gt; oil and he was trying to modify an entry early on
Tuesday morning (like &lt;st1:time Hour="0" Minute="10" w:st="on"&gt;12:10 am&lt;/st1:time&gt;)
that he had created late Monday night (like 11:30).&lt;/p&gt;
&lt;p&gt;I now found the bug today when I tried to modify last
night's entry to point to Rob's blog. Now I have a fixed version that stashes
the created date along with the GUID into the Word document, but it means the
version I just posted to GotDotNet is broken... &lt;/p&gt;
&lt;span&gt;Isn't
software wonderful? Gotta go now.&lt;/span&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=56182" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/ptorr/archive/tags/Office/default.aspx">Office</category><category domain="http://blogs.msdn.com/ptorr/archive/tags/WordBlogX/default.aspx">WordBlogX</category></item></channel></rss>