    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: Professionalism in Programming #28</title>
        <link>https://members.accu.org/index.php/articles/700</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>




<div class="xar-mod-head"><span class="xar-mod-title">Professionalism in Programming, from CVu journal + CVu Journal Vol 16, #5 - Oct 2004</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c184/">Journal Columns</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c182/">Professionalism</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c100/">165</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/c182-100/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/articles/c182+100/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Professionalism in Programming #28</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 04 October 2004 13:16:08 +01:00 or Mon, 04 October 2004 13:16:08 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e22" id="d0e22"></a></h2>
</div>
<div class="c3"><img src="/var/uploads/journals/resources/goodliffe-Picture.png" align=
"right"></div>
<div class="blockquote">
<blockquote class="blockquote">
<p>Security is mostly a superstition. It does not exist in
nature... Life is either a daring adventure or nothing. (Helen
Keller)</p>
</blockquote>
</div>
<p>Not so long ago computer access was a scarce commodity. The
world contained only a handful of machines, owned by a few
organisations, accessed by small teams of highly trained personnel.
In those days computer security meant wearing the right labcoat and
pass card to get past the guard on the door.</p>
<p>Fast forward to today. We carry more computational power in a
pocket than those operators ever dreamt of. Computers are plentiful
and, more pertinently, highly connected.</p>
<p>The volume of information carried by computer systems is growing
at a fantastic rate. We write programs to store, manipulate,
interpret, and transfer this data. Our software must guard against
data going astray: into the hands of malicious attackers, past the
eyes of accidental observers, or even disappearing into the ether.
This is critical; a leak of top-secret company information could
spell financial ruin. You don't want sensitive personal information
(your bank account or credit card details, for example) leaking out
for anyone to use. Most software systems require some level of
security<sup>[<a name="d0e34" href="#ftn.d0e34" id=
"d0e34">1</a>]</sup>.</p>
<p>Whose responsibility is it to build secure software? Here's the
bad news: it's <span class="emphasis"><em>our</em></span> headache.
If we don't consider the security of our handiwork carefully, we
will inevitably write insecure, leaky programs and reap the
rewards.</p>
<p>Software security is a really big deal, but generally we're very
bad at it. Nearly every day you'll hear of a new security
vulnerability in a popular product, or see the results of viruses
compromising system integrity.</p>
<p>This is an enormous topic, far larger than we have scope to go
into here. It's a highly specialised field, requiring much training
and experience. However, even the basics are still not adequately
addressed by modern software engineering teaching. The aim of this
series is to highlight security issues and explore the problem.
We'll learn a number of basic techniques for protecting our
code.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e47" id="d0e47"></a>Why Do We Get
It So Wrong?</h2>
</div>
<p>Building secure software requires a mindset that is sadly
lacking in the average programmer. In the day-to-day madness of the
software factory we're too focused on getting the program working,
on getting it out of the door on time and in a reasonable state. We
sit back and breathe a sigh of relief when our streamlined
application appears to be doing what its supposed to. Rarely do we
turn our attention to how secure the code is. Unless the test
department is particularly skilled in this area, it's easy to
ignore the whole issue - we'd rather not think the worst of a new
creation.</p>
<p>If you do eventually turn your gaze to security issues, perhaps
with a little test department prodding, it's probably too late
anyway. Once a system is built, patching up any security problems
is a hard job; the problems are either too fundamental, too
prevalent, or far too hard to identify.</p>
<p>It's probably hard to believe that anyone would take the time
and effort to hack your applications. But these people exist.
They're talented, motivated, and they are very, very patient. Why
do they do it? Some malicious crackers intend to steal, commit
fraud, or cause damage, but their motive can equally be to prove
superior skills or to cause a little mischief. They might not want
to compromise your application specifically, but won't hesitate to
exploit its flaws if you leave a hole open.</p>
<p>Sadly, no application is totally hack-proof. Writing a secure
program is no easy task. Yet even the most secure application must
run in its operating environment: under a particular OS, on some
specific piece of hardware, on a network, and with a certain set of
users. An attacker is just as likely to compromise one of these as
your actual code. Indeed they're probably more likely to;
<span class="emphasis"><em>social engineering</em></span> - the art
of acquiring important information from people, items in an office,
or even the outgoing trash - is usually a lot easier (and often
quicker) than worming a way into your computer system.</p>
<p>Software security presents a myriad of problems and challenges
for the poor overworked programmer.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e63" id="d0e63"></a>The Risks</h2>
</div>
<div class="blockquote">
<blockquote class="blockquote">
<p>Better be despised for too anxious apprehensions, than ruined by
too confident security. (Edmund Burke)</p>
</blockquote>
</div>
<p>Why would anyone bother to attack your system? It's usually
because you've got something that they want. This could be:</p>
<div class="itemizedlist">
<ul type="disc">
<li>
<p>your processing power,</p>
</li>
<li>
<p>your ability to send data (e.g. send spam emails),</p>
</li>
<li>
<p>your privately stored information,</p>
</li>
<li>
<p>your capabilities; perhaps the specific software you have
installed, or</p>
</li>
<li>
<p>your connection to more interesting remote systems.</p>
</li>
</ul>
</div>
<p>They might even attack you for the sheer fun of it, or because
they dislike you and want to cause harm by disrupting your computer
resources. Of course, we must remember that whilst malicious people
<span class="emphasis"><em>are</em></span> lurking around looking
for easy, insecure prey, a security vulnerability might equally be
caused by a program that accidentally releases information to the
wrong audience. Sometimes this won't matter. More often it's just
embarrassing. In the worst case, though, that lucky user can
opportunistically exploit the leak and cause you harm.</p>
<p>To understand the kinds of attack you might suffer, it's
important to mark the difference between protecting an entire
computer <span class="emphasis"><em>system</em></span> (comprising
of several computers, a network, and a number of collaborating
applications) and writing a single secure <span class=
"emphasis"><em>program</em></span>. Both are important aspects of
computer security; they blur together since both are necessary. The
latter is a subset of the former. It takes just one insecure
program to render an entire computer system (or network) insecure,
so we must take the utmost care at all times.</p>
<p>Let's take a look at the ways you can be caught with your pants
down. These are some of the most common security risks and
compromises of a live, running computer system:</p>
<div class="itemizedlist">
<ul type="disc">
<li>
<p><span class="bold"><b>Physically acquiring a machine</b></span>,
for example by stealing a laptop or PDA containing unsecured
sensitive data. This data is freely readable by anyone with the
inclination. Similarly, the stolen device might be configured to
automatically dial into a private network, allowing a simple route
straight through all your company's defences. This is a serious
security threat, and one that you can't easily guard against in
code! What we can do is write systems that aren't immediately
accessible to computer thieves.</p>
</li>
<li>
<p><span class="bold"><b>Exploiting flaws in a program's input
routines</b></span>. Not checking input validity can lead to many
types of compromise, even to the attacker gaining access to the
whole machine. We'll see examples of this later.</p>
</li>
<li>
<p><span class="bold"><b>Breaking in through an unsecured public
network interface</b></span> is a specific variant of the previous
point. This is particularly worrying. UI flaws can only be
exploited by people actually <span class=
"emphasis"><em>using</em></span> that UI, but when your insecure
system is running on a public network the whole world could be
trying to break down your doors.</p>
</li>
</ul>
</div>
<div class="sidebar">
<p class="title c4">A Promise Kept</p>
<p>In the last article I promised you the answer to my riddle: how
many programmers does it take to change a light bulb? How many
answers did you come up with? Here are mine:</p>
<div class="orderedlist">
<ol type="1">
<li>
<p>None. The bulb's not broken. It's a power saving feature.</p>
</li>
<li>
<p>Just the one, but it will take all night and an inordinate
amount of pizza and coffee.</p>
</li>
<li>
<p>Twenty. One to fix the initial problem, and nineteen to debug
the resultant mess.</p>
</li>
<li>
<p>The question's wrong. It's a hardware problem, not a software
one.</p>
</li>
</ol>
</div>
</div>
<div class="itemizedlist">
<ul type="disc">
<li>
<p><span class="bold"><b>Malicious authorised users copying and
sharing data</b></span> they're not supposed to. It's hard to guard
against this one. You have to trust that each user is responsible
enough to handle the level of system access they've been
designated.</p>
</li>
<li>
<p><span class="bold"><b>Malicious authorised users entering bad
data</b></span> to compromise the quality of your computer system.
Any system has a small set of trusted users. If they're not
trustworthy then you can't write a program to fix them. This shows
that security is as much about administration and policy as it is
about writing code.</p>
</li>
<li>
<p><span class="bold"><b>Setting incorrect permissions</b></span>,
allowing the wrong users to gain access to sensitive parts of your
system. This could be as basic as setting the correct access
permissions on database files so casual users can't see everyone's
salary details.</p>
</li>
<li>
<p><span class="bold"><b>Privilege escalation</b></span>. This
occurs when a user with limited access rights tricks the system to
gain a higher security level. The attacker could be an authentic
user, or someone who has just broken into the system. Their
ultimate aim is to achieve root or <span class=
"emphasis"><em>administrator</em></span> privilege, where the
attacker has total control of the machine.</p>
</li>
<li>
<p><span class="bold"><b>&quot;Tapping into&quot; data</b></span> as it is
transmitted on the wire. If communication is unencrypted and
traverses an insecure medium (e.g. the internet) then any computer
en route can syphon off and read data without anyone else knowing.
A variant of this is known as a <span class=
"emphasis"><em>man-in-the-middle</em></span> attack - when an
attacker's machine pretends to be the other communicant and sits
between both senders, snooping on their data.</p>
</li>
<li>
<p><span class="bold"><b>Virus attacks</b></span> (self-replicating
malicious programs, commonly spread by email attachment), trojans
(hidden malicious payloads in seemingly benign software), and
spyware (a form of trojan that spies on what you are doing, the
webpages you visit, etc). These programs can capture even the most
complex password with keystroke loggers, for example.</p>
</li>
<li>
<p><span class="bold"><b>Careless users</b></span> (or bad system
design) can leave a system unnecessarily open and vulnerable. For
example, users often forget to log off, and if there is no session
timeout anyone can later pick up your program and start using
it.</p>
</li>
<li>
<p><span class="bold"><b>Storing data 'in the clear'</b></span>
(unencrypted). Even leaving it in memory is dangerous; memory is
not as safe as many programmers think. A virus or trojan can scan
computer memory and pull out a lot of interesting titbits for an
attacker to exploit. This depends on how secure your OS is - does
it allow this kind of memory access and can you lock your
applications's memory pages manually?</p>
</li>
<li>
<p><span class="bold"><b>Copying software</b></span>. For example:
running multiple installations in an office only licensed for one
user, or allowing copies to spread on the internet.</p>
</li>
<li>
<p><span class="bold"><b>Allowing weak, easily guessable
passwords</b></span>. Many attackers use dictionary-based password
cracking tools that fire off many login attempts until one works.
It's a sad fact that easily memorable passwords are also easily
guessable passwords. More secure systems will suspend a user
account after a few unsuccessful logins.</p>
</li>
<li>
<p><span class="bold"><b>Out-of-date software
installations</b></span>. Many vendors issue security warnings and
software patches. They come at a phenomenal rate and should really
be carefully checked before being deployed. A computer system
administrator can easily fall behind the cutting edge.</p>
</li>
</ul>
</div>
<p>The problem scales as the number of routes into a system grows.
It gets worse with: the more input methods (web access, command
line, or GUI interfaces), the more individual inputs (different
windows, prompts, web forms, or XML feeds), and the more users
(there is more chance of someone discovering a password). With more
outputs there is more chance for bugs to manifest in the display
code, leaking out the wrong information</p>
<p>How do you know when your program has been compromised? Without
detection measures you'll have no idea - and will just have to keep
an eye out for unusual system behaviour or different patterns of
activity. This is hardly scientific. A hacked system can remain a
secret indefinitely. Even if the victim (or their software vendor)
does spot an attack, they probably don't want to release detailed
information about it to invite more intruders. What company would
publicise that their product has security issues that are
effectively wide-open doors? If they are conscientious enough to
release a security patch not everyone will upgrade, leaving a
well-documented security flaw in many operational systems.</p>
<div class="sidebar">
<p class="title c4">Cracker vs Hacker</p>
<p>These two terms often get confused and used inappropriately.
Let's stop briefly and set the record straight. Their correct
definitions are:</p>
<div class="variablelist">
<dl>
<dt><span class="term">Cracker:</span></dt>
<dd>
<p>Someone who purposefully attacks computer systems by exploiting
their vulnerabilities to gain unauthorised access.</p>
</dd>
<dt><span class="term">Hacker:</span></dt>
<dd>
<p>Often used incorrectly to mean cracker, a hacker is really
someone who 'hacks' at code. This is a term used with pride by a
particular breed of programming geek. A hacker is a computer expert
or enthusiast.</p>
</dd>
</dl>
</div>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e223" id="d0e223"></a>The
Opposition</h2>
</div>
<p>To defend yourself adequately it's important to know whom you're
fighting against. As they say: <span class="emphasis"><em>know your
enemies</em></span>. We must understand exactly what they're doing,
how they do it, the tools they're using, and their objectives. Only
then can we formulate a strategy to cope.</p>
<p>Your attacker might be a common crook, a talented cracker, a
'script kiddie'<sup>[<a name="d0e233" href="#ftn.d0e233" id=
"d0e233">2</a>]</sup>, a dishonest employee cheating the company,
or a disgruntled ex-employee seeking revenge for unfair
dismissal.</p>
<p>Thanks to pervasive networking they could be anywhere, in any
continent, using any type of computer. When working over the
internet attackers are very hard to locate; many are skilled at
covering their tracks. Often they crack easy machines to use as a
cover in more audacious attacks.</p>
<p>They could attack at any time, day or night. Across continents
one person's day is another's night. You need to run secure
programs around the clock, not just in business hours.</p>
<p>There is a cracker subculture where knowledge is passed on and
easy-to-use cracker tools are distributed. Not knowing about this
doesn't make you innocent and pure, just naive and open to the
simplest of attack.</p>
<p>With such a large bunch of potential attackers, the motives for
an attack are diverse. It might be malicious (a political activist
wants to ruin your company, or a thief wants to access your bank
account), or it might be for fun (a college prankster wants to post
a comical banner on your website). It might be inquisitive (a
hacker just wants to see what your network infrastructure looks
like, or practice their cracking skills), or might be opportunist
(a user stumbles over data they shouldn't see, and works out how to
use it to their advantage).</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e245" id="d0e245"></a>Excuses,
Excuses</h2>
</div>
<p>How do attackers manage to break into code so often? They're
armed with weapons we don't have or (due to lack of education) know
nothing about. Tools, knowledge, skills: these all work in their
favour. However, they have one key advantage that makes all the
difference: time. In the heat of the software factory, programmers
are pressed to deliver as much code as humanly possible (probably a
little bit more), and to do so on time: or else. This code has to
meet all requirements (for functionality, usability, reliability,
etc) leaving precious little time to focus on other 'peripheral'
concerns, like security. Attackers don't share this burden, have
plenty of time to learn the intricacies of your system, and have
learnt to attack from many different angles.</p>
<p>The game is stacked heavily in their favour. As software
developers we must defend all possible points of the system; an
attacker can pick the weakest point and focus there. We can only
defend against the known exploits; an attacker can take their time
to find any number of unknown vulnerabilities. We must be
constantly on the lookout for attacks; the attacker can strike at
will. We have to write good, clean software that works nicely with
the rest of the world; an attacker can play as dirty as they
like.</p>
<p>What does this tell us? Simply that we <span class=
"emphasis"><em>must</em></span> do better. We must be better
informed, better armed, more aware of our enemies, and more
conscious of the way we write code. We must design in security from
the outset and put it into our development processes and
schedules.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e257" id="d0e257"></a>Next
Time</h2>
</div>
<p>We'll conclude this topic by investigating some specific code
vulnerabilities, and working out good techniques to defend our code
from attack.</p>
</div>
<div class="footnotes"><br>
<hr class="c5" width="100">
<div class="footnote">
<p><sup>[<a name="ftn.d0e34" href="#d0e34" id=
"ftn.d0e34">1</a>]</sup> As we'll see, this is true whether they
handle sensitive data or not. If a 'non-critical' component has a
public interface then it poses a security risk to the system as a
whole.</p>
</div>
<div class="footnote">
<p><sup>[<a name="ftn.d0e233" href="#d0e233" id=
"ftn.d0e233">2</a>]</sup> A derogatory name for crackers who run
automated 'crack er scripts'. They exploit well-known
vulnerabilities with little skill themselves.</p>
</div>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
