<?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>Compass Security Blog</title>
	<atom:link href="http://blog.csnc.ch/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.csnc.ch</link>
	<description>A Blog about Information Security...</description>
	<lastBuildDate>Tue, 09 Apr 2013 09:43:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Lean Risk Assessment based on OCTAVE Allegro</title>
		<link>http://blog.csnc.ch/2013/04/lean-risk-assessment-based-on-octave-allegro/</link>
		<comments>http://blog.csnc.ch/2013/04/lean-risk-assessment-based-on-octave-allegro/#comments</comments>
		<pubDate>Tue, 09 Apr 2013 09:16:40 +0000</pubDate>
		<dc:creator>Cyrill Brunschwiler</dc:creator>
				<category><![CDATA[Industrial Control Systems]]></category>
		<category><![CDATA[Risk Assessment]]></category>
		<category><![CDATA[Standards]]></category>

		<guid isPermaLink="false">http://blog.csnc.ch/?p=978</guid>
		<description><![CDATA[The article will provide a quick overview and introduction into the Operationally Critical Threat, Asset, and Vulnerability Evaluation (OCTAVE) Allegro [1] methodology, its approach and terminology. OCTAVE Allegro is an asset centric and lean risk assessment successor of the OCTAVE &#8230; <a href="http://blog.csnc.ch/2013/04/lean-risk-assessment-based-on-octave-allegro/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The article will provide a quick overview and introduction into the Operationally Critical Threat, Asset, and Vulnerability Evaluation (OCTAVE) Allegro [1] methodology, its approach and terminology. OCTAVE Allegro is an asset centric and lean risk assessment successor of the OCTAVE method. The method supports a straight-forward qualitative risk assessment and structured threat analysis which mainly fits for smaller organisations (few hundred employees). Figure 1 is based on [2] and groups the methodology steps into four major phases.</p>
<h2><strong>OCTAVE Allegro Phases</strong></h2>
<ul>
<li>Phase “Establish Drivers” aims to justify and prioritise the measurement criteria for risk for a specific organisation.</li>
<li>Phase “Profile Assets” is designed to identify and document logical, technical, physical and people assets.</li>
<li>Phase “Identify Threats” focuses on the identification of threats against the identified assets.</li>
<li>Phase “Identify and Mitigate Risk” supports the valuation of the risks posed against the critical information assets. Finally, after this step, the mitigation strategy for each of the identified risks is defined.</li>
</ul>
<p><img src="http://blog.csnc.ch/wp-content/uploads/2013/04/Untitled1.jpg" alt="" width="500" height="303" /></p>
<p>Figure 1: OCTAVE Allegro steps and phases [2]</p>
<h2><strong>OCTAVE Allegro Steps</strong></h2>
<p>This section goes through all of the OCTAVE Allegros steps to provide an introduction into the methodology. Moreover, each step will be accompanied by a fictitious example related to AMI. Note, that dark coloured steps in figure 1 are considered major steps in order to conduct a threat analysis whereas light coloured steps are crucial when approaching a complete risk assessment.</p>
<p><strong>Step 1</strong> advises to identify all areas that impact an organisation. The methodology requires for a minimum set of areas which includes safety, health, productivity, reputation, financial and fines. For each of the impact areas, a set of criteria to measure low, medium and high impact must be developed. Table 1 provides an example for loss of revenue in case of data privacy violation. Finally, the major areas will be ranked and assigned values in order to allow for risk scoring. In case five areas have been identified and “legal penalties” is considered the top risk area, then the area would be assigned a five. An example is provided in table 6.</p>
<p><img src="http://blog.csnc.ch/wp-content/uploads/2013/04/Untitled2.jpg" alt="" width="500" height="49" /></p>
<p>Table 1: OCTAVE Allegro Step 1: Establish Risk Measurement Criteria. Impact Area Example</p>
<p><strong>Step 2</strong> provides guidance in identifying critical information assets for the organisation. The methodology also provides a set of questions and asks for example for the value of assets or the dependency on assets for the day-to-day business of the organisation. Each identified information asset will be attributed additional cornerstone such as the security requirements to make up a whole information asset profile. An example for key material in a smart meter is provided in table 2. Moreover, each profile&#8217;s most important security requirement is being identified to support the later valuation of the potential impacts. OCTAVE Allegro does not provide much guidance and structure on how to identify security requirements. A way to model such requirements is by means of misuse cases [3]. The misuse case approach lends it from the unified modelling language (UML) such as used in common software engineering processes where success and fail scenarios of interaction with data and processes is being modelled. Though, the modelling of misuse cases rather focuses on the abuse of such scenarios by malicious actors (misusers).</p>
<p><img src="http://blog.csnc.ch/wp-content/uploads/2013/04/Untitled3.png" alt="" width="500" height="80" /></p>
<p>Table 2: OCTAVE Allegro Step 2: Develop Information Asset Profile. Critical Information Asset Example</p>
<p><strong>Step 3</strong> collects information asset containers in the form of an information asset risk environment map. Information asset containers, as the name implies, can hold, process or somehow get in touch with information assets. The methodology classifies containers as technical, physical and people. Table 3 provides examples for each of the types. Correspondingly, containers are being attributed whether they are of type internal which means under control of the organisation or whether the container is external.</p>
<p><img src="http://blog.csnc.ch/wp-content/uploads/2013/04/Untitled4.png" alt="" width="500" height="73" /></p>
<p>Table 3: OCTAVE Allegro Step 3: Identify Information Asset Containers. Container Examples</p>
<p>For the analysis of an organisation the type column can be attributed with minimal effort. However, for an abstract analysis such as network protocols or embedded devices, some assumptions must be made. There is no general rule on what assumptions to make.</p>
<p><strong>Step 4</strong>&#8216;s goal is to identify major areas of concern. Thereby the method foresees to consider all containers and to identify issues that could affect assets within the container. The compiled list of “areas of concern” is then expanded with the according actor, the means to realise the threat, the motive of the actor and the potential outcome. Whereby an outcome is always one out of disclosure, modification, interruption or destruction. The method documentation further lists loss next to destruction. An example, implicitly referencing the affected information asset, is provided in table 4. This step does not aim to identify a complete list of threats but helps to capture the major concerns in short time.</p>
<p><img src="http://blog.csnc.ch/wp-content/uploads/2013/04/Untitled5.png" alt="" width="500" height="48" /></p>
<p>Table 4: OCTAVE Allegro Step 4: Identify Areas of Concern. Area of Concern Example</p>
<p>Note, that I have made use of this step in order to capture area of concerns for the smart meter and wireless M-Bus analysis within my master thesis.</p>
<p><strong>Step 5</strong> ensures structured identification of all potential threats. Threat trees ensure robust consideration of threats. The step relies on four trees in total. Two considering human actors with either technical or physical means and two considering technical and other problems. Part of the “Human Actors Using Technical Means” tree originating of the methodology documentation [1] is shown in figure 2.</p>
<p><img src="http://blog.csnc.ch/wp-content/uploads/2013/04/Untitled6.png" alt="" width="500" height="339" /></p>
<p>Figure 2: OCTAVE Allegro &#8220;Human Actors Using Technical Means&#8221; Tree [1]</p>
<p>With each information asset, each branch of the four trees will be traversed to ensure thorough coverage and identification of threats. The guidance provides worksheets and questionnaires to simplify the activity. The result of the walk through will be a comprehensive list of threat entries as shown in table 4. Optionally, each resulting list entry can be assigned the probability of the realisation of the concerned threat scenarios with either low, medium or high likelihood.<br />
As this is a tedious task in an assessment based on OCTAVE Allegro, I would not dig too much into it unless the previous step “Identify Areas of Concern” does not provide sufficient material or the analysis significantly lacks coverage. However, if thorough coverage is a requirement, that step cannot be circumvented.</p>
<p><strong>Step 6</strong> consists of a single activity and aims to identify the impact if a certain threat scenario becoming realised. Following that, each threat scenario will be attributed a consequence. Thus, table 4 has been expanded with an additional column to describe the consequence for each scenario. Part of table 4 and the newly added column is shown in table 5.</p>
<p><img src="http://blog.csnc.ch/wp-content/uploads/2013/04/Untitled7.jpg" alt="" width="500" height="63" /></p>
<p>Table 5: OCTAVE Allegro Step 6: Identify Risks. Risk Example</p>
<p><strong>Step 7</strong> focuses on creation of a relative risk scores for each identified threat scenario. The impact on each impact area as well as the impact area importance will be reflected in the total risk score. The score should help to decide on what mitigation approach to choose in the ultimate step of the methodology. Assumed the impact area ranking in table 6 and threat scenario listed in table 5 the risk score for that specific scenario calculates as shown in table 6.</p>
<p><img src="http://blog.csnc.ch/wp-content/uploads/2013/04/Untitled8.jpg" alt="" width="500" height="198" /></p>
<p>Table 6: OCTAVE Allegro Step 7: Analyse Risk. Example Risk Score Calculation</p>
<p>Basically, for each impact area the impact will be measured according to the criteria defined in step 1. An example of such criteria is provided in table 1. High impact will be assigned a value of three and low impact accordingly a value of one. The impact area ranking is then multiplied with the threat scenario impact value whereby the result of that calculation contributes to the total risk score.</p>
<p><strong>Step 8</strong> the ultimate step in the OCTAVE Allegro qualitative risk assessment method deals with the mitigation approach of identified risks. In general risks can be accepted, mitigated, transferred, avoided or being further monitored (deferred) whereas mitigation aims to avoid or limit the risk. However, the efforts for avoidance and limitation should never outweigh a potential impact.<br />
Though numbers have been assigned as risk scores, their specific value only provides indication to whether a risk should to be mitigated or not. One might also take the likelihood of occurrence and some organisation specifics into account. It is suggested to divide the risks into four pools, pool one to pool four, whereby each pool groups threats for a range of the total risk score. The four pools are then approached as follows:</p>
<ul>
<li>Pool 1: Mitigate</li>
<li>Pool 2: Mitigate or Defer</li>
<li>Pool 3: Defer or Accept</li>
<li>Pool 4: Accept</li>
</ul>
<p>Depending on whether probabilities have been assigned in step 5 of the methodology it is suggested to either form a list of all risks and then split it into four pools or create a matrix which reflects the four pools and takes the probability into account. Finally, a mitigation strategy should be formulated for all risks that need to be mitigated. The mitigation strategy should list the information asset container to which the controls will be applied. Plus, the chosen strategy should consider and outline potential residual risks. An example of such a mitigation strategy is provided in table 7.</p>
<p><img src="http://blog.csnc.ch/wp-content/uploads/2013/04/Untitled9.jpg" alt="" width="500" height="47" /></p>
<p>Table 7: OCTAVE Allegro Step 8: Select Mitigation Approach. Mitigation Strategy Example</p>
<p><strong>Conclusion</strong></p>
<p>OCTAVE Allegro is a lean risk assessment method and does not provide guidance in selecting security controls as with extensive information security management standards such as ISO 27000 [4]. However, ISO 27002 [5] and NIST SP 800-53 [6] provide a comprehensive list of controls to choose from, if needed.</p>
<p><strong>References</strong></p>
<p>[1] R.A. Caralli, J.F. Stevens, L.R. Young, W.R. Wilson. The OCTAVE Allegro Guidebook, v1.0. Cert Program, Software Engineering Institute, Carnegie Mellon University, Pittsburgh, PA 15213. May 2007, Online <a href="http://www.cert.org/octave/allegro.html" target="_blank">http://www.cert.org/octave/allegro.html</a><br />
[2] R.A. Caralli, J.F. Stevens, L.R. Young, W.R. Wilson. Introducing OCTAVE Allegro: Improving the Information Security Risk Assessment Process. CMU/SEI-2007-TR-012, CERT Program, Software Engineering Institute, Carnegie Mellon University, Pittsburgh, PA 15213. May 2007, Online <a href="http://www.cert.org/archive/pdf/07tr012.pdf" target="_blank">http://www.cert.org/archive/pdf/07tr012.pdf</a><br />
[3] G. Sindre and A.L. Opdahl. Eliciting security requirements with misuse cases. Requirements Engineering Vol. 10 No. 1, pp. 34-44. Jun. 2004 (DOI 10.1007/s00766-004-0194-4)<br />
[4] ISO-27000:2009: Information technology &#8211; Security techniques &#8211; Information security management systems &#8211; Overview and vocabulary<br />
[5] ISO 27002:2005: Information technology &#8211; Security techniques &#8211; Code of practice for information security management<br />
[6] NIST. Security and Privacy Controls for Federal Information Systems and Organizations. Special Publication 800-53, Rev. 4, Final Public Draft, Feb. 2013, Online <a href="http://csrc.nist.gov/publications/drafts/800-53-rev4/sp800_53_r4_draft_fpd.pdf" target="_blank">http://csrc.nist.gov/publications/drafts/800-53-rev4/sp800_53_r4_draft_fpd.pdf</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.csnc.ch/2013/04/lean-risk-assessment-based-on-octave-allegro/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>XSS &#8211; The never ending story</title>
		<link>http://blog.csnc.ch/2013/03/xss-the-never-ending-story/</link>
		<comments>http://blog.csnc.ch/2013/03/xss-the-never-ending-story/#comments</comments>
		<pubDate>Thu, 07 Mar 2013 09:12:45 +0000</pubDate>
		<dc:creator>Stephan Rickauer</dc:creator>
				<category><![CDATA[Penetration Test]]></category>
		<category><![CDATA[Web Application]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[OWASP]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://blog.csnc.ch/?p=971</guid>
		<description><![CDATA[Cross-Site Scripting (XSS) has lost one rank in the newly released OWASP Top Ten 2013 candidate. Compared to the 2010 version, it&#8217;s now on rank three, overtaken by &#8220;Broken Authentication and Session Management&#8221;. Has XSS become less common then? No, &#8230; <a href="http://blog.csnc.ch/2013/03/xss-the-never-ending-story/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Cross-Site Scripting (XSS) has lost one rank in the <a href="https://www.owasp.org/index.php/Top_10_2013-T10" target="_blank">newly released OWASP Top Ten 2013</a> candidate. Compared to the 2010 version, it&#8217;s now on rank three, overtaken by &#8220;Broken Authentication and Session Management&#8221;. Has XSS become less common then? No, I don&#8217;t think so.</p>
<p><a href="http://blog.csnc.ch/wp-content/uploads/2013/03/fi.png"><img class="alignright size-full wp-image-972" title="Cross-Site Scripting visible in Source Code" src="http://blog.csnc.ch/wp-content/uploads/2013/03/fi.png" alt="" width="442" height="81" /></a></p>
<p>Compass Security has always been strong in web application security testing and not surprisingly, has a huge experience in identifying all kinds of web app related weaknesses, including Cross-Site Scripting. To wrap up quickly, here&#8217;s <a href="https://www.owasp.org/index.php/Top_10_2013-A3" target="_blank">OWASP&#8217;s pretty decent definition</a>:</p>
<blockquote><p>&#8220;XSS flaws occur whenever an application takes untrusted data and sends it to a web browser without proper validation or escaping. XSS allows attackers to execute scripts in the victim’s browser which can hijack user sessions, deface web sites, or redirect the user to malicious sites.&#8221;</p></blockquote>
<p>Just in the last two months, I&#8217;ve been releasing three advisories, all related to XSS:</p>
<ul>
<li><a href="http://seclists.org/fulldisclosure/2013/Mar/0" target="_blank">CVE-2013-1413</a> (Synetics i-doit)</li>
<li><a href="http://seclists.org/fulldisclosure/2013/Jan/207" target="_blank">CVE-2013-0805</a> (Combodo iTop)</li>
<li><a href="http://seclists.org/fulldisclosure/2013/Jan/218" target="_blank">CVE-2013-1393</a> (Drupal CurvyCorners)</li>
</ul>
<p>So why is XSS still so wide-spread? Here&#8217;s my personal top three:</p>
<ol>
<li>Developers tend to care more about features than security. This might be driven by marketing or sales, time constraints or other well-founded reasons – but at the end, it doesn&#8217;t matter. Sloppy coding, not being well trained and cheap outsourcing complete this picture.</li>
<li>People suffer from the NIH syndrome (Not-Invented-Here). Instead of building their product on a well-tested code base, e.g. some common framework, they re-invent software in an insecure matter, also due to point 1.</li>
<li>People underestimate the effort of maintaining software, which is always dynamic per se. This often leads to unpatched Content-Management-Systems being used in the wild: set up once, forgotten forever.</li>
</ol>
<p><strong>So, what&#8217;s the solution?</strong></p>
<p>Software development should always be embedded in a <a href="http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&amp;id=12285" target="_blank">Secure Development Lifecycle</a>, in order to ensure its quality in development, improvements and operation. Besides, professional software companies and communities need to treat security incidents seriously. A positive example of the three above has been the <a href="https://security.drupal.org/" target="_blank">Drupal community</a>, which has shown it&#8217;s a professional approach from day one I contacted them.</p>
<p>Cross-Site Scripting is so easy to fix but so powerful to exploit. However, XSS is either not treated as a concrete threat or its impact is underestimated. We can just hope that someday all web developers understand its impacts and care more about their software – and customers.</p>
<p>Meanwhile, we&#8217;ll <a href="http://shirtoid.com/46366/keep-calm-and-continue-testing/" target="_blank">stay calm and continue testing …</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.csnc.ch/2013/03/xss-the-never-ending-story/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advanced Metering Infrastructure Architecture and Components</title>
		<link>http://blog.csnc.ch/2013/02/advanced-metering-infrastructure-architecture-and-components/</link>
		<comments>http://blog.csnc.ch/2013/02/advanced-metering-infrastructure-architecture-and-components/#comments</comments>
		<pubDate>Thu, 28 Feb 2013 05:30:14 +0000</pubDate>
		<dc:creator>Cyrill Brunschwiler</dc:creator>
				<category><![CDATA[Industrial Control Systems]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[advanced metering infrastructure]]></category>
		<category><![CDATA[ami]]></category>
		<category><![CDATA[AMR]]></category>
		<category><![CDATA[collector]]></category>
		<category><![CDATA[DSO]]></category>
		<category><![CDATA[gateway]]></category>
		<category><![CDATA[HAN]]></category>
		<category><![CDATA[head end system]]></category>
		<category><![CDATA[HES]]></category>
		<category><![CDATA[home area network]]></category>
		<category><![CDATA[meter]]></category>
		<category><![CDATA[NAN]]></category>
		<category><![CDATA[neighborhood area network]]></category>
		<category><![CDATA[relay]]></category>
		<category><![CDATA[WAN]]></category>
		<category><![CDATA[wide area network]]></category>

		<guid isPermaLink="false">http://blog.csnc.ch/?p=959</guid>
		<description><![CDATA[The advanced metering infrastructure (AMI) is typically structured into a bunch of networks and composed of a few major components. Figure 1 provides an overview of all components and most networks. It is made up of the Meter, the Collector &#8230; <a href="http://blog.csnc.ch/2013/02/advanced-metering-infrastructure-architecture-and-components/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The advanced metering infrastructure (AMI) is typically structured into a bunch of networks and composed of a few major components. Figure 1 provides an overview of all components and most networks. It is made up of the Meter, the Collector and of the server systems at the distribution system operator (DSO) or metering company side.</p>
<p>The subsequent sectionswill briefly introduce the major components of the AMI.</p>
<p><img src="http://blog.csnc.ch/wp-content/uploads/2013/02/advanced_metering_infrastrcuture1.png" alt="" width="550" height="178" /></p>
<p>Figure 1: Advanced Metering Infrastructure Networks and Components</p>
<p><strong>Head-end System</strong><br />
The head-end system (HES), also known as meter control system, is located within a metering company network. In most cases the metering company is the responsible DSO. The HES is directly communicating with the meters. Therefore, the HES is located in some demilitarized zone (DMZ) since services and functionality will be provided to the outside.<br />
There is much more infrastructure at the DSO or metering company side. The collected data will be managed within a metering data management system (MDM) which also maps data to the relevant consumer. Depending on the automation level, the metering data will have influence on the DSO actions in order to balance the grid.<br />
Exposing the HES to consumers enables some significant threats to the DSO. For example, an adversary getting hold of the HES could read all consumer data. Moreover, one could control meters or could manipulate usage data or generate alerts in order to disturb the DSO operations or at least trigger the computer incident response team (CIRT) and maybe force the DSO to backup to some business continuity plan (BCP) while analysing and recovering the HES.</p>
<p><strong>Collector</strong><br />
The collector, also known as concentrator or gateway serves as communication node for the HES. Depending on the infrastructure the collector could be a meter itself. Its primary function is to interface between the HES and the meters and/or other collectors within its neighbourhood – the neighbourhood area network (NAN).<br />
Not only the head-end but also the collector exposes threats. The collector is physically exposed to adversaries. Moreover, it has a trust binding to the HES and the NAN side and is thus privileged to communicate with either end. Adversaries might exploit the fact in order to attack the HES. Additionally, on the NAN side, adversaries might impersonate the collector to setup a man-in-the-middle scenario or to invoke arbitrary commands at the meters.</p>
<p><strong>Meter</strong><br />
The meter is installed at consumer premises. When integrated with a collector, it directly communicates to the HES. As a meter it either communicates with the collector or may serve as a relay in order to route packets between nearby meters and the collector. Some meters provide an interface for appliances. With retail consumer that network is known as the home area network (HAN). Meters do also provide local diagnostic ports for manual readout, installation and maintenance tasks as shown in figure 2.<br />
From an attackers perspective the meter is the entry point to building automation, DER and usage data. But the meter is also a relevant part of the smart grid and under no circumstances should its manipulation allow critical influence or affect the availability of the grid or parts of it.</p>
<p><strong>Communication</strong><br />
The infrastructure consist of several networks of which all could rely on absolutely different media and a multitude of protocols. In total, three networks are commonly described when referring to the AMI. The WAN, NAN and HAN.</p>
<p><em><strong>Wide Area Network</strong></em><br />
The WAN does connect a meter or collector to the HES. The WAN is sometimes also referred to as the backhaul network. Communication on the WAN link is mostly Internet protocol (IP) based and does commonly rely on standard information technology (IT) media and technology stacks such as fibre optic cables (FOC), digital subscriber line (DSL), general packet radio service (GPRS), multi-protocol label switching (MPLS), power line carrier (PLC) or some sort of private network. A brief overview on PLC for WAN side communication is provided in [1]<br />
The CEN/CENELEC/ ETSI Smart Meter Co-ordination Group (SMCG) does not identify a specific protocol but proposes to rely on “secure and non proprietary protocols and communication platforms” [2] for bulk transmission from collectors that bundle a large number of meters.</p>
<p><em><strong>Neighbourhood Area Network</strong></em><br />
The NAN connects meters and collectors. Typical NAN devices are electricity, gas, water or heat meters. organisations sometimes refer to the NAN as local metrological network (LMS) [3], field area network (FAN) [4] or the metering LAN [5].<br />
Although standards such as the IEEE 802.15.4 [6], [7] based ZigBee profiles are gaining momentum, the industry and regulators seam to struggle on a common standard. Utilities among the European union nations seem to prefer the meter bus standard for NAN communication [3] although the ENISA does not list [4] the meter bus as a NAN protocol.</p>
<p><em><strong>Home Area Network</strong></em><br />
Depending on the consumer type the HAN could also be named as building area network (BAN) or industrial area network (IAN). Whatever its name is, the purpose of the HAN is to integrate additional gas, water or heat meters. The HAN could allow for intelligent building automation and does also allow the integration of DERs with the smart grid.</p>
<p><img src="http://blog.csnc.ch/wp-content/uploads/2013/02/home_area_network.png" alt="" width="550" height="290" /></p>
<p>Figure 2: Home Area Network and Local Bus Blueprint</p>
<p>To optimize consumption during peak hours a utility might for example decide not to entirely turn off but to throttle large heating, ventilation, and air conditioning (HVAC) appliances to balance the grid. For that purpose, consumers will be required to grant utilities or a third-party supplier access to their appliances. However, intelligent control does not necessarily require the intervention of an external part. Thus, an intelligent HVAC might decide to throttle automatically based on the real-time pricing information provided by the utility.<br />
Meters in the US largely focus on ZigBee for HAN communication [8]. Profiles for home automation and smart energy are specified in [9], [10]. The Europe based open metering system (OMS) group is pushing a specification that relies on M‑Bus whereby the wireless M‑Bus stack is compatible with the KNX specifications [11]. KNX is very popular in home automation.</p>
<p><strong>Local Bus</strong><br />
Common interfaces for diagnostic purposes are provided as two or three-wire serial lines, current loop or as an optical interface [12], [13].</p>
<p><strong>References</strong><br />
[1] M. Rafiei and S. M. Eftekhari, A practical smart metering using combination of power line communication (PLC) and WiFi protocols, In Proceedings of 17th Conference on Electrical Power Distribution Networks (EPDC), 2012, pp. 1–5, May 2012<br />
[2] Smart Meters Co-Ordination Group. Standardization mandate to CEN, CENELEC and ETSI in the field of measuring instruments for the development of an open architecture for utility meters involving communication protocols enabling interoperability M/441: Final Report v0.7. Dec. 2009<br />
[3] Federal Office for Information Security (BSI) Germany. Technische Richtlinie BSI-TR-03109-1: Anforderungen an die Interoperabilität der Kommunikationseinheit eines intelligenten Messsystems, v0.5. 2012<br />
[4] ENISA. Smart Grid Security: Annex I. General Concepts and Dependencies with ICT. 2012<br />
[5] EN 13575-1:2002: Communication system for meters and remote reading of meters &#8211; Part 1: Data exchange<br />
[6] IEEE Std 802.15.4:2011. IEEE Standard for Local and metropolitan area networks &#8211; Part 15.4: Low-Rate Wireless Personal Area Networks (LR-WPANs)<br />
[7] C. Bennet and D. Highfill. Networking AMI Smart Meters. In Proceedings of Energy 2030 Conference, 2008. ENERGY 2008. IEEE. pp 1-8. Nov. 2008 (DOI 10.1109/ENERGY.2008.4781067)<br />
[8] V. Aravinthan, V. Namboodiri, S. Sunku and W. Jewell. Wireless AMI Application and Security for Controlled Home Area Networks. In Proceedings of Power and Energy Society General Meeting, 2011 IEEE. pp. 1-8. Jul. 2011 (DOI 10.1109/PES.2011.6038996)<br />
[9] ZigBee Alliance. Home Automation Public Application Profile. ZigBee Profile: 0&#215;0104 Revision 26, Version 1.1, Feb. 2010<br />
[10] ZigBee Alliance. Smart Energy Profile Specification. ZigBee Profile: 0&#215;0109, Revision 16, Version 1.1, Mar. 2011<br />
[11] EN50090-4-1:2004. Home and Building Electronic Systems (HBES) Part 4-1: Media independent layers &#8211; Application layer for HBES Class 1<br />
[12] EN 13575-6:2008: Communication system for meters and remote reading of meters &#8211; Part 6: Local Bus<br />
[13] EN 62056-21:2002, Electricity metering &#8211; Data exchange for meter reading, tariff and load control &#8211; Part 21: Direct local data exchange</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.csnc.ch/2013/02/advanced-metering-infrastructure-architecture-and-components/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Metering Infrastructure</title>
		<link>http://blog.csnc.ch/2013/02/the-metering-infrastructure/</link>
		<comments>http://blog.csnc.ch/2013/02/the-metering-infrastructure/#comments</comments>
		<pubDate>Wed, 20 Feb 2013 07:11:00 +0000</pubDate>
		<dc:creator>Cyrill Brunschwiler</dc:creator>
				<category><![CDATA[Industrial Control Systems]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[advanced metering infrastructure]]></category>
		<category><![CDATA[ami]]></category>
		<category><![CDATA[AMR]]></category>
		<category><![CDATA[CEN]]></category>
		<category><![CDATA[CENELEC]]></category>
		<category><![CDATA[DER]]></category>
		<category><![CDATA[distributed energy resources]]></category>
		<category><![CDATA[enisa]]></category>
		<category><![CDATA[ETSI]]></category>
		<category><![CDATA[security standards]]></category>
		<category><![CDATA[smart grid security]]></category>

		<guid isPermaLink="false">http://blog.csnc.ch/?p=954</guid>
		<description><![CDATA[I have provided introductions to the electrical and specifically the smart grid earlier on. Today I will briefly introduce the advanced metering infrastructure &#8211; its purpose, benefits and issues. Moreover, different approaches to metering and some ongoing security standards and &#8230; <a href="http://blog.csnc.ch/2013/02/the-metering-infrastructure/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I have provided introductions to the electrical and specifically the smart grid earlier on. Today I will briefly introduce the advanced metering infrastructure &#8211; its purpose, benefits and issues. Moreover, different approaches to metering and some ongoing security standards and specifications processes and organizations will be referenced.</p>
<p><strong>Purpose of Smart Meters<br />
</strong>The reason for smart meters is to enable the operators to improve their infrastructure towards a smarter grid and its six characteristics outlined. A smart meter has several advantages over a traditional mechanical meter. A smart meter does lots more [1], [2] than just providing detailed power consumption data to the operator. Primarily, a smart meter can significantly support the distribution system operator (DSO) to balance the network load and improve reliability.</p>
<p>Thus, a smart meter does not only lower manual reading cost but also enables to more efficiently estimate the load on the generators. It helps to more efficiently integrate distributed energy resources (DER) and helps to monitor the distribution network in order to identify power quality (PQ) issues, misrouted energy flows or fire alerts in case a consumer outage is being detected. Moreover, a meter could be used to push real-time pricing information to the consumer in order to allow appliances in the local network to optimize their power consumption according to the current rates. During an emergency, a meter could allow to disconnect consumers from the power grid. A meter could limit the consumption to a specified amount or could enforce pre-payment for defaulting consumers.</p>
<p>Yet, at time of writing, the effective use cases implemented heavily differ from operator to operator. Whereby all of them support at least remote meter reading. However, a security analysis should take all potential use cases into consideration since it is likely that firmware and hardware is being enhanced to support additional use cases in the near future.</p>
<p><strong>Meter Reading vs. Metering Infrastructure<br />
</strong>Typically, literature differs between advanced meter reading (AMR) and the advanced metering infrastructure (AMI) whereby AMR is to be seen as a subset of AMI [3].<br />
AMR provides the metering company with usage data only. AMR does not allow for remote controlled action or advanced collection of power information. Thus, one-way communication from meter to the metering company is sufficient for that approach.<br />
AMI will allow for remote initiated actions and will therefore require a two-way communication protocol. Though the border between the two approaches fades since remote initiated reading will also require for a two-way channel in AMR setups.</p>
<p><strong>North American vs. European Implementations<br />
</strong>The US as well as the European countries have developed absolutely independent implementations of the AMI. Nevertheless, the key drivers and business needs are exactly the same. Comparing the two, the preferred communication protocols in either continent are not compatible with each other.<br />
The National Institute of Standards and Technology (NIST) and European Network and Information Security Agency (ENISA) respectively the European Committee for Standardization, the European Committee for Electrotechnical Standardization and the European Telecommunications Standards Institute (CEN/CENELEC/ETSI) mandated by the European Commission drive very similar projects to provide security guidance [4], [5] for smart grid and metering implementations. However, the guidance neither specifically requests for nor does it recommend the use of specific protocols.</p>
<p><strong>References<br />
</strong>[1] G. N. Sorebo and M. C. Echols. Smart Grid Security: An End-to-End View of Security in the New Electrical Grid. CRC Press. 2011 (ISBN 978-1-4398-5587-4)<br />
[2] ENISA. Smart Grid Security: Annex I. General Concepts and Dependencies with ICT. 2012<br />
[3] E.D. Knapp. Industrial Network Protocols, AMI and the Smart Grid. In Industrial Network Security: Securing Critical Infrastructure Networks for Smart Grid, SCADA, and Other Industrial Control Systems. Syngress. 2011 (ISBN 978-1-59749-645-2)<br />
[4] NIST. Security Profile for Advanced Metering Infrastructure. v2.0, Jun. 2010<br />
[5] ENISA. Smart Grid Security: Recommendations for Europe and Member States. Jul. 2012</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.csnc.ch/2013/02/the-metering-infrastructure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compass Security eröffnet Niederlassung in Berlin</title>
		<link>http://blog.csnc.ch/2013/02/compass-security-eroffnet-niederlassung-in-berlin/</link>
		<comments>http://blog.csnc.ch/2013/02/compass-security-eroffnet-niederlassung-in-berlin/#comments</comments>
		<pubDate>Wed, 06 Feb 2013 16:21:25 +0000</pubDate>
		<dc:creator>Ivan Buetler</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.csnc.ch/?p=941</guid>
		<description><![CDATA[Die Compass Security AG unternimmt die nächsten Wachstumsschritte auf europäischer Ebene. Unter der Firmierung Compass Security Deutschland GmbH (www.csnc.de) hat das Team rund um Marco Di Filippo (bisher Regional Director Germany) am 01. Januar 2013 ihre Arbeit in Berlin aufgenommen. &#8230; <a href="http://blog.csnc.ch/2013/02/compass-security-eroffnet-niederlassung-in-berlin/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Die Compass Security AG unternimmt die nächsten <em><strong>Wachstumsschritte</strong> </em>auf europäischer Ebene. Unter der Firmierung <em><strong>Compass Security Deutschland GmbH</strong></em> (www.csnc.de) hat das Team rund um Marco Di Filippo (bisher Regional Director Germany) am 01. Januar 2013 ihre Arbeit in Berlin aufgenommen.</p>
<p><a href="http://blog.csnc.ch/wp-content/uploads/2013/02/berlin.png"><img class="alignnone size-full wp-image-946" title="berlin" src="http://blog.csnc.ch/wp-content/uploads/2013/02/berlin.png" alt="" width="764" height="567" /></a></p>
<p>Die hohe Nachfrage aus dem Raum Deutschland veranlasste die Compass Security AG, ihre Aktivitäten sowie die Kundennähe vor Ort weiter zu verstärken. Unter der <em><strong>Geschäftsführung von Marco Di Filippo und Walter Sprenger</strong></em> liegt das Kerngeschäft der deutschen Dependance nach dem Vorbild der Muttergesellschaft darin, Unternehmen im Dienste der ICT-Sicherheit rund um Präventions- und Schutzmassnahmen für deren technologische Infrastruktur zu unterstützen.</p>
<p>Dies ist der erste Schritt der<em><strong> Compass Expansions Strategie</strong></em>, welche durch die Erschliessung von neuen Märkten bei gleichbleibendem Service Portfolio definiert wird. Die Compass Security will weltweit an Kundennähe gewinnen und sich bei internationalen Projekten profilieren.</p>
<p><strong>Kontakt Berlin</strong><br />
Compass Security Deutschland GmbH<br />
Tauentzienstrasse 18<br />
DE-10789 Berlin</p>
<p>Tel. +49 (0)30 2100253-0<br />
Fax + 49 (0)30 2100253-69</p>
<p>www.csnc.de<br />
team@csnc.de</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.csnc.ch/2013/02/compass-security-eroffnet-niederlassung-in-berlin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why does Compass Security recommend HSTS?</title>
		<link>http://blog.csnc.ch/2013/02/why-does-compass-security-recommend-hsts/</link>
		<comments>http://blog.csnc.ch/2013/02/why-does-compass-security-recommend-hsts/#comments</comments>
		<pubDate>Mon, 04 Feb 2013 08:08:02 +0000</pubDate>
		<dc:creator>Stephan Rickauer</dc:creator>
				<category><![CDATA[Hardening]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Web Application]]></category>
		<category><![CDATA[Web Server]]></category>
		<category><![CDATA[HSTS]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[SSLstrip]]></category>
		<category><![CDATA[strict transport]]></category>

		<guid isPermaLink="false">http://blog.csnc.ch/?p=931</guid>
		<description><![CDATA[Secure web communications using HTTPS isn&#8217;t anything fancy anymore these days. It ensures traffic from a user to your web application cannot be eavesdropped or tampered with, given it has been set up securely using SSL/TLS. But, do you trust &#8230; <a href="http://blog.csnc.ch/2013/02/why-does-compass-security-recommend-hsts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Secure web communications using HTTPS isn&#8217;t anything fancy anymore these days. It ensures traffic from a user to your web application cannot be eavesdropped or tampered with, given it has been set up securely using SSL/TLS. But, do you trust your web application&#8217;s code to entirely disregard unencrypted requests? Are you sure your Apache/IIS is configured properly to redirect http to https all the time? How can you be sure your users, which never bother typing in explicitly the https:// part of your URL, won&#8217;t be affected by the SSLstrip attack?</p>
<p>Well, sometimes you may be pretty confident about your server configuration &#8211; but there are certainly occasions where you simply can&#8217;t. So, wouldn&#8217;t it be great if the user&#8217;s browser could be told to refuse unencrypted channels for a domain at all? And even remember that decision for a defined time span?<br />
This is where HSTS comes into play. That acronym stands for &#8220;HTTP Strict Transport Security&#8221; and defines a fairly new HTTP response header that forces a user agent to solely interact with the server using HTTPS. It has been officially approved by IESG on 2nd October 2012 and is specified in RFC 6797. Let&#8217;s have a look at it:</p>
<pre>Strict-Transport-Security: max-age=2628000</pre>
<p>That response header causes a modern browser with HSTS support to never ever interact with the server in an unencrypted way for one month. So, in case your web application accidentally issues a non-https redirect (or anything else happens that would cause a non-https connection – e.g. a JavaScript or CSS resource loaded over http from the same domain), the user&#8217;s browser would simply use https instead. This web security policy mechanism can be enhanced by specifying the optional subdomains flag. That way, and not very surprisingly, all accordant sub domains are also put into the HSTS scope:</p>
<pre>Strict-Transport-Security: max-age=2628000; includeSubDomains</pre>
<p>Setting the max-age value to a month is the default recommendation, but this parameter should take the common usage pattern of your website into account. If your users connect themselves only once a month, you might want to extend the max-age period to avoid having the HSTS value expire.</p>
<p><strong>Downsides? Sure.</strong></p>
<p>The very initial request to a HSTS web site may still be http and thus exposed to a standard Man-In-The-Middle attack (Bootstrap MITM). In that phase, an attacker could tamper with the HSTS response header and inject invalid subdomains (DoS), disable HSTS (set max-age to 0) or poison the HSTS cache of the user agent otherwise. However, wrongly stored HSTS policies can be simply removed by clearing the local browser cache.</p>
<p>Another downside is rather an organizational one: once you have pushed an HSTS policy to your clients, you are no longer as free to switch back to non-https connections, of course. Their browser is configured to ignore http for the time span you have defined. Simple fix: Push a temporary policy with &#8216;max-age=0&#8242; to disable it again. Also, the process of keeping your certificates valid must be properly implemented. With HSTS, there is zero tolerance for problems with respect to SSL certificates as the user is no longer able to bypass SSL warnings and &#8220;click through&#8221;.</p>
<p><strong>Use it? Yes!</strong></p>
<p>The advantages of HSTS clearly outweigh its downsides. It even defeats some issues it wasn&#8217;t planned for: HSTS helps in fixing mixed-content issues, defends against the cookie value being sent in plain text (in case you don&#8217;t set its &#8216;secure&#8217; flag), and it may even reduce network latency by saving superfluous http-to-https redirects. Unfortunately, not all browsers support it yet, most prominently Internet Explorer. However, given HSTS was just officially approved, Microsoft will probably need to introduce it soon.</p>
<p>References:</p>
<ul>
<li><a title="http://tools.ietf.org/html/rfc6797" href="http://tools.ietf.org/html/rfc6797" target="_blank">http://tools.ietf.org/html/rfc6797</a></li>
<li><a title="http://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security" href="http://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security" target="_blank">http://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security</a></li>
<li><a title="https://wiki.mozilla.org/WebAppSec/MozSecureWorld" href="https://wiki.mozilla.org/WebAppSec/MozSecureWorld" target="_blank">https://wiki.mozilla.org/WebAppSec/MozSecureWorld</a></li>
<li><a title="https://www.blackhat.com/presentations/bh-dc-09/Marlinspike/BlackHat-DC-09-Marlinspike-Defeating-SSL.pdf" href="https://www.blackhat.com/presentations/bh-dc-09/Marlinspike/BlackHat-DC-09-Marlinspike-Defeating-SSL.pdf" target="_blank">https://www.blackhat.com/presentations/bh-dc-09/Marlinspike/BlackHat-DC-09-Marlinspike-Defeating-SSL.pdf</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.csnc.ch/2013/02/why-does-compass-security-recommend-hsts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grid, gridder, smart grid</title>
		<link>http://blog.csnc.ch/2013/01/grid-gridder-smart-grid/</link>
		<comments>http://blog.csnc.ch/2013/01/grid-gridder-smart-grid/#comments</comments>
		<pubDate>Mon, 28 Jan 2013 05:30:09 +0000</pubDate>
		<dc:creator>Cyrill Brunschwiler</dc:creator>
				<category><![CDATA[Industrial Control Systems]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[advanced metering infrastructure]]></category>
		<category><![CDATA[ami]]></category>
		<category><![CDATA[doe]]></category>
		<category><![CDATA[electrical grid]]></category>
		<category><![CDATA[enisa]]></category>
		<category><![CDATA[ics]]></category>
		<category><![CDATA[nerc]]></category>
		<category><![CDATA[scada]]></category>
		<category><![CDATA[smart grid]]></category>

		<guid isPermaLink="false">http://blog.csnc.ch/?p=924</guid>
		<description><![CDATA[This post will briefly introduce the major aspects and goals of smart grids. For those not familiar with electrical grids, have a look at the former post for a quick intro. This article aims to describe the challenges and requirements &#8230; <a href="http://blog.csnc.ch/2013/01/grid-gridder-smart-grid/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>This post will briefly introduce the major aspects and goals of smart grids. For those not familiar with electrical grids, have a look at the <a href="http://blog.csnc.ch/2013/01/introduction-to-the-electrical-grid/" target="_self">former post</a> for a quick intro. This article aims to describe the challenges and requirements smart grids are dealing with. Moreover, the need for an intelligent measurement network – the advances metering infrastructure (AMI) will be outlined</p>
<p>Some electricity industry body defines the smart grid as follows: <em>“A Smart Grid is an electricity network that can intelligently integrate the behaviour and actions of all users connected to it -generators, consumers and those that do both – in order to efficiently ensure sustainable, economic and secure electricity supply. ”</em> [1]. The definition clearly refers to the challenging dynamics of renewable energy resources (RES) whose generation heavily relies on the fluctuate availability of sun light, wind or maybe tides. Unfortunately, it less clearly addresses changes in behavior whereby the smart grid should not only be capable to react on actions but should also directly or indirectly influence consumption behavior.</p>
<p>There have been six major characteristics [2, 3] identified. These characteristics describe the key benefits of a smart grid. The reference even provides additional detail on the characteristics:</p>
<div>
<ol>
<li><em>“Enables Informed Participation by Customers </em></li>
<li><em>Accommodate s All Generation &amp; Storage Options </em></li>
<li><em>Enables New Products, Services, &amp; Markets </em></li>
<li><em>Provides Power Quality for the Range of Needs </em></li>
<li><em>Optimizes Asset Utilization &amp; Operating Efficiency </em></li>
<li><em>Operates Resiliently to Disturbances, Attacks, &amp; Natural Disasters ”</em></li>
</ol>
</div>
<div>
<p>The upper halve of the characteristics is probably the most interesting from a retail customers view. However, the thesis I am currently working on will map to the part “Operates Resiliently to Disturbances, Attacks” of item six.</p>
<p>For the smart grid the basic electrical grid in the <a href="http://blog.csnc.ch/2013/01/introduction-to-the-electrical-grid/" target="_self">former post</a> is enriched with new elements. The basic domain structure persists but an additional domain hosting distributed generators and distributed storage devices have been added to the smart grid blue print shown in the below figure.</p>
<p>The newly introduced domain hosts all sort of distributed energy resources (DER) such as generators and storages. The blueprint introduces a small wind park which contributes to the distribution domain and a PV installation with rechargeable batteries as buffer storage, Moreover, a freezer and an electrical vehicle (EV) were added to the consumer domain. Actually, the EV is not only a consumer but may also contribute to the grid as a storage in peak times. Its not the single items which are challenging for the grid but its the masses which require for more &#8216;smartness&#8217;. Small systems could also be grouped and centrally managed as a combined power plant to form a steady power resource. A more detailed view on improvements in the transmission and distribution domains with focus on security is given in [4].</p>
<p><img src="http://blog.csnc.ch/wp-content/uploads/2013/01/smart_grid.png" alt="Smart Grid Security" width="570" height="413" /></p>
<p>Thus, to ensure reliability of the grid the DSO and TSO must ensure that the power consumed and the power generated stays balanced otherwise efficiency and power quality (PQ) suffer. Unfortunately, poor PQ may quickly result in damaged consumer devices. To avoid such scenario, live information and detailed statistics of the consumer behavior, of generators capacity and of storage capacity is needed. Moreover, the operator will need to smartly attach or detach generators and consumer devices (EV) to their local storage or to the grid according to the power needs. The management of the grid balance is also known as demand-response. As good it sounds, management of so many components is much more complex and the recovery of a failure will demand for a controlled re-launch of DERs and bulk generators simultaneously at both ends of the grid. Additionally, dynamic-pricing or real-time pricing (RTP) or critical peak pricing (CPP) could help to reduce peak loads and would result in lower demand-response efforts. For real-time pricing, consumers will be kept informed on the current power rates. Consumers could then decide on whether to run heavy loads at the current pricing.</p>
<p>Hence, reporting consumption and switching loads will require a bi-directional channel being established between operator and consumer. The channel would then allow for delivery of detailed measurement from the consumer and DG side to the operators. Furthermore, it would enable the operator to actively manage DER and to push real-time information to the consumer facilities. The equipment and network necessary is known as the advanced metering infrastructure (AMI). I will provide a closer look to the AMI in upcoming posts. Stay tuned.</p>
<p>In order to securely operate smart grids, NERC (North American Electricity Reliability Corporation) and ENISA (European Network and Informations Security Agency) have prepared appropriate recommendations [5,6].</p>
<p>[1] EURELECTRIC, Smart Grids and Networks of the Future, 201, http://www.eurelectric.org/Download/Download.aspx?DocumentID=26620<br />
[2] U.S. Department of Energy (DOE), 2009 Smart Grid System Report, 2009, http://www.doe.gov/sites/prod/files/2009%20Smart%20Grid%20System%20Report.pdf<br />
[3] U.S. Department of Energy (DOE), 2010 Smart Grid System Report, 2012, http://www.doe.gov/sites/prod/files/2010%20Smart%20Grid%20System%20Report.pdf<br />
[4] G. N. Sorebo and M. C. Echols, Smart Grid Security: An End-to-End View of Security in the New Electrical Grid, CRC Press, 2011, ISBN 978-1-4398-5587-4<br />
[5] NERC Reliability Standards, http://www.nerc.com/page.php?cid=2%7C20<br />
[6] ENISA Smart Grid Security Recommendations, http://www.enisa.europa.eu/activities/Resilience-and-CIIP/critical-infrastructure-and-services/smart-grids-and-smart-metering/ENISA-smart-grid-security-recommendations</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.csnc.ch/2013/01/grid-gridder-smart-grid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Impact of IIS 7.5 Service Accounts for file system audits</title>
		<link>http://blog.csnc.ch/2013/01/iis-7-5-service-accounts-file-system-audits/</link>
		<comments>http://blog.csnc.ch/2013/01/iis-7-5-service-accounts-file-system-audits/#comments</comments>
		<pubDate>Mon, 21 Jan 2013 06:30:19 +0000</pubDate>
		<dc:creator>Thomas Röthlisberger</dc:creator>
				<category><![CDATA[Hardening]]></category>
		<category><![CDATA[Web Server]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[hardening]]></category>
		<category><![CDATA[IIS 6]]></category>
		<category><![CDATA[IIS 7]]></category>
		<category><![CDATA[Service Account]]></category>

		<guid isPermaLink="false">http://blog.csnc.ch/?p=771</guid>
		<description><![CDATA[Introduction It can be very tricky to analyze the relevant service account and its file system permissions in order to evaluate if a compromised ASP.NET application can access sensitive resources (file system / network / processes) on the web server. &#8230; <a href="http://blog.csnc.ch/2013/01/iis-7-5-service-accounts-file-system-audits/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h2>Introduction</h2>
<p>It can be very tricky to analyze the relevant service account and its file system permissions in order to evaluate if a compromised ASP.NET application can access sensitive resources (file system / network / processes) on the web server. Especially from IIS 6 to IIS 7.5 there is quite a big change in how the service accounts are isolated on IIS.</p>
<h2>Contents</h2>
<p>Many different factors influence under which identity an IIS Worker Process runs. All the following settings need to be evaluated in order to be able make a clear statement which service account(s) are relevant.</p>
<h3><strong>Check IIS Application Pool Identity</strong></h3>
<ol>
<li>LocalService or LocalSystem<br />
<em><em><em>(Should obviously not be choosen at all, since they are high privileged built-in system accounts)</em></em></em></li>
<li>NetworkService<br />
<em>(Built-In service account with least privileges designed for low trusted network services like a web application. It was best practice to use this account prior to IIS6 or 7. Problem is that the web application shares the process memory and file access permissions with all the other services using the NETWORK SERVICE account. This causes </em><em>insufficient </em><em><em><em>application isolation.)</em></em></em></li>
<li>ApplicationPoolIdentity <em><br />
(New and better application isolation with IIS 7.5: A &#8220;virtual&#8221; account is generated automatically with the name of the application pool, e.g. &#8220;</em><em>IIS AppPool \ DefaultAppPool &#8221; or </em> <em>IIS &#8221; AppPool \ XSSViewStateUser &#8221; and cannot be seen in the Users and Group Configuration Dialog. You need to specify exact user name in the FilePermission Dialog to give this account permission on a certain folder. Using this option, no custom service accounts need to be configured anymore for the application pools since IIS handles them automatically. This provides a maximum</em> <em>isolation</em> <em>of</em> <em>applications.)</em></li>
</ol>
<h3><strong>Check IIS Anonymous Authentication Identity</strong></h3>
<ol>
<li>IUSR<br />
<em>(</em> <em>Built-In account with least privileges designed to provide file system access for anonymous users of web applications.</em> <em><em><em>)</em></em></em></li>
<li>ApplicationPoolIdentity<br />
<em>(The &#8220;virtual&#8221; account</em><em> configured as the Application Pool Identity.</em> <strong><em>&#8211;&gt; Check IIS Application Pool Identity</em></strong> <em>)</em></li>
</ol>
<h3><strong>Check ASP.NET Authentication Scheme</strong></h3>
<ol>
<li>&lt;authentication mode=&#8221;<strong>Windows</strong>&#8221; /&gt;&lt;identity impersonate=&#8221;<strong>false</strong>&#8221; /&gt;<em><br />
</em><em>(With Windows authentication but without impersonation, ASP.NET will run as the Application Pool Identity and needs <strong><span style="color: #ff0000;">read and write</span></strong> access, depending on the application</em><em>.<span style="color: #ff0000;"><strong> &#8211;&gt; Check IIS Application Pool Identity</strong></span></em><em><br />
but as well needs the </em> <em><em>IIS-authenticated caller <strong><span style="color: #ff6600;">read </span></strong>access <span style="color: #ff6600;"><strong>&#8211;&gt; Check IIS Anonymous Authentication Identity</strong><span style="color: #000000;"><em>)</em></span></span></em></em></li>
<li>&lt;authentication mode=&#8221;<strong>Windows</strong>&#8221; /&gt;&lt;identity impersonate=&#8221;<strong>true</strong>&#8221; /&gt;<br />
<em>(With Windows authentication and impersonation, ASP.NET runs as the IIS-authenticated caller and needs <span style="color: #ff0000;"><strong>read and write</strong></span> access, depending on the application. <strong><span style="color: #ff0000;">&#8211;&gt; Check IIS Anonymous Authentication Identity</span><br />
</strong>but as well needs the Application Pool Identity <span style="color: #ff6600;"><strong>read </strong></span>access <span style="color: #ff6600;"><strong>&#8211;&gt; Check IIS Application Pool Identity </strong></span>)<br />
(Attention, In IIS 7 you need to consider the fact that impersonation can only be used with the &#8220;Classic Managed Pipeline Mode&#8221; and not the &#8220;Integrated Managed Pipeline Mode&#8221; mode. Second is the default)</em></li>
<li>&lt;authentication mode=&#8221;<strong>None</strong>&#8221; /&gt; or &lt;authentication mode=&#8221;<strong>Forms</strong>&#8221; /&gt;<br />
<em>(Without</em><em> Windows authentication, ASP.NET runs as the </em> <em>as the Application Pool Identity</em> <em>.</em> <span style="color: #008000;"><strong><em>&#8211;&gt; Check IIS Application Pool Identity</em></strong></span> )</li>
</ol>
<p><span id="more-771"></span></p>
<h3><strong>Verify Identity of the IIS Worker Process in the TaskManager </strong></h3>
<p>You could as well check the worker process identity in the task manager. The relevant process to check is <strong>w3wp.exe</strong> <strong>&#8220;IIS Worker Process&#8221;</strong>. This means that the User under which this process currently runs is the one which needs all the access the ASP.NET application needs. But in order to run the application it might be necessary, dependent on the settings above, that another account needs read access to the web folder as well.</p>
<h3><strong>Check Identity of the IIS Root Process in the Services</strong></h3>
<p>The relevant service to check for the IIS root process is <strong>W3SVC &#8220;World Wide Web Publishing Service</strong><strong>&#8220;</strong>. This means that the port binding and <strong>writing the logs</strong> (W3C) is with the <strong>LOCAL SYSTEM </strong>account.</p>
<h2>Examples</h2>
<p>The following are the most common scenarios in the Internet area whereas no impersonation is used and Forms or None ASP.NET authentication is used.</p>
<h3><strong>First Scenario with Forms authentication<br />
</strong></h3>
<ul>
<li>IIS Application Pool Identity = <strong>NetworkService</strong></li>
<li>IIS Authentication Identity = <strong>IUSR</strong></li>
<li>ASP.NET Authentication Scheme = <strong>Forms or None</strong></li>
</ul>
<p>==&gt; Result: The account <strong><span style="color: #008000;">NetworkService </span></strong>needs all the access the application needs. Whereas the <em>IUSR </em>does not need access at all.</p>
<h3><strong>Second Scenario</strong> <strong>with Forms authentication</strong></h3>
<ul>
<li>IIS Application Pool Identity = <strong>ApplicationPoolIdentity</strong></li>
<li>IIS Authentication Identity = <strong>IUSR</strong> or <strong>ApplicationPoolIdentity<br />
</strong></li>
<li>ASP.NET Authentication Scheme = <strong>Forms or None</strong></li>
</ul>
<p>==&gt; Result: The account <span style="color: #008000;"><strong>IIS AppPool \&lt;Name of Application Pool&gt;</strong></span> needs all the access the application needs. Whereas the <em>IUSR </em>or <em>NetworkService</em>do not need access at all.</p>
<h3><strong>First Scenario with Windows authentication<br />
</strong></h3>
<ul>
<li>IIS Application Pool Identity = <strong>NetworkService</strong></li>
<li>IIS Authentication Identity = <strong>IUSR</strong></li>
<li>ASP.NET Authentication Scheme = <strong>Windows with Impersonation</strong></li>
</ul>
<p>==&gt; Result: The account <span style="color: #008000;"><strong>IUSR</strong> </span>needs all the access the application needs. Whereas the <span style="color: #008000;"><strong>NetworkService</strong> </span>does only need read access on the web application folder.</p>
<h3><strong>Second Scenario with Windows authentication<br />
</strong></h3>
<ul>
<li>IIS Application Pool Identity = <strong>NetworkService</strong></li>
<li>IIS Authentication Identity = <strong>IUSR</strong></li>
<li>ASP.NET Authentication Scheme = <strong>Windows without Impersonation</strong></li>
</ul>
<p>==&gt; Result: The account <strong><span style="color: #008000;">NetworkService </span></strong>needs all the access the application needs. Whereas the <strong><span style="color: #008000;">IUSR </span></strong>does only need read access on the web application folder.</p>
<h3><strong>third Scenario </strong><strong>with Windows authentication<br />
</strong></h3>
<ul>
<li>IIS Application Pool Identity = <strong>ApplicationPoolIdentity</strong></li>
<li>IIS Authentication Identity = <strong>IUSR</strong></li>
<li>ASP.NET Authentication Scheme = <strong>Windows without Impersonation</strong></li>
</ul>
<p>==&gt; Result: The account <span style="color: #008000;"><strong>IIS AppPool \&lt;Name of Application Pool&gt;</strong></span> needs all the access the application needs. Whereas the <span style="color: #008000;"><strong>IUSR</strong> </span>does only need read access on the web application folder.</p>
<h3><strong>fourth Scenario </strong><strong>with Windows authentication<br />
</strong></h3>
<ul>
<li>IIS Application Pool Identity = <strong>ApplicationPoolIdentity</strong></li>
<li>IIS Authentication Identity = <strong>ApplicationPoolIdentity</strong></li>
<li>ASP.NET Authentication Scheme = <strong>Windows without Impersonation</strong></li>
</ul>
<p>==&gt; Result: The account<span style="color: #008000;"> <strong>IIS AppPool \&lt;Name of Application Pool&gt;</strong></span> needs all the access the application needs. Whereas the <em>IUSR </em>does not need access at all.</p>
<h2>Conclusion</h2>
<p>When it comes to file system audits, you need to be aware of all the above options. However, when you deploy your own web application, it is recommended to rely on the ApplicationPoolIdentity whenever possible. This new feature has several security advantages:</p>
<ul>
<li>Dedicated memory space</li>
<li>ACLs can be set very specifically</li>
<li>No other dependencies</li>
<li>…</li>
</ul>
<h2>References</h2>
<ul>
<li><a href="http://learn.iis.net/page.aspx/140/understanding-built-in-user-and-group-accounts-in-iis/" target="_top">http://learn.iis.net/page.aspx/624/application-pool-identities/</a></li>
<li><a href="http://learn.iis.net/page.aspx/140/understanding-built-in-user-and-group-accounts-in-iis/" target="_top">http://learn.iis.net/page.aspx/140/understanding-built-in-user-and-group-accounts-in-iis/</a></li>
<li><a href="http://stackoverflow.com/questions/5729264/what-are-all-the-user-accounts-for-iis-asp-net-and-how-do-they-differ" target="_top">http://stackoverflow.com/questions/5729264/what-are-all-the-user-accounts-for-iis-asp-net-and-how-do-they-differ</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/ff649337.aspx" target="_top">http://msdn.microsoft.com/en-us/library/ff649337.aspx</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.csnc.ch/2013/01/iis-7-5-service-accounts-file-system-audits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to the Electrical Grid</title>
		<link>http://blog.csnc.ch/2013/01/introduction-to-the-electrical-grid/</link>
		<comments>http://blog.csnc.ch/2013/01/introduction-to-the-electrical-grid/#comments</comments>
		<pubDate>Mon, 14 Jan 2013 05:30:00 +0000</pubDate>
		<dc:creator>Cyrill Brunschwiler</dc:creator>
				<category><![CDATA[Industrial Control Systems]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[electrical grid]]></category>
		<category><![CDATA[enisa]]></category>
		<category><![CDATA[focp]]></category>
		<category><![CDATA[ics]]></category>
		<category><![CDATA[nerc]]></category>
		<category><![CDATA[scada]]></category>
		<category><![CDATA[smart grid]]></category>

		<guid isPermaLink="false">http://blog.csnc.ch/?p=914</guid>
		<description><![CDATA[When it comes to industrial control systems (ICS) specifically to supervisory control and data acquisition (SCADA) then a basic unterstanding of the business is crucial. In the curse of my master thesis I am currently digging into parts of the &#8230; <a href="http://blog.csnc.ch/2013/01/introduction-to-the-electrical-grid/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>When it comes to industrial control systems (ICS) specifically to supervisory control and data acquisition (SCADA) then a basic unterstanding of the business is crucial. In the curse of my master thesis I am currently digging into parts of the electrical grid and try to examine the issues and security level of some specific protocols. Thus, I will regularly keep you posted on grid aspects over the next two months</p>
<p>For a starter, this article shall give a short introduction into electrical grids in general. It aims to introduce general terms and to state the difference between the former electrical grid architecture and the smart grid. Additionally, paradigm changes and challenges [1] to the current grid will be pointed-out and the conclusion will include some reasoning for a more flexible architecture – the smart grid.</p>
<p>Electrical grids consist of power plants that create electricity from some form of energy. They consist of towers and poles that hold wires to transport the electricity and finally make it available to the consumer. The figure provides an overview how these facilities are logically grouped into four major electric grid domains. The domain concept is not entirely new and was similarly outlined in a description of cyber security on the essential parts of the smart grid [2].</p>
<p><img style="border: 0; vertical-align: baseline;" src="http://blog.csnc.ch/wp-content/uploads/2013/01/traditional_grid_underlay.png" alt="" width="550" height="385" /></p>
<p><strong>Generator domain; </strong>includes all sort of bulk power generation plants such as nuclear reactors, fossil fuel (coal or gas) plants as well as hydroelectricity plants. Typically, these are power plants that can continuously generate electricity of several hundred million watts (MW).</p>
<p><strong>Transmission domain; </strong>represents the long-distance transmission network components. This includes components such as large interconnection nodes, substations and of course, cables either mounted on towers or buried underground. Electrical lines at this domain normally work on very high voltage. The voltage for that size of transmissions networks is  several hundred of thousand volts (kV). Among Europe typically values are 230kV and 400kV. Traditionally, the domain is under control of the transmission system operator (TSO). In some countries a national body or a super body of utilities operates that domain.</p>
<p><strong>Distribution domain; </strong>provides the whole infrastructure to bring power to the end user (consumer). The domain also includes transformer equipment which is necessary to reduce the voltage as power is transported to the consumer. Bulk consumers typically get their power at higher voltages, for example 16kV, then common house holds for which 230 Volts and 400 Volts present common values. The domain is manged by the so-called distribution system operator (DSO).</p>
<p><strong>Consumer domain;</strong> groups all sort of consumers. The industries as well as household regardless of the amount of consumption and the consumer geographic location.</p>
<p>The four domain model gives a good introduction into the basic concept of an electrical grid but it does by no means appreciate the full detail of the electrical grid nor does it fully model the energy flow. Due to the liberalization of the power market the generation domain is not exclusively subject to large utilities anymore. For example, consumers may want to invest into renewable energy such as photo voltaic (PV) equipment in order to cover their own power consumption and to supply current out of surplus production to others. Thus, <em>&#8220;consumers are becoming producers or producing consumers &#8211; prosumers” </em>[3].</p>
<p>Comparable changes also apply to the distribution domain. Local utilities more frequently setup own facilities to generate power which will be feed-in directly at the distribution level at high voltages. Distributed generation (DG) is nothing new to grid operators and utilities as it was already discussed in literature [4] in 2001. The referenced book [4] does also introduce several forms of generators and does recognize the technical and financial impact of distributed generation to the grid. The reader will find information on combustion turbines, PV systems, micro turbines, fuel cells, combined heat and power as well as background information on grid operations with distributed generation and storage. However, security relevant aspects are not being discussed.</p>
<p>Since 2001 distributed power generation significantly emerged due to renewable energy got political attention and national funding [5]. These fundings do not only focus on large installations but also take small generators in home scale into account. Meanwhile, distributed generation has taken off and demands for advances in measurement and operations of the electrical grid. Only the introduction of additional information technology (IT) will allow to coordinate all generators, storages and consumers and thus to ensure efficiency and reliability of the grid.</p>
<p>A functional and reliable grid is evident for a country&#8217;s stability. Therefore, governments provide guidance in form of critical infrastructure protection (CIP) programmes [6,7] and in form of written recommendations [8,9] on how to securely operate the IT stuffed new generations of grids.</p>
<p><strong>References</strong><br />
<code>[1] European Commission, Energy Efficiency Plan, 2011<br />
[2] United States of America, H.R. 6582: American Energy Manufacturing Technical Corrections Act, 2012<br />
[3] P. Hasse, Smartmeter: A technological overview of the German roll-out, 29th Chaos Communication Congress, Online http://events.ccc.de/congress/2012/Fahrplan/events/5239.en.html, 2012<br />
[4] A. Borbely and J.F. Kreider, Distributed Generation: The Power Paradigm for the New Millenium, CRC Press, 2001, ISBN 0-8493-0074-6<br />
[5] European Commission for Energy, Financing Renewable Energy in the European Energy Market, 2011<br />
[6] North American Electric Reliability Corporation (NERC), http://www.nerc.com/<br />
[7] Federal Office for Civil Protection (FOCP), The Swiss Programm on Critical Infrastructure Protection, Nov 2010, Online http://www.bevoelkerungsschutz.admin.ch/internet/bs/en/home/themen/ski. parsysrelated1.82246.downloadList.18074.DownloadFile.tmp/factsheete.pdf<br />
[8] NIST Cyber Security Coordination Task Group, Security Profile for Advanced Metering Infrastructure, v2.0, June 2010<br />
[9] ENISA, Smart Grid Security: Recommendations for Europe and Member States, July 2012, Online http://www.enisa.europa.eu/activities/Resilience-and-CIIP/critical-infrastructure-and-services/smart-grids-and-smart-metering/ENISA-smart-grid-security-recommendations/at_download/fullReport</code></p>
<p>Note, this work is a preview version of an MSc Information Security dissertation in the fields of electrical grids.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.csnc.ch/2013/01/introduction-to-the-electrical-grid/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Risks of DOM Based XSS due to &#8220;unsafe&#8221; JavaScript functions</title>
		<link>http://blog.csnc.ch/2013/01/dom-based-xss-unsafe-javascript-functions/</link>
		<comments>http://blog.csnc.ch/2013/01/dom-based-xss-unsafe-javascript-functions/#comments</comments>
		<pubDate>Mon, 07 Jan 2013 06:30:58 +0000</pubDate>
		<dc:creator>Thomas Röthlisberger</dc:creator>
				<category><![CDATA[Vulnerability]]></category>
		<category><![CDATA[Web Application]]></category>
		<category><![CDATA[Cross-Site Scripting]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://blog.csnc.ch/?p=788</guid>
		<description><![CDATA[Introduction Several native JavaScript functions or properties like .eval() and .innerHTML as well as several jQuery functions like .html() and .append() are considered as &#8220;unsafe&#8221;, but why? The reason is that they allow DOM manipulation using strings containing HTML code &#8230; <a href="http://blog.csnc.ch/2013/01/dom-based-xss-unsafe-javascript-functions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h2>Introduction</h2>
<p>Several native JavaScript functions or properties like <span style="font-family: 'Courier New'; background: #FCE6D0;">.eval()</span> and <span style="font-family: 'Courier New'; background: #FCE6D0;">.innerHTML</span> as well as several jQuery functions like <span style="font-family: 'Courier New'; background: #FCE6D0;">.html()</span> and <span style="font-family: 'Courier New'; background: #FCE6D0;">.append()</span> are considered as &#8220;unsafe&#8221;, but why? The reason is that they allow DOM manipulation using strings containing HTML code (e.g.&#8221;<span style="font-family: 'Courier New'; background: #FCE6D0;"><strong>&lt;b&gt;</strong>This text is bold<strong>&lt;/b&gt;</strong></span>&#8220;), which can lead to DOM Based Cross-Site Scripting vulnerabilities. To be more specific: The usage of such functions is not a problem as long as no user input is directly embedded in an &#8220;unsafe&#8221; way. jQuery can help us to safely manipulate the DOM without executing XSS in user defined inputs. But do not by mistake assume jQuery is safe per se, it only provides us some helper function to manipulate the DOM more safely.</p>
<p>The subsequent sections show the difference between safe and unsafe usage of JavaScript and jQuery functions in the following scenarios:</p>
<ul>
<li><a href="#section1">Unsafe DOM manipulation using eval()</a></li>
<li><a href="#section2">Safe DOM manipulation using eval()</a></li>
<li><a href="#section3">Unsafe DOM manipulation using jQuery html()</a></li>
<li><a href="#section4">Safe DOM manipulation using </a><a href="#section3">jQuery </a><a href="#section4">html() and text()</a><a name="section1"></a></li>
</ul>
<h2>Unsafe DOM manipulation using eval():</h2>
<pre class="brush: javascript; gutter: false">var txtField = &quot;field1&quot;;
var txtUserInput = &quot;&#039;test@csnc.ch&#039;;alert(1);&quot;;
eval(
   &quot;document.forms[0].&quot; + txtField + &quot;.value =&quot; + txtUserInput
);</pre>
<p>The last double quote causes the user input to be treated as JavaScript. This results in the following JavaScript code being executed by <span style="font-family: 'Courier New'; background: #FCE6D0;">eval()</span>:</p>
<pre class="brush: javascript; gutter: false">document.forms[0].field1.value = &#039;test@csnc.ch&#039;;alert(1);</pre>
<p>Therefore the user input is executed:</p>
<p><a href="http://blog.csnc.ch/wp-content/uploads/2012/12/image001.png"><img class="alignnone size-full wp-image-805" title="image001" src="http://blog.csnc.ch/wp-content/uploads/2012/12/image001.png" alt="" width="398" height="264" /></a><br />
<a name="section2"></a></p>
<h2>Safe DOM manipulation using eval():</h2>
<pre class="brush: javascript; gutter: false">var txtField = &quot;field1&quot;;
var txtUserInput = &quot;&#039;test@csnc.ch&#039;;alert(1);&quot;;
eval(
   &quot;document.forms[0].&quot; + txtField + &quot;.value = txtUserInput&quot;
);</pre>
<p>The double quote at the end causes the user input NOT to be treated as JavaScript. This results in the following JavaScript code being executed by <span style="font-family: 'Courier New'; background: #FCE6D0;">eval()</span>:</p>
<pre class="brush: javascript; gutter: false">document.forms[0].field1.value = txtUserInput</pre>
<p>Or in other words:</p>
<pre class="brush: javascript; gutter: false">document.forms[0].field1.value = &quot;&#039;test@csnc.ch&#039;;alert(1);&quot;</pre>
<p>This results in the following HTML code:</p>
<pre class="brush: html; gutter: false">&lt;input type=&#039;text&#039; id=&#039;field1&#039; name=&#039;field1&#039;
       value=&quot;&#039;test@csnc.ch&#039;;alert(1);&quot; /&gt;</pre>
<p>Therefore the user input is not executed:</p>
<p><a href="http://blog.csnc.ch/wp-content/uploads/2012/12/image002.png"><img class="alignnone size-full wp-image-806" title="image002" src="http://blog.csnc.ch/wp-content/uploads/2012/12/image002.png" alt="" width="399" height="182" /></a></p>
<p>However, this snippet shows again how small the difference is between safe and unsafe usage of <span style="font-family: 'Courier New'; background: #FCE6D0;">eval()</span>:</p>
<pre class="brush: javascript; gutter: false">&quot;document.forms[0].&quot; + txtField + &quot;.value =&quot; + txtUserInput
&quot;document.forms[0].&quot; + txtField + &quot;.value = txtUserInput&quot;</pre>
<p>Therefore it is recommended to completely ban this function from your JavaScript code.<br />
<a name="section3"></a></p>
<h2>Unsafe DOM manipulation using jQuery html():</h2>
<pre class="brush: javascript; gutter: false">var txtAlertMsg = &quot;This is bold: &quot;;
var txtUserInput = &quot;test&lt;script&gt;alert(1)&lt;\/script&gt;&quot;;
$(&quot;#message&quot;).html(
   txtAlertMsg +&quot;&lt;b&gt;&quot; + txtUserInput + &quot;&lt;/b&gt;&quot;
);</pre>
<p>Or in other words:</p>
<pre class="brush: javascript; gutter: false">$(&quot;#message&quot;).html(
   &quot;This is bold: &lt;b&gt;test&lt;script&gt;alert(1)&lt;\/script&gt;&lt;/b&gt;&quot;
);</pre>
<p>This results in the following HTML code:</p>
<pre class="brush: html; gutter: false">&lt;div id=&#039;message&#039;&gt;&lt;b&gt;test&lt;script&gt;alert(1)&lt;/script&gt;&lt;/b&gt;&lt;/div&gt;</pre>
<p>Therefore the user input is executed:</p>
<p><a href="http://blog.csnc.ch/wp-content/uploads/2012/12/image003.png"><img class="alignnone size-full wp-image-807" title="image003" src="http://blog.csnc.ch/wp-content/uploads/2012/12/image003.png" alt="" width="402" height="269" /></a><br />
<a name="section4"></a></p>
<h2>Safe DOM manipulation using jQuery html() and text():</h2>
<pre class="brush: javascript; gutter: false">var txtAlertMsg = &quot;This is bold: &quot;;
var txtUserInput = &quot;test&lt;script&gt;alert(1)&lt;\/script&gt;&quot;;
$(&quot;#message&quot;).html(
   txtAlertMsg +&quot;&lt;b&gt;&lt;div id=&#039;userInput&#039;&gt;&lt;/div&gt;&lt;/b&gt;&quot;
);
$(&quot;#userInput&quot;).text(
   txtUserInput
);</pre>
<p>Or in other words:</p>
<pre class="brush: javascript; gutter: false">$(&quot;#userInput&quot;).text(
   &quot;test&lt;script&gt;alert(1)&lt;\/script&gt;&quot;
);</pre>
<p>This results in the following HTML code:</p>
<pre class="brush: html; gutter: false">&lt;div id=&#039;message&#039;&gt;This is bold: &lt;b&gt;
   &lt;div id=&#039;userInput&#039;&gt;test&amp;lt;script&amp;gt;alert(1)&amp;lt;/script&amp;gt;&lt;/div&gt;
&lt;/b&gt;&lt;/div&gt;</pre>
<p>Therefore the user input is not executed:</p>
<p><a href="http://blog.csnc.ch/wp-content/uploads/2012/12/image004.png"><img class="alignnone size-full wp-image-808" title="image004" src="http://blog.csnc.ch/wp-content/uploads/2012/12/image004.png" alt="" width="470" height="219" /></a></p>
<h2>Conclusion</h2>
<ul>
<li><span style="font-family: 'Courier New'; background: #FCE6D0;">eval()</span> is evil</li>
<li>jQuery does not solve all your problems</li>
<li>When using JavaScript or jQuery functions to manipulate your DOM you always need to know if your content may contain user input. If yes you must only use functions which encode HTML / JavaScript strings like jQuery <span style="font-family: 'Courier New'; background: #FCE6D0;">text()</span>.</li>
</ul>
<h2>Resources</h2>
<ul>
<li><a href="https://www.owasp.org/index.php/DOM_Based_XSS">https://www.owasp.org/index.php/DOM_Based_XSS</a></li>
<li><a href="https://www.owasp.org/index.php/DOM_based_XSS_Prevention_Cheat_Sheet">https://www.owasp.org/index.php/DOM_based_XSS_Prevention_Cheat_Sheet</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.csnc.ch/2013/01/dom-based-xss-unsafe-javascript-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
