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

<channel>
	<title>exploring software and hardware security &#187; Attacking secure systems</title>
	<atom:link href="http://securityblog.astida.com/category/attacking-secure-systems/feed/" rel="self" type="application/rss+xml" />
	<link>http://securityblog.astida.com</link>
	<description>articles about secure systems, secure protocols, tamperproofing, obfuscation, authentication, attack vectors...</description>
	<lastBuildDate>Tue, 10 Nov 2009 20:44:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to choose the right security protocol?</title>
		<link>http://securityblog.astida.com/2009/11/02/how-to-choose-the-right-security-protocol/</link>
		<comments>http://securityblog.astida.com/2009/11/02/how-to-choose-the-right-security-protocol/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 01:20:47 +0000</pubDate>
		<dc:creator>davitb</dc:creator>
				<category><![CDATA[Attacking secure systems]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[how to design secure systems?]]></category>
		<category><![CDATA[authenticity]]></category>
		<category><![CDATA[confidentiality]]></category>
		<category><![CDATA[diffie-helman]]></category>
		<category><![CDATA[eavesdropping]]></category>
		<category><![CDATA[integrity]]></category>
		<category><![CDATA[man-in-the-middle]]></category>
		<category><![CDATA[replay attacks]]></category>
		<category><![CDATA[security protocols]]></category>
		<category><![CDATA[SPEKE]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://securityblog.astida.com/?p=306</guid>
		<description><![CDATA[We all know that sending data over network and being sure that its confidentiality is not damaged is one of the crucial problems in security engineering. In fact, except some special cases the entire information security area is based on the problem of being able to send information from point A to point B and [...]]]></description>
			<content:encoded><![CDATA[<p>We all know that sending data over network and being sure that its confidentiality is not damaged is one of the crucial problems in security engineering. In fact, except some special cases the entire information security area is based on the problem of being able to send information from point A to point B and making sure that’s its security properties are maintained properly.</p>
<p>Creating secure protocols is not an easy task and this article is not intended to help you to create new protocols from the scratch. There already exist many well designed protocols which will give you all the necessary features to meet your requirements. There are many books and articles about how different secure protocols work and how they are designed. This article is not trying to describe details of these protocols rather it tries to recommend the &#8220;ideal&#8221; protocol for you, which of course doesn’t exist. The question that this article will try to answer is how you should choose the right secure protocol for your particular application.</p>
<p>Choosing the right protocol is also not a trivial task however I believe there are patterns which will help you to solve this task for your particular application. I’m able to recognize these patterns and I’m sure you will also be able to do it once you get the proper knowledge and experience.</p>
<p>We will go over the following topics:</p>
<ul>
<li>Data confidentiality and integrity in protocols</li>
<li>Two types of security protocols</li>
<li>Attacks you should worry about while thinking about protocols</li>
<li>Protocol Choosing Patterns</li>
<li>A demonstrative example</li>
<li>Recommended references</li>
</ul>
<p><span id="more-306"></span><br />
So let’s start.</p>
<h3>Data confidentiality and integrity in protocols</h3>
<p>Before going deep into different security protocols and their problems let’s understand why they exist and what they are protecting from.</p>
<p>In my last article (<a href="http://securityblog.astida.com/2009/10/28/key-concepts-in-information-security/">How to design secure systems? Key concept in Information Security</a>) I was talking about security properties of information. I expressed an idea in that article that the whole problem that information security area is trying to solve is “how to make sure that security properties of an information block are properly maintained during its lifetime and that there is no way to damage them?”. Security protocols are tools which allow us designing systems where the information can be transferred from point A to point B over insecure/un-trusted networks without loosing its security properties. I have highlighted six properties in that article – confidentiality, integrity, authenticity, accessibility, availability, non-repudiation. Although in particular applications other properties also can be damaged while transferring data over un-trusted networks – in most cases only confidentiality, integrity and authenticity are of the major concern of security architects. In this article we will mostly focus on these three security properties.</p>
<p>Let’s see what mean confidentiality, integrity and authenticity of data when it comes to transferring information. We transfer sensitive (confidential, private, important) data everyday in our life – when browsing over web, when chating over Skype or other messengers, when talking over phone, transferring files to other locations in network or internet, sending and receiving emails, watching HD TV at home, when locating our location with GPS, etc.</p>
<p>When we transfer this information we want to be sure that nobody else can get it except the addressee. We also want to be sure that the addressee will receive the information exactly in the form we sent it to her. And finally, when the addressee receives our information she wants to be able to make sure that information really came from us and nobody else who is claiming to be us. So our first requirement is about confidentiality, the second is about integrity and the third – authenticity.</p>
<h3>Two types of security protocols</h3>
<p>Although there may be many criteria which can be used to define different categories for security protocols – I have decided to divide them into two types:</p>
<ul>
<li>Authentication based</li>
<li>Zero knowledge</li>
</ul>
<p>Authentication is a key part in a security protocol. Remember, if you want to maintain confidentiality of data – you need to have an authentication part in your protocol. Otherwise how you would know who you are sending your data to?</p>
<p>However it’s not always possible to have authentication primitives in the systems. This is especially true for embedded systems with restricted capabilities. Sometimes you <span style="text-decoration: underline;">have to</span> restrict yourself with protocols which don’t require authentication and thus are prone to man in the middle attacks.</p>
<p>Let’s see what kinds of attacks are possible on security protocols.</p>
<h3>Attacks you should worry about while thinking about protocols</h3>
<p>There are three important attacks you should worry about while designing a security protocol for your system:</p>
<ul>
<li>Eavesdropping<br />
<img class="aligncenter size-full wp-image-311" title="Eavesdropping" src="http://securityblog.astida.com/wp-content/uploads/2009/11/eaves.jpg" alt="Eavesdropping" width="228" height="285" /></p>
<ul>
<li>The attacker has access to the communication channel over which your data is going to be transferred</li>
<li>The attacker can read everything on this channel</li>
</ul>
</li>
</ul>
<ul>
<li>Replay<br />
<img class="aligncenter size-full wp-image-316" title="Replay" src="http://securityblog.astida.com/wp-content/uploads/2009/11/replay.jpg" alt="Replay" width="530" height="285" /></p>
<ul>
<li>This attack is applicable only to authentication based security protocols</li>
<li>When two legitimate users create a secure session &#8211; attacker records the authentication part of the protocol.</li>
<li>After this the attacker replays recorded messages to one of the users and tries to impersonate as the previous legitimate user.</li>
<li>If the protocol doesn’t have means to protect against replay attack – the attack will be successful.</li>
</ul>
</li>
</ul>
<ul>
<li>Man in the Middle<br />
<img class="aligncenter size-full wp-image-319" title="Man in the Middle" src="http://securityblog.astida.com/wp-content/uploads/2009/11/mitm.jpg" alt="Man in the Middle" width="455" height="285" /></p>
<ul>
<li>Any protocol which doesn’t have authentication part is prone to this attack.</li>
<li>The main idea is that the attacker is acting as a malware which stays between two legitimate users – A and B.</li>
<li>When user A sends a message to user B, the attacker is able to receive this message, change it and send the modified message to user B and vice versa.</li>
</ul>
</li>
</ul>
<p>If you designed/chose a protocol which is protected against these three attacks – you can be sure that your protocol is good enough. There can be cases when your system will have specific requirements and those three attacks won’t cover all possibilities. I’m afraid these cases must be addressed uniquely. However I can assure you that in most cases protecting against eavesdropping, replay and MitM attacks is enough.</p>
<h3>Protocol Choosing Patterns</h3>
<p>There are lots of security protocols available in different cryptography books and publications &#8211; Challenge-Response, OTP, EKE family (EKE, SPEKE, J-PAKE, Augmented-EKE, etc), Kerberos, SSL, Diffie-Hellman, and more. How should you choose the right protocol for you?</p>
<p>Choosing the right protocol highly depends on your requirements. I will try to describe an algorithm here aimed to help you in making the right decision but you should understand that it’s not always going to solve the exact problem you have. There will always be cases specific to your requirements and for these cases the described algorithm will serve you just as a direction and not as a solution.</p>
<p>Suppose you have two components in your system – C1 and C2. These components are connected via an un-trusted network. Your general requirement is to be able to send data from C1 to C2 (and vice versa) and yet maintain the security properties of the sending data.</p>
<ol>
<li>If (C1 and C2 don’t share a secret)
<ol>
<li>If (you are not using PKI) then
<ol>
<li>Implement Diffie-Hellman protocol between them</li>
<li><span style="text-decoration: underline;">You will be protected against Replay and Eavesdropping attacks</span></li>
<li><span style="text-decoration: underline;">However, note that you are not protected against Man in the Middle attacks.</span></li>
</ol>
</li>
<li>Else</li>
<li>If (you want one way authentication &#8211; C1 authenticates C2 and C2 doesn’t authenticate C1) then
<ol>
<li>Implement one way SSL between them. C1 authenticates C2 with certificates (this is how web sites are usually authenticated by the browsers).</li>
<li><span style="text-decoration: underline;">You will be protected against Replay, Eavesdropping and Man in the Middle attacks</span></li>
<li><span style="text-decoration: underline;">Note that you need to address the problem of CLR (certificate revocation list) on C1. For embedded devices it’s not always possible.</span></li>
</ol>
</li>
<li>Else</li>
<li>If (you are able to use PKI) then
<ol>
<li> Implement SSL between them</li>
<li><span style="text-decoration: underline;">You will be protected against Replay, Eavesdropping and Man in the Middle attacks</span></li>
<li>N<span style="text-decoration: underline;">ote that you need to address the problem of CLR (certificate revocation list). For embedded devices it’s not always possible</span></li>
</ol>
</li>
</ol>
</li>
</ol>
<p><span style="text-decoration: underline;"> </span></p>
<ol>
<li>If (C1 and C2 share a secret) then
<ol>
<li>If (there is no trusted Root server) then
<ol>
<li> If (you want one way authentication &#8211; C1 authenticates C2 and C2 doesn’t authenticate C1) then
<ol>
<li>Use Challenge-Response or OTP based protocols</li>
<li><span style="text-decoration: underline;">Authentication will be protected against Replay and Eavesdropping attacks</span></li>
<li><span style="text-decoration: underline;">However, note that authentication process is not protected against Man in the Middle attacks.</span></li>
</ol>
</li>
<li>Else</li>
<li> If (You want mutual authentication between C1 and C2) then
<ol>
<li>Use SPEKE (or other EKE based strong algorithm)</li>
<li><span style="text-decoration: underline;">You will be protected against Replay, Eavesdropping and Man in the Middle attacks</span></li>
</ol>
</li>
<li>Else</li>
<li>If (You want mutual authentication between C1 and C2 but don’t want to have exponentiation block in your protocol) then
<ol>
<li> v.      Use SSL which is not based on PKI. Instead of encrypting the pre-master secret with a private key, encrypt it with the shared symmetric key and transfer to C2.</li>
<li>This is quite effective.</li>
<li><span style="text-decoration: underline;">You will be protected against Replay, Eavesdropping and Man in the Middle attacks</span></li>
</ol>
</li>
</ol>
</li>
<li>Else</li>
<li>If (there is a trusted Root server) then
<ol>
<li> i.      Use Kerberos</li>
<li> ii. <span style="text-decoration: underline;">You will be protected against Replay, Eavesdropping and Man in the Middle attacks</span></li>
</ol>
</li>
</ol>
</li>
</ol>
<h3>A demonstrative example</h3>
<p>Let’s assume we have a USB based biometric sensor. After it is attached to a USB port of a PC, user’s biometrics can be scanned and transferred to the PC where it will be processed.</p>
<p>Now, user’s biometric information is used for authentication purpose and it usually opens privacy problems if not protected well… That’s why it is required to protect the confidentiality, integrity and authenticity of biometric data when it is being sent from the sensor to PC.</p>
<p>Biometric sensor usually doesn’t have enough computation power and internal persistent memory and that’s why we are not always free to choose the “ideal” protocol for our system. We will go over several possible cases and discuss how to choose the right protocol.</p>
<p><em>No shared secret</em></p>
<p>Biometric sensors are now very popular and there are companies which produce such sensors by dozens million of units per year. It’s not always easy to share a secret between these sensors and PC. One of the problems is “where exactly the shared secret will be stored on PC?”. It’s not very secure to store it on hard disc. So this is a real problem. Another problem is how the secret will be provisioned in the sensor? This may impact the manufacturing process and make it more expensive. That’s why it’s quite practical to assume that there is no secret shared between the sensor and PC.</p>
<p>So what should we do here to protect the confidentiality of biometric data?</p>
<p>Let’s see what happens if we decide to send biometric data without protecting it:</p>
<p><img class="aligncenter size-full wp-image-321" title="Eavesdropping" src="http://securityblog.astida.com/wp-content/uploads/2009/11/ex1.jpg" alt="Eavesdropping" width="267" height="232" /></p>
<p align="center">
<p>Hopa, the malware can just read the data by installing a USB Kernel driver and eavesdropping the traffic. That’s not good.</p>
<p>Ok, let’s refer to the algorithm described above and see what it suggests. We are not sharing a secret between Biometric Sensor and PC and we are not using PKI – so we fell in 1.a. After implementing Diffie-Hellman only the man in the middle attack will be possible on our system. Note that because we don’t have authentication – we cannot have a better protocol here. So Diffie-Hellman is the best choice.</p>
<p><em> </em></p>
<p><em>Shared secret</em></p>
<p>Let’s assume we designed a system where each sensor possesses a symmetric key and there is a way to securely install this key on PC when we first time attach the sensor to the PC.</p>
<p>The first idea that will come to mind is to encrypt biometric data with the shared secret when the user provides it and send it to PC.</p>
<p><img class="aligncenter size-full wp-image-323" title="Encrypting biometric data" src="http://securityblog.astida.com/wp-content/uploads/2009/11/ex2.jpg" alt="Encrypting biometric data" width="368" height="232" /></p>
<p align="center">
<p>Data confidentiality is protected here – the eavesdropper cannot decrypt data being send. But, hey, what if the malware records the traffic when a legitimate user provides biometrics and replays this traffic next time? The malware will impersonate a legitimate user in this case and gain access to the system without even having the shared secret. That’s bad and that is called a replay attack.</p>
<p><img class="aligncenter size-full wp-image-325" title="Replay attack" src="http://securityblog.astida.com/wp-content/uploads/2009/11/ex3.jpg" alt="Replay attack" width="748" height="247" /></p>
<p>Ok, let’s go further. Usually replay attacks can be protected by using a random challenge in the protocol. If PC sends a random challenge each time before receiving the biometric data and verifies that random challenge exists in the received package – we might be protected against replays.</p>
<p><img class="aligncenter size-full wp-image-327" title="Random Challenge" src="http://securityblog.astida.com/wp-content/uploads/2009/11/ex4.jpg" alt="Random Challenge" width="386" height="318" /></p>
<p align="center">
<p>This is already not bad. First we protect the confidentiality of biometric data by encrypting it and second, we protect authenticity and integrity by verifying the hashed MAC and making sure that it contains the random challenge. In this case we will also be protected against man in the middle attacks as we are doing one way authentication.</p>
<p>Sometimes it’s also required to authenticate the PC in order for the attacker to not be possible to impersonate PC. In this case above mentioned algorithm will direct us to the cases 2.iii or 2.v.</p>
<h3>Recommended references</h3>
<p><a href="http://en.wikipedia.org/wiki/Man-in-the-middle_attack">http://en.wikipedia.org/wiki/Man-in-the-middle_attack</a></p>
<p><a href="http://en.wikipedia.org/wiki/Eavesdropping">http://en.wikipedia.org/wiki/Eavesdropping</a></p>
<p><a href="http://en.wikipedia.org/wiki/Replay_attack">http://en.wikipedia.org/wiki/Replay_attack</a></p>
<p><a href="http://en.wikipedia.org/wiki/Transport_Layer_Security">http://en.wikipedia.org/wiki/Transport_Layer_Security</a></p>
<p><a href="http://en.wikipedia.org/wiki/SPEKE">http://en.wikipedia.org/wiki/SPEKE</a></p>
<p><a href="http://en.wikipedia.org/wiki/Encrypted_key_exchange">http://en.wikipedia.org/wiki/Encrypted_key_exchange</a></p>
<p><a href="http://en.wikipedia.org/wiki/Kerberos_%28protocol%29">http://en.wikipedia.org/wiki/Kerberos_%28protocol%29</a></p>
<p><a href="http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange">http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange</a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsecurityblog.astida.com%2F2009%2F11%2F02%2Fhow-to-choose-the-right-security-protocol%2F&amp;linkname=How%20to%20choose%20the%20right%20security%20protocol%3F"><img src="http://securityblog.astida.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://securityblog.astida.com/2009/11/02/how-to-choose-the-right-security-protocol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to design secure systems? Security Analysis</title>
		<link>http://securityblog.astida.com/2009/10/19/how-to-design-security-systems-security-analysis/</link>
		<comments>http://securityblog.astida.com/2009/10/19/how-to-design-security-systems-security-analysis/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 05:41:08 +0000</pubDate>
		<dc:creator>davitb</dc:creator>
				<category><![CDATA[Attacking secure systems]]></category>
		<category><![CDATA[how to design secure systems?]]></category>
		<category><![CDATA[attack graph]]></category>
		<category><![CDATA[attack vector]]></category>
		<category><![CDATA[risk]]></category>
		<category><![CDATA[security design]]></category>
		<category><![CDATA[threat]]></category>
		<category><![CDATA[vulnerabilities]]></category>

		<guid isPermaLink="false">http://securityblog.astida.com/?p=152</guid>
		<description><![CDATA[Secure system is a piece, or any combination of hardware, software or just an operation which protects an information block that is sensitive to the user. There are secure systems which are dedicated to perform only security related operations (such as safe storage, a dongle token, DRM system, firewalls, encryption device, etc). There are also [...]]]></description>
			<content:encoded><![CDATA[<p>Secure system is a piece, or any combination of hardware, software or just an operation which protects an information block that is sensitive to the user. There are secure systems which are dedicated to perform only security related operations (such as safe storage, a dongle token, DRM system, firewalls, encryption device, etc). There are also systems which are designed to perform operations which work on sensitive information and thus require having security features implemented inside (such as online payment systems, ATMs, email clients/servers, messengers, etc). Independent of purpose of the system and the operations it allows to perform – the security engineers must threat them identically important and design the security of these systems by taking into account the state of art best practices and techniques.</p>
<p>This article is the first part of a series of articles dedicated to principles and best practices of designing secure systems. It will discuss the following topics:</p>
<ul>
<li>The wrong approach of designing security systems</li>
<li>The right approach</li>
<li>Assets, threats, security controls, vulnerabilities, attack vectors and risks</li>
</ul>
<p><span id="more-152"></span></p>
<h3><strong><strong><strong><strong>The wrong approach<br />
</strong></strong></strong></strong></h3>
<p>Security design, as a standalone discipline, has been significantly evolved in the recent years. People have designed tools and techniques for thinking about security and design it more effectively. However this discipline and the knowledge associated with it hasn’t yet fully integrated into system engineering processes and in many cases security systems are designed with a big lack of professionalism. As a result such systems often implement unnecessary and inappropriate security controls, don’t protect the security properties of real assets and leave security holes in the system.</p>
<p>A classical mistake is when engineers start designing security features without first understanding the real assets they are going to protect, their security properties and the real threats that are going to affect the system.</p>
<p>As an example they might decide to encrypt confidential data with a strong cryptographic encryption algorithm but also decide to store the cryptographic key on the hard disc in clear text or use a global key and put it in an executable without understanding that it doesn’t make sense at all.</p>
<p>The usual flow of the wrong approach is demonstrated in the following diagram:</p>
<p><img class="aligncenter size-full wp-image-159" title="Wrong Approach" src="http://securityblog.astida.com/wp-content/uploads/2009/10/wrong.jpg" alt="Wrong Approach" width="512" height="153" /></p>
<ol>
<li>Engineers start designing security controls by analyzing inputs which are mainly based on  intuition. Although intuition is sometimes very good source but is not an institutional way of engineering.</li>
<li>After creating the initial security design, it is being analyzed against different attacks, again based on intuition.</li>
</ol>
<p>This is a wrong approach as it doesn’t use standardized techniques and doesn’t take into account best practices.</p>
<p>Let’s see what the right approach is in my opinion for doing such analysis.</p>
<h3><strong><strong><strong><strong><strong><strong><strong><strong>The right approach</strong></strong></strong></strong></strong></strong></strong></strong></h3>
<p>The reasons behind mistakes that engineers are facing while designing security systems are well known. They are also present in other engineering areas such as software engineering. In order to develop the required software, first engineers need to understand the requirements. In many cases software engineers start to design (even implement!) software without properly clarifying the requirements and at the end of the day they are coming with a product which doesn’t correspond to customer requirements.</p>
<p>In order to avoid such problems people invented different software development methodologies and best practices, which will help guide the engineer to take the appropriate steps while developing software.</p>
<p>Similar methodologies exist also for security system engineering although I would say they are not as popular and distinguished as it is for software engineering.</p>
<p><strong> </strong></p>
<h3><strong><strong><strong><strong><strong><strong><strong><strong>Assets, threats, security controls, vulnerabilities, attack vectors and risks</strong></strong></strong></strong></strong></strong></strong></strong></h3>
<p>Let’s take a look at the diagram below:</p>
<p><img class="aligncenter size-full wp-image-161" title="Security Analisys" src="http://securityblog.astida.com/wp-content/uploads/2009/10/secanal.jpg" alt="Security Analisys" width="701" height="380" /></p>
<p align="center">
<p align="center">
<p>There are several new “keywords” used in this diagram. Let’s define them carefully:</p>
<ul>
<li>Informational Asset
<ul>
<li>Asset is an information piece that needs to be protected. It may have four types of security properties &#8211; confidentiality, integrity, authenticity and availability.</li>
<li>Examples &#8211; user credentials, high-definition video, private information, etc</li>
</ul>
</li>
<li>Threat
<ul>
<li>Threat is anything that has the potential to cause harm to the security properties of an Asset.</li>
<li>Examples – stealing of user credentials, piracy of high-definition video, breach of privacy, etc</li>
</ul>
</li>
<li>Security Control
<ul>
<li>Security controls are safeguards or countermeasures to avoid, counteract or minimize security risks.</li>
<li>Examples – Authentication systems, DRM systems, encryption of private information, etc</li>
</ul>
</li>
<li>Vulnerability
<ul>
<li>Vulnerability is a weakness that could be used to causes harm the security properties of an Asset.</li>
<li>Examples &#8211; Weak passwords, global key in a DRM system, weak encryption function, etc</li>
</ul>
</li>
<li>Attack Vector
<ul>
<li>A set of steps which exploits vulnerability of a system to result in a successful threat execution.</li>
<li>Examples  &#8211; Using brute force to break weak password, Reverse engineer DRM system and obtain the global key, Crypt-analyze the weak encryption function and obtain the encryption key, etc</li>
</ul>
</li>
<li>Risk
<ul>
<li>Risk is the likelihood that something bad will happen that causes harm to the security properties of an Asset.</li>
<li>Examples – the potential of having broken authentication system because of weak passwords is a risk, the potential of having broken DRM system because of global key is a risk, the potential of having broken privacy because of weak encryption function is a risk for the entire system</li>
</ul>
</li>
</ul>
<p>So after defining the terms used in the diagram let’s go through the steps of the flow and understand what each step means:</p>
<ol>
<li><em>Identify and understand your Information Assets: </em>
<ol>
<li>What is the valuable information of your system and what security properties does it have.</li>
<li>Where will your assets be stored and where they need to be traveled.</li>
<li>What security properties of your asset need to be maintained at each point of the system’s lifecycle</li>
</ol>
</li>
<li><em>Identify Threats: </em>
<ol>
<li>Understand what the applicable threats are to your information assets and the future entire system.</li>
<li>Research for known threats in the internet.</li>
</ol>
</li>
<li><em>Start designing security controls: </em>
<ol>
<li>Consider using cryptography</li>
<li>Consider using physical security</li>
<li>Plan protection mechanism for software and hardware (if needed)</li>
<li>Implement other security features</li>
<li>etc</li>
<li>Note that during design of security controls you will introduce new information assets and thus will need to go to step #1</li>
</ol>
</li>
<li><em>Construct the attack vectors (also known as attack trees) of your system: </em>
<ol>
<li>Consider you in the place of the attacker and think different attack scenarios</li>
<li>Research the internet and find applicable attacks</li>
<li>Etc</li>
</ol>
</li>
<li><em>Identify vulnerabilities of the system </em>
<ol>
<li>Attack vectors will result in finding vulnerabilities in your designed system</li>
</ol>
</li>
<li><em>Understand the risks of the vulnerabilities: </em>
<ol>
<li>Evaluate the risk of having vulnerabilities in the system</li>
<li>If the risk is high you might decide to implement new security controls or change existing ones</li>
<li>goto step #3</li>
</ol>
</li>
</ol>
<p>This algorithm allows designing security systems which are measureable by the means of risks. Of course the main problem in security engineering is that during “Construct Attack Vectors” step there is no way to construct and understand all the possible attacks and thus you cannot identify all the vulnerabilities of your system, so you cannot completely measure your design. However the algorithm at least gives you a better understanding of what you are doing, gives the ability to better measure the risks you have in your system and finally – it allows using institutional approach for future analysis.</p>
<h3><strong><strong><strong><strong><strong><strong><strong><strong>References</strong></strong></strong></strong></strong></strong></strong></strong></h3>
<p><a href="http://www.sse-cmm.org/">http://www.sse-cmm.org</a></p>
<p><a href="http://msdn.microsoft.com/en-us/security/cc448177.aspx">http://msdn.microsoft.com/en-us/security/cc448177.aspx</a></p>
<p><a href="http://en.wikipedia.org/wiki/Information_security">http://en.wikipedia.org/wiki/Information_security</a></p>
<p><a href="http://iac.dtic.mil/iatac/download/security.pdf">http://iac.dtic.mil/iatac/download/security.pdf</a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsecurityblog.astida.com%2F2009%2F10%2F19%2Fhow-to-design-security-systems-security-analysis%2F&amp;linkname=How%20to%20design%20secure%20systems%3F%20Security%20Analysis"><img src="http://securityblog.astida.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://securityblog.astida.com/2009/10/19/how-to-design-security-systems-security-analysis/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How the crackers crack code?</title>
		<link>http://securityblog.astida.com/2009/10/11/how-the-crackers-crack-code/</link>
		<comments>http://securityblog.astida.com/2009/10/11/how-the-crackers-crack-code/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 22:33:16 +0000</pubDate>
		<dc:creator>davitb</dc:creator>
				<category><![CDATA[Attacking secure systems]]></category>
		<category><![CDATA[software obfuscation]]></category>
		<category><![CDATA[tamperproof software]]></category>
		<category><![CDATA[breaking code]]></category>
		<category><![CDATA[cracking]]></category>
		<category><![CDATA[debuggers]]></category>
		<category><![CDATA[DLL hooking]]></category>
		<category><![CDATA[tamper proofing]]></category>

		<guid isPermaLink="false">http://securityblog.astida.com/?p=119</guid>
		<description><![CDATA[There are several reasons why a software company would decide to implement heavy protection schemes in their applications by spending lot of development resources, time and money. These reasons are mainly related to the business models of the applications. License based applications (IDE, compilers, etc), applications with valuable IP inside (EDA applications, etc) and applications [...]]]></description>
			<content:encoded><![CDATA[<p>There are several reasons why a software company would decide to implement heavy protection schemes in their applications by spending lot of development resources, time and money. These reasons are mainly related to the business models of the applications. License based applications (IDE, compilers, etc), applications with valuable IP inside (EDA applications, etc) and applications which have access to confidential information (DRM, authentication software, etc), in addition to their main logic, also require difficult protection schemes implemented inside which will ensure that the integrity, confidentiality and availability of the assets, inside these applications, will not be damaged.</p>
<p>It has always been a mystery for me how crackers try to break software. What techniques they are starting with when they have the executable in hand, or what tools they are using for doing the crack.</p>
<p>In general the motivation of crackers is obvious and is the same as what the abovementioned applications want to prevent from:</p>
<ul>
<li>They are trying to use software without paying money (break)</li>
<li>They are trying to steal intellectual property of applications to create a copy of it</li>
<li>They are trying to steal confidential information (such as cryptographic keys) from applications to have access to other valuable information, such as user credentials, high-definition video content, etc, which is accessible in this application</li>
</ul>
<p>In this article we will try to outline the techniques and tools that crackers are using while trying to break protections that exist in applications.</p>
<p><span id="more-119"></span></p>
<p>Typical “cracking lifecycle” consists of the following steps:</p>
<ol>
<li>Static and dynamic analysis of binary executable file</li>
<li>Preparation for an attack</li>
<li>Automation (optional)</li>
</ol>
<p>Usually the first two steps are mandatory but the third is optional and depends on the crackers motivation. If the goal is reverse engineering of IP based algorithms – there is no need to automate the attack. However, for removing license checks – the automation phase is essential.</p>
<p><img class="aligncenter size-full wp-image-120" title="The flow" src="http://securityblog.astida.com/wp-content/uploads/2009/10/flow.jpg" alt="The flow" width="758" height="323" /></p>
<p>The diagram above shows details of these steps and how they actually interact with each other. The adversary usually starts with conducting static and dynamic analyze of the executable. After some protection mechanisms are discovered, the next step will be to remove it, rebuild the executable and test. This process will continue until all protections primitives are removed.</p>
<p>During analysis the adversary can use very different techniques and of course there is no way to cover all possible approaches in one article as they are being improved over time and new, smarter, more complex approaches are being invented. It’s important to note that the cracker has full control over the environment where he runs the target executable. He can run debuggers, run the executable under virtual machine, hook system DLLs, write a kernel rootkit, etc.</p>
<p>Let’s go over each technique mentioned in the diagram above and see how they are performed.</p>
<h3><strong><strong>Learning the Executable structure (Static analysis)</strong></strong></h3>
<p>The first thing that the cracker would do (though it highly depends on his/her taste) is probably learning the structure of executable. Though this step is not very difficult (comparing to others) the information she can gather from it is essential for the next steps.</p>
<p>The following information can be comparably easily obtained from an executable:</p>
<ul>
<li>What libraries is it dynamically linked to? (if any)</li>
<li>Symbol Table (if any)</li>
<li>The starting address of executable</li>
<li>The starting and ending addresses of text and data segments</li>
</ul>
<p>Tools which can help you to dump this information are usually available by default in the operating system or are included in the package of integrated development environments. For Linux type systems it will be GNU Binutils (http://en.wikipedia.org/wiki/GNU_Binary_Utilities), for Windows – set of Dumpbin tools. In addition of course IDA Tool, PE explorer can also be used for this purpose.</p>
<p>The following link provides comprehensive listing of available tools:</p>
<p><a href="http://en.wikibooks.org/wiki/X86_Disassembly/Analysis_Tools">http://en.wikibooks.org/wiki/X86_Disassembly/Analysis_Tools</a></p>
<h3><strong><strong>Searching for known strings (Static analysis)</strong></strong></h3>
<p>The next obvious thing the adversary will try to do is searching for string characters which the program outputs as an indication for error. For example, a license checking or registration based program must have a way to inform the user that registration code is wrong or that the license has been expired. Obviously the adversary can search for these strings in the binary file and try to locate the place of license check.</p>
<p>Constant data is usually embedded in data segment so the basic algorithm for disabling the license check or registration code check would be:</p>
<ol>
<li>Search for the error indication string (smth like “incorrect registration code”) in data segment</li>
<li>Retrieve the address of this string in data segment</li>
<li>Search for the reference of this address in code segment. The code will be something like this:
<ol>
<li>cmp readRegCode, realRegCode</li>
<li>je regCodeValid</li>
<li>…</li>
</ol>
</li>
<li>Replace the “je” command with &#8216;always&#8217; jump command (“jmp”)</li>
</ol>
<p>Note that for some architectures the address gathered from data segment will not be referred directly in code but will be constructed as a “base + offset”. It may make harder finding the appropriate code in code segment.</p>
<p><strong> </strong></p>
<h3><strong><strong>De-compilation (Static analysis)</strong></strong></h3>
<p>Another helpful technique is to try to decompile the binary code into higher level language, such as C. After decompilation is done obviously the code will still be hard to analyze but it may give a better understanding of high-level structure of modules and functions in binary file.</p>
<p>The following resource discusses more about decompilation process and what can be achieved with it:</p>
<p><a href="http://en.wikipedia.org/wiki/Decompiler">http://en.wikipedia.org/wiki/Decompiler</a></p>
<p><strong> </strong></p>
<h3><strong><strong>Searching for algorithm patterns (Static analysis)</strong></strong></h3>
<p>If the target program has cryptographic features implemented inside, such as encryption/decryption functions, it may be an interesting option to try to search the binary file for patterns of “encryption instructions”.</p>
<p>Usually encryption functions have lot of XOR and SHIFT commands inside and that makes them different from usual code. Every standard encryption algorithm (AES, DES, TEA, etc) has its pattern of implementation (a sequence of assembly instructions similar to mov, shl, shl, shl, xor, shr, etc) and if the adversary searches with this pattern, he may be lucky by finding the encryption/decryption functions. After these functions are found if can be easy to locate where exactly the data is being encrypted or decrypted.</p>
<p><strong> </strong></p>
<h3><strong><strong>Listening for library calls (Dynamic analysis)</strong></strong></h3>
<p>The first dynamic analysis technique we will discuss here is the “listening for library calls”. The idea behind this technique is to set a breakpoint on a <span style="text-decoration: underline;">library function call</span> which is definitely going to be called while checking the license expiration or registration code.</p>
<p>Let’s see an example. Suppose the target program checks for registration code and prints “incorrect code” on command prompt if the input code is wrong. Most probably the program will call printf function to do the print. If the adversary sets a breakpoint in printf function and gives a wrong registration code to the program, the breakpoint will be hit. The cracker can navigate up by the call stack and find the appropriate code fragment which is comparing the real registration code with wrong one.</p>
<p>It’s possible that the target program, instead of dynamic linking, used static linking with C libraries. So it won’t be possible to set a break point on printf function as it won’t be called. For these cases there are two options:</p>
<ul>
<li>Search for the pattern of printf function in target binary and set a breakpoint there.</li>
<li>Set a breakpoint on an underlying system call which will be called when printf is called and navigate back by call stack. For printf it will probably be the “write” system call.</li>
</ul>
<p><strong> </strong></p>
<h3><strong><strong>Monitoring memory (Dynamic analysis)</strong></strong></h3>
<p>Sometimes replacing the “je” command with “jmp” won’t be enough for cracking the software. The software developers could implement complicated protections schemes against cracking which assume crashing of software at random places if the registration code was incorrect – e.g. instead of having just an “if” statement for checking the validness of input registration code the software may also have a logic which overwrites some important data in RAM and after the software executes – it crashes at different points. So even if the adversary was able to crack the checking of “reg code” she won’t be able to use the program properly.</p>
<p>In order to understand where exactly the program crashes the following technique could be used:</p>
<ol>
<li>The program is usually crashing when an inaccessible memory is read or write</li>
<li>The cracker will run the program until it’s crashed</li>
<li>The cracker will review the crash dump information and locate the memory address which was being read</li>
<li>The cracker will set a breakpoint on this memory address and wait until it’s hit</li>
<li>In simplest scenario this memory will be is just set to zero</li>
<li>After identifying the code fragment the cracker replaces the “mov” command with appropriate number of “nops” so that the size of binary file is not modified.</li>
</ol>
<p><strong> </strong></p>
<h3><strong><strong>Dumping the internal data (Dynamic analysis)</strong></strong></h3>
<p>Sometime the adversary’s goal is to obtain data which is being available in the program at some point of execution. This data could be user credentials, high definition video content, etc.</p>
<p>Let’s assume that after playing with binary file for some period the attacker found the place where the data is getting available. Now he needs to output it to an external disc. The first option that will come to mind is to add a code to the executable that dumps this data. However, this is not trivial. Adding a new code to a binary executable is not easy as it will break the offsets of different data in the binary file and its integrity will be broken.</p>
<p>So a better approach will be to use the debugger for this purpose. The adversary will run the debugger and set a breakpoint on the place where the data is available. Then he may use the features of debugger to output the content of a variable to external disc (the debuggers usually have a feature of executing set of commands when a breakpoint is hit).</p>
<p><strong> </strong></p>
<h3><strong>Hooking the library calls</strong><strong> (Dynamic analysis)</strong></h3>
<p>I’m sure everyone reading this article has heard about DLL hooking. This technique provides a way to intercept the program data that is being passed to different functions that are called from DLLs.</p>
<p>“Hooking library calls” technique can be used for two purposes:</p>
<ul>
<li>The one that we mentioned above &#8211; intercept the program data</li>
<li>Replace standard functions with yours and make the program to use them</li>
</ul>
<p>We will focus on the second technique.</p>
<p>Sometimes it’s much easier for the adversary to change the environment settings that surround the target program to turn off protection schemes implemented in the program. For example if a program is calling time() function to get the current time, the adversary might provide his own implementation of this function, which will always return a previous time and the license checking code will always succeed.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fsecurityblog.astida.com%2F2009%2F10%2F11%2Fhow-the-crackers-crack-code%2F&amp;linkname=How%20the%20crackers%20crack%20code%3F"><img src="http://securityblog.astida.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://securityblog.astida.com/2009/10/11/how-the-crackers-crack-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

