<?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>On the road to Bandol &#187; Java Card 2.x</title>
	<atom:link href="https://javacard.vetilles.com/category/java-card-2x/feed/" rel="self" type="application/rss+xml" />
	<link>https://javacard.vetilles.com</link>
	<description>A weblog on Java Card, security, and other things personal</description>
	<lastBuildDate>Mon, 18 Aug 2025 06:48:26 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.32</generator>
	<item>
		<title>Java Card++ ?</title>
		<link>https://javacard.vetilles.com/2025/08/18/java-card/</link>
		<comments>https://javacard.vetilles.com/2025/08/18/java-card/#comments</comments>
		<pubDate>Mon, 18 Aug 2025 06:47:58 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[Java Card 2.x]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/?p=26403</guid>
		<description><![CDATA[I was part of the team that defined the binary format that has been in use since the end of the 1990&#8217;s. The selected solution was not my preferred one, as I preferred a pre-linked version. At the time, everybody agreed that on-card verification was too ambitious, so this was never considered for Java Card [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I was part of the team that defined the binary format that has been in use since the end of the 1990&#8217;s. The selected solution was not my preferred one, as I preferred a pre-linked version. At the time, everybody agreed that on-card verification was too ambitious, so this was never considered for Java Card 2.1, the ancestor of today&#8217;s Java Card specification.</p>
<p>In the following years, we wasted a lot of time working on a much more ambitious version of Java Card, which never made it, but we never worked on addressing this issue of unverified bytecode, mostly because we had the cryptographic protections provided by GlobalPlatform. If nobody can load unverified bytecode, where is the problem?</p>
<p>As an evaluator, this allowed me to reverse engineer many types of Java Card, as I was allowed to download unverified (and very much illegal) bytecode into cards. Over time, most virtual machines have included runtime countermeasures, and some implementations have been difficult to attack with illegal bytecode for quite a while.</p>
<p>Yet, Java Card has become an industry standard. Strong implementations exist, in which loading unverified bytecode is about impossible, and then, exploiting unverified bytecode is challenging. But on the other hand, weaker platforms also exist, and recently, following a combination of mistakes from various stakeholders, <a href="https://security-explorations.com/esim-security.html" class="liexternal">one of them was broken</a>; luckily, by a researcher, not by a criminal.</p>
<p>The real surprise is not that this has happened. It is that it took over 25 years for it to happen. The lack of on-card verification has always been a weakness in the Java Card story. Over the past 25 years, there have been a few attempts to address the issue, but the industry never adopted them. Isn&#8217;t a solution to this issue a bit overdue?</p>
<p>The smart card industry is a small industry, with few actors, and Java Card has been a great success, its interoperability providing the basis for the deployment of billions of products every year. But the industry has been complacent, and although I am not part of it any more, I bear some of this responsibility since I have headed the Java Card Forum&#8217;s Technical Committee for a few years. I defended off-card bytecode verification many times, for instance  <a href="https://javacard.vetilles.com/2011/10/19/the-misuse-of-bytecode-verification/" class="liexternal">in 2011</a> and quite vehemently <a href="https://javacard.vetilles.com/2013/11/21/the-off-card-byte-code-verifier-is-fine-thank-you/" class="liexternal">in 2013</a>.</p>
<p>But that was over 10 years ago, and I would now argue that it&#8217;s time to fix this issue. Despite minor updates, the core Java Card technology is over 25 years old. The similarity between the latest version of the Java Card Virtual Machine specification with its first interoperable version is striking. There have been almost no changes. The CAP file format is antiquated, and an update could allow all vendors to ensure that no illegal bytecode is allowed to run on the any card.</p>
<p>From a now outsider&#8217;s viewpoint, I believe that after the recent developments and an issue impacting the security of millions of unsuspecting users, the usual denials sound really out of touch with reality, so I am asking the Java Card community a simple question: Since you are pushing for Java Card to be the basis for our personal security, and asking us to trust you with our sensitive data, including our identity, isn&#8217;t it now the right time to put this bytecode issue behind us once and for all?</p>
]]></content:encoded>
			<wfw:commentRss>https://javacard.vetilles.com/2025/08/18/java-card/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Logical Attacks in the Java Card security landscape</title>
		<link>https://javacard.vetilles.com/2016/11/10/logical-attacks-in-the-java-card-security-landscape/</link>
		<comments>https://javacard.vetilles.com/2016/11/10/logical-attacks-in-the-java-card-security-landscape/#comments</comments>
		<pubDate>Thu, 10 Nov 2016 18:11:05 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[Java Card 2.x]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[logical attack]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/?p=26293</guid>
		<description><![CDATA[Logical attacks on Java Card have been known for a long time, and they have also been a focus of a lot of academic research, which still continues today. Earlier this week at Cardis 2016, there have been two presentations on logical attacks. I will not discuss the details of the attacks that are being [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Logical attacks on Java Card have been known for a long time, and they have also been a focus of a lot of academic research, which still continues today. Earlier this week at <a href="https://2016.cardis.org/" title="Cardis 2016" class="liexternal">Cardis 2016</a>, there have been two presentations on logical attacks. I will not discuss the details of the attacks that are being disclosed; the important thing is that the publicly available information about logical attacks is increasing regularly over time.</p>
<p>What amazed me most during these presentations is the very low security level of some cards that are being sold in 2016. Among my surprises, I noted:</p>
<ul>
<li><strong>Object meta-data in the heap.</strong> I would have expected the object meta-data (headers) to be separated from heap data in a dedicated array of <em>handles</em>. But apparently, there is a significant proportion of cards that don&#8217;t use that basic protection (actually, my surprise comes from the fact that cards have more and more memory, and handles help to manage large heaps with a 16-bit reference).</li>
<li><strong>Single key encryption key.</strong> In some cards, key material stored in <code>SecretKey</code> and <code>PrivateKey</code> objects are encrypted, but the same key is used for all objects. This weakness may be the most symptomatic of how logical attacks are being ignored, as it provides a good protection against hardware attacks (like a memory dump), but no protection at all from logical attacks that &#8220;jump&#8221; the firewall.</li>
<li><strong>No key encryption.</strong> Apparently, some cards don&#8217;t even bother to encrypt their secrets at all. That&#8217;s really bad, I even have trouble believing it (which explains the &#8220;apparently&#8221;). Yet, it only shows great disdain for any security, not just logical attacks.</li>
</ul>
<p>The problem with the two first issues come from one of the most powerful features of logical attacks. These attacks run as a legitimate Java Card application, and they are able to <em>impersonate</em> an application. As such, they can defeat some protections (like the encryption of keys, or the integrity protections of a PIN counter) without breaking the protection itself. Basically, you don&#8217;t need the key if someone holds the door for you.</p>
<p>Now, we come to the main reason why logical attacks are not being considered. Most smart cards must undergo some kind of security evaluation before they reach the market. This evaluation is performed by security laboratories, including Riscure, which presented on of the Cardis papers. These laboratories find vulnerabilities, for instance using logical attacks, and they then try to build attacks from these vulnerabilities. A card will fail the evaluation only if such a complete attack can be built.</p>
<p>Furthermore, laboratories follow strict guidelines, often those defined in the <a href="https://www.ssi.gouv.fr/archive/site_documents/JIL/JIL-The_application_of_attack_potential_to_smartcards_V2-1.pdf" class="lipdf">Application of Smart Card Attack Potential</a> to rate the difficulty of attacks, and only attacks that are rated under some predetermined level can be considered.</p>
<p>All of this make perfect sense, since the laboratory is supposed to evaluate the ability of a potential attacker with given skills and resources to &#8220;break&#8221; the card. For this reason, these evaluations have often focused greatly on cryptography: if an attacker is able to &#8220;guess&#8221; a secret/private key, then the card is most likely broken.</p>
<p>The problem with logical attacks is that, in order to be exploited, they need to be combined with other attacks. In particular, most (all) deployed cards only allow the loading of an application after a successful GlobalPlatform authentication. In order to exploit a logical attack, this authentication (or the checks related to that authentication) needs to be broken. This is a very strong condition, which makes it very unlikely. So, from a traditional smart card evaluation point of view, I admit that it makes perfect sense to ignore logical attacks as being a remote possibility of attack.</p>
<p>Before continuing, I need to distinguish between two kinds of security evaluations: <em>black-box</em> evaluations, in which the laboratory only has access to the cards, without any non-public documentation, and <em>white-box</em> evaluations, in which the laboratory has access to full information, including source code and tests.</p>
<p>Logical attacks are very interesting to learn about the targeted platform, and get information about the implementation options used by a card, and globally revere engineer the platform. As such, they are not useful in white-box evaluations, where reverse engineering is not required. However, they are very useful in black-box evaluation, because this is how an evaluator learns about the cards, and uses this knowledge to select the hardware attacks that are most likely to work. In a black-box evaluation, or in a real attack, logical attacks are an essential tool to optimize attacks. When they don&#8217;t work, the attacker is blind in performing attacks, and likely to waste a lot of time. In addition, the attacker will immediately get the feeling that the vendor has invested on the card&#8217;s security, which is bad news (from an attacker&#8217;s point of view).</p>
<p>The papers from Cardis 2016 are interesting in this perspective, because the researchers have started to investigate the cards a bit further. In particular, on some cards, they have identified the fact that the implementation of some APIs does not follow the Java Card specification, and/or uses proprietary bytecode instructions. Through that work, they are getting closer to &#8220;traditional&#8221; hacking, where vulnerabilities are found in the OS and exploited. They are not there yet, but it is coming.</p>
<p>Finally, and possibly most importantly, the smart card industry is evolving, in particular for the SIM market. There is a move toward eUICC, and possibly toward some kind of &#8220;software SIMs&#8221; that would leverage the security features of a device&#8217;s main chipset rather than run on a dedicated hardware. Such a software SIM would still be quite isolated from the main OS, for instance using TrustZone, but <a href="http://bits-please.blogspot.fr/" class="liexternal">some researchers</a> have shown that TrustZone software can be broken. And then, logical attacks become plausible, and very interesting for attackers, in particular for their application impersonation capabilities.</p>
<p>In my previous jobs, I have long fought the idea that the security of Java Card implementation should be left to competition as a differentiation feature for vendors, mostly because customers can&#8217;t tell the difference. As Java Card moves out of dedicated hardware, its security landscape is going to evolve, and hopefully this change will be considered by the industry.</p>
]]></content:encoded>
			<wfw:commentRss>https://javacard.vetilles.com/2016/11/10/logical-attacks-in-the-java-card-security-landscape/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Card software attacks</title>
		<link>https://javacard.vetilles.com/2016/06/03/java-card-software-attacks/</link>
		<comments>https://javacard.vetilles.com/2016/06/03/java-card-software-attacks/#comments</comments>
		<pubDate>Fri, 03 Jun 2016 11:29:20 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[Java Card 2.x]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/?p=25883</guid>
		<description><![CDATA[There have been two papers at SSTICâ€™16 that outline the limits of bytecode verification in the context of Java Card. One of the papers, by Guillaume Bouffard and Julien Lancia, describes a bug found in Oracle&#8217;s bytecode verifier through fuzzing (yes, itâ€™s been fixed). The second one, by Jean Dubreuil, outlines several logical and combined [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>There have been two papers at <a href="https://www.sstic.org/2016/" class="liexternal">SSTICâ€™16</a> that outline the limits of bytecode verification in the context of Java Card. One of the papers, <a href="https://www.sstic.org/2016/presentation/fuzzing_and_overflows_in_java_card_smart_cards/" class="liexternal">by Guillaume Bouffard and Julien Lancia</a>, describes a bug found in Oracle&#8217;s bytecode verifier through fuzzing (yes, itâ€™s been fixed). The second one, <a href="https://www.sstic.org/2016/presentation/java_card_security_software_and_combined_attacks/" class="liexternal">by Jean Dubreuil</a>, outlines several logical and combined attacks through legal applets.</p>
<p>I will refrain from commenting on the first paper because of my previous involvement with Oracleâ€™s Java Card technology, but I would like to make a few comments on the second one.</p>
<p>First, this paper is very well-written, and the attacks are really easy to understand, at least if you have the appropriate background. The attacks are all interesting, and some of them, in particular on the logical part, seem a little bit too easyâ€¦ Maybe some quality issues in some places.</p>
<p>I have two remarks, though.</p>
<p>First, the general comment about logical attacks that </p>
<blockquote><p>the correctness implementation of the JCVM embedded on sensitive products must be carefully checked
</p></blockquote>
<p> is OK, but the following statement about the bytecode verifier (BCV) sounds strange:</p>
<blockquote><p>Today, a huge part of the security of the products relies on the robustness of the BCV but these attacks demonstrate that the BCV is not always sufficient enough to protect the JCVM against this type of software attacks.
</p></blockquote>
<p>A BCV reasons on the application, and makes no claim that the applications will run securely on a buggy JCVM implementation. There is nothing to demonstrate here, because the BCV has never been intended to protect against this type of software attacks. We need to stress that there is nothing to be done at the level of the BCV to counter these attacks. Here, we need to verify the JCVM implementations.</p>
<p>The second remark is about a sentence in the conclusion, which states that</p>
<blockquote><p>tests like TCK are not designed to find this kind of bugs in implementations.
</p></blockquote>
<p>Thatâ€™s true for the stack overflow bug, which is an implementation bug. However, it is not obvious for the two other bugs:</p>
<ul>
<li>The firewall check on a cast should be tested by the TCK. I am actually surprised that it isnâ€™t, but I donâ€™t have access to the TCK these days.</li>
<li>Similarly, the implementation bug on the switch instructions is a also a compliance issue, and should be somehow caught by the TCK (it is more of a corner case, though, so it raises the question of required TCK coverage).</li>
</ul>
<p>In the end, I agree on the fact that labs should have a library of malicious applets of all kinds that they use in evaluations, but compliance issues should be as much as possible checked by the TCK.</p>
]]></content:encoded>
			<wfw:commentRss>https://javacard.vetilles.com/2016/06/03/java-card-software-attacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inside Java Card: From APDUs to CAP File and Interoperability</title>
		<link>https://javacard.vetilles.com/2016/05/12/inside-java-card-from-apdus-to-cap-file-and-interoperability/</link>
		<comments>https://javacard.vetilles.com/2016/05/12/inside-java-card-from-apdus-to-cap-file-and-interoperability/#comments</comments>
		<pubDate>Thu, 12 May 2016 11:26:55 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[History]]></category>
		<category><![CDATA[Java Card 2.x]]></category>
		<category><![CDATA[Java Card]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/?p=25867</guid>
		<description><![CDATA[As promised in the previous post, here are a few Java Card stories. Over the almost 20 years of Java Card history, many design decisions have been taken on the product: some successful, some less successful. Here are a few stories of these discussions/decisions. API vs. APDU Before Java Card, a smart card specification consisted [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>As promised in the previous post, here are a few Java Card stories. Over the almost 20 years of Java Card history, many design decisions have been taken on the product: some successful, some less successful. Here are a few stories of these discussions/decisions.</p>
<h2>API vs. APDU</h2>
<p>Before Java Card, a smart card specification consisted in the definition of a set of APDU commands, with a precise syntax, and in most cases, a precise semantics associated to that syntax. With Java Card, for the first time, an API was designed to run inside the card.</p>
<p>At that time, some of us believed that this would lead rapidly to a paradigm shift in the card world, with the definition of card products shifting from the definition of APDUs (which are low-level communication protocol items) to a more noble definition of API, closer to a functional definition. That&#8217;s why we worked on the definition of the Java Card RMI protocol, whose objective was to allow the definition of interfaces to communicate with cards independently of protocols.</p>
<p>Well, we were wrong. Maybe not on the principles, but most definitely in practice. Nobody adopted the RMI protocol, and APDU protocols are still being defined today. In the world of smart cards, this makes sense, since low-level considerations remain a significant challenge (for instance, performance issues in some contactless transactions). In payment, mobile, and identity, APDU standards remain the norm everywhere.</p>
<p>Why did that happen? The answer is complex, but one major factor surely is the fact that Java Card is for obscure security specialists, and that the smart card protocols are only being exposed to a few developers. In such a context, there is no real need to simplify the interfaces exposed to developers.</p>
<p>What about new markets, though? Are there good reasons to define new APIs rather than new protocols? We can here consider two markets: Mobile TEE and IoT. In both cases, the market is sufficiently new to avoid compatibility issues. Even if standards like GlobalPlatform exist, they are not strong enough yet to be real obstacles.</p>
<p>Let&#8217;s start by the mobile TEE. The idea is here to isolate the security functionality of sensitive smartphone applications. By first looking at it, this looks like a fairly open model, where a developer would split an application into the security-sensitive part, which goes in the TEE, and the non-sensitive part, which runs on the &#8220;normal&#8221; OS. Well, that would work if  developers had a clue about how to do this, but it sure isn&#8217;t the case. That&#8217;s why TEE providers are targeting &#8220;security providers&#8221;, <em>i.e.</em> developers who are working on security products. However, when taking a closer look, the requirements are always the same: authenticating users, protecting stored data (including keys and other credentials), and getting access to a little crypto to implement proprietary protocols. Most developers do not need in any way a full-fledged TEE with applications and more. All they need is a piece of trusted software that they can leverage in their applications without having to dive too deep in the security part. This may sound good for a supporter of APIs, but I am not sure, as &#8220;normal&#8221; developers need a generic API for their apps. The way in which these APIs are implemented is not their problem, and it is quite likely that at least part of this implementation will be on the &#8220;normal&#8221; side. In the end, the usual suspects (security specialists) will be designing the interface between the normal applications and the TEE, and they may be tempted to &#8220;optimize&#8221; things with low-level protocols.</p>
<p>IoT is different, though. It is interesting for at least two reasons: (1) there is no history and backward compatibility requirements, so why bother with APDUs? and (2) there is a wide variety of devices and applications. In addition, in IoT, we are quite likely to see situations where there is no secure element, so new frameworks have to be designed. Not sure where this is going, but I will sure follow what my ex-colleagues from Oracle are doing with this.</p>
<h2>CAP file vs. class file</h2>
<p>This debate has been very active during the design of Java Card 3.0 Connected, in which the class file ended up being selected. I was against the decision then, and I am still against it today. The class file is very nice, but it has not been designed with smart card and other limited environments in mind, so it makes perfect sense to design a more optimized format for constrained environments: the CAP file.</p>
<p>Here are a few good reasons to do so:</p>
<ul>
<li>Optimization. That&#8217;s the obvious one. We can optimize on size by reducing overhead, and we can also optimize on loading and linking times, exploiting Java Card&#8217;s limitations on dynamicity.</li>
<li>Specialized instruction set. This may be considered as a special kind of optimization, but Java Card uses a specific instruction set, which includes in particular a few combined instructions that make programs smaller. This path has definitely not been fully exploited in Java Card.</li>
<li>Enhanced provability. Java binaries are verifiable, and Java Card could benefit from specific verifications, for instance related to the management of objects. However, Java Card has not exploited this at any point, and bytecode verification has remained more of an issue throughout the years.</li>
</ul>
<p>On the opposite, from my biased point of view, the only reason to use class files would be to use the same format as anybody else. But since we are not running the same programs, what is the point? Well, there is at least one: with class files, there wouldn&#8217;t be a debate about the suitability of bytecode verifiers, as no one  is discussing the fact that the Java bytecode verifier is correct.</p>
<p>So, I hope that in the future, the CAP file remains, and that it evolves to integrates more aggressive optimizations, as well as a more sophisticated set of analyses that leverage the specific nature of Java Card code.</p>
<h2>Interoperability vs.  differentiation</h2>
<p>This has been a recurrent discussion item at the Java Card Forum.  What should be standardized, and what should be left as differentiators between the actors. Here are a few interesting topics here:</p>
<ul>
<li><em>Basic functionality should be interoperable</em>. That&#8217;s been OK for a long time, and nobody dared going back on that one, at least officially. However, there have been some tensions there, in particular around SIM Toolkit. With proactive commands, it is possible to interrupt the execution of a SIM Toolkit routine while waiting for a response from the mobile, and during that time, other commands can be processed. This suspension mechanism, which is essential to the SIM Toolkit spec, has never been formalized in the Java Card platform, leaving an obvious interoperability gap.</li>
<li><em>Performance is for differentiation</em>. Another obvious one, although vendors have regularly stymied any effort to define a benchmark for Java Card, like the Mesure project. Performance is a differentiator, but it is better not to measure it correctly.</li>
<li><em>Size is for differentiation</em>. That sounds obvious too, but it has led to barrels of fun in real life. Obviously different platforms, even when running on the exact same chip, don&#8217;t occupy the same space, so the space left for applications and their data differs. Well, that&#8217;s expected, and totally static, so it can easily be considered. Things get more fun when we get to objects. Platforms use headers of different sizes, they don&#8217;t implement redundancy in the same way, the don&#8217;t manage memory in the same way. In the end, the same set of objects doesn&#8217;t occupy the same memory space on two different platforms, and this has been a great issue when cards are almost full.</li>
<li><em>Security is not much for differentiation</em>. At first, this looks like a good opportunity for differentiation, as vendors want to be able to claim that their products are &#8220;more secure&#8221; than their competitor&#8217;s products. As an evaluator, I noticed the wide differences in security features between the products, and implicitly supported this view. I now believe that standards are more important for security than differentiation. If we consider the mobile payment vertical, some people will claim that the combination of private platform certifications by Visa and others and of formal Common Criteria certifications bring the desired level of interoperability. Yet, in many cases, certification authorities want to see an application certified on every target platform, and rightly so, because the various platforms do not provide the same guarantees on individual functions; they globally achieve the desired global level of security, but they protect individual functions differently. In order to reduce this, I have pushed for security interoperability to be included in Java Card for many years, first by defining security annotations, and more recently by defining dedicated security APIs. The Protection Profile for Java Card 3.0.5 has not been released yet, so I can&#8217;t tell for sure, but I am afraid that the measures included in the latest specification will still not be sufficient to provide sufficient interoperability.</li>
</ul>
<p>Another interesting thing about interoperability, as we are moving to a world where Java Card may be used on very different platforms: When we defined the Connected Edition, it was very different from the Classic Edition, but we nevertheless stated very stringent interoperability requirements: All Classic applications must run on a Connected platform.</p>
<p>As we may be moving toward another split of Java Card platforms with the rise of RAM-based platforms, I would like to see less stringent requirements. If we consider that Java Card Next will include a Classic and a RAM edition, I would require the following:</p>
<ul>
<li>Java Card Next Classic is just the next version following Java Card 3.0.5 Classic. Therefore, backward compatibility must be strict: all Java Card 3.0.5 Classic applications must run unchanged on a Java Card Next Classic platform, even without a recompile.</li>
<li>Java Card Next RAM is a new platform. Applications developed specifically for this platform are only expected to run on that platform.</li>
<li>Java Card Next Classic and Java Card Next RAM must be interoperable. It must be possible to write an application that runs on all Java Card Next platforms (Classic and RAM).</li>
</ul>
<p>For an application provider, this would mean that the following options are available:</p>
<ul>
<li>Keep existing applications, and only support their deployment on Java Card Next Classic platforms (in addition to all previous Classic platforms). This could for instance make perfect sense for payment cards or identity cards, which will remain based on classical smart card chips.</li>
<li>Write new applications specifically for the RAM platform, and only run them on Java Card Next platforms. This is suitable for applications without a strong history, which need to leverage the specific features of RAM platforms, for instance on a mobile TEE.</li>
<li>Rewrite/write applications that work on both platforms. This is suitable for new applications that target a wide range of devices, like in IoT, where the same application coudl run on many different architectures.</li>
</ul>
<p>Interoperability discussions are among the most obscure and technical in the Java Card community. It is a bit like politics: it is very easy to make broad statements that sound definitive, but reality is closer to economics, very complex and requires a deep technical understanding (and like economics, it is not a hard science, so debates can be very long). I&#8217;ll miss these discussions.</p>
]]></content:encoded>
			<wfw:commentRss>https://javacard.vetilles.com/2016/05/12/inside-java-card-from-apdus-to-cap-file-and-interoperability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Card, a farewell</title>
		<link>https://javacard.vetilles.com/2016/05/09/java-card-a-farewell/</link>
		<comments>https://javacard.vetilles.com/2016/05/09/java-card-a-farewell/#comments</comments>
		<pubDate>Mon, 09 May 2016 11:54:08 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[Discussions]]></category>
		<category><![CDATA[History]]></category>
		<category><![CDATA[Java Card 2.x]]></category>
		<category><![CDATA[Java Card Bandol]]></category>
		<category><![CDATA[Java Card]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/?p=25865</guid>
		<description><![CDATA[My Oracle story has ended, and with it my Java Card story, at least for now. I started working on the technology in February 1997, and I have never been very far from the technology for almost 20 years. However, Java Card is not in the scope of my next job, as I will focus [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>My Oracle story has ended, and with it my Java Card story, at least for now. I started working on the technology in February 1997, and I have never been very far from the technology for almost 20 years. However, Java Card is not in the scope of my next job, as I will focus on embedded and IoT security. I can&#8217;t say that I will never work again on Java Card, but at least I will take a break.</p>
<p>These 20 years have been quite an interesting ride. Java Card is an amazing technology, just as successful as it is understated. Java Card has been deployed on over 15 billion devices since the first deployments in 2000, its deployment numbers have been growing steadily for 15 years. With the current movements in the SIM industry, it is hard to guarantee that this growth will be sustained over the next years, but Java Card is at least guaranteed to have a very fat and very long tail before it disappears.</p>
<p>I will publish a few entries on Java Card, starting here with a few comments on how improbable this success has been over the years.</p>
<h2>An immature technology for an immature industry</h2>
<p>Initial work on Java Card started in 1996 at Schlumberger&#8217;s research team (now part of Gemalto), as all card vendors were looking for solutions to run scripts on smart cards, mostly for supporting the SIM Toolkit framework. At the time, every major vendor had developed a proprietary solution, usually based on an existing programming framework.</p>
<p>In 1997, smart card issuers were starting to ask for interoperability between vendors. The Java Card Forum was founded in the spring as an answer, although few of its members were convinced that it was the way to go forward. Sun Microsystems was invited as owner of the Java technology, smart card vendors became Java Card licensees, and Sun Microsystems took the responsibility of managing the specification and related technologies (reference implementation and compliance kit). Sun didn&#8217;t have any experience about smart cards, and in the first meetings, their representatives clearly showed it. Sun then hired Integrity Arts (a Gemplus spin-off) as consultant, and rapidly acquired them, getting expertise in-house.</p>
<p>Java was not well suited to the smart cards available then. The language was easy to learn, but the virtual machine brought an overhead in both size and performance. At the time, it would have been possible to design a more suitable standard for programming smart cards, but the industry has not been able to organize in order to define such a standard.</p>
<p>Java Card became an API specification rapidly with version 2.0, but this version was short-lived, and quickly replaced by version 2.1, which also included a virtual machine specification, and allowed binary Interoperability between products. At about that time, the mobile operators became really interested, a SIM toolkit API was defined, and the deployment began around 2000.</p>
<p>15 years later, this adoption of a poorly adapted technology by an immature industry has become an asset. Because Java Card was a bit too ambitious at the time, and thanks to the continuing success of the Java language, Java Card has now become a mainstream technology, which in 2015, fits the needs of the smart card market, and is present on most open smart cards, and roughly half of the microprocessor cards sold worldwide. In the end, it pays to be inadapted.</p>
<h2>Mostly an ecosystem</h2>
<p>In the late 1990&#8217;s, the first marketing sentences for Java Card were directly taken from Java, like &#8220;Millions of developers&#8221;, or &#8220;Write once, run anywhere&#8221;. The one specific marketing argument was about &#8220;Running multiple applications on your card&#8221;. Fifteen years later, here is a factual status:</p>
<ul>
<li>Hundreds of developers (tens of expert developers), mostly working for smart card vendors or for a few specialized consulting firms.</li>
<li>Most applications written for a single card, or at least for a single issuer.</li>
<li>Most applications written by a card vendor, and running only on a single vendor&#8217;s cards.</li>
<li>Most cards running a single application.</li>
</ul>
<p>The next question is: why is Java Card still around if it is not used? Well, in fact, it is being used, just not in the ways that people initially planned. In fact, an essential factor in the success of Java Card has been the certification of cards. In many cases, once a card is deployed, there is no (efficient) procedure to update the card to fix a bug or a vulnerability. Therefore, cards are heavily tested before to be deployed, and most vendors require several levels of certification, including a functional certification and a security certification.</p>
<p>These certification processes are costly, both in developer resources and in laboratory fees. Over the years, efficient certification has become an essential aspect of card development, and Java Card facilitated this in several ways:</p>
<ul>
<li>A reference for core functionality. The Java Card specification defines a set of core functions which can then be used to develop applications (cryptography, I/O, storage, appication isolation and sharing). It then becomes possible to test separately these core functions (by evaluating a Java Card platform) and the application using them (by evaluating a Java Card applet). This can lead to economies of scale.</li>
<li>Reference applications. Some issuers and actors, notably Visa, have written reference versions of their applications, which have been thoroughly tested on compliant Java Card implementations. Vendors who use these reference implementations can simplify the certification process.</li>
<li>Building experience beyond developers. Laboratories, certification authorities, security consultants all have worked with many Java Card platforms and applications over the years, and now feel confident about their ability to use, test and certify such cards in different configurations. This is the ecosystem part.</li>
</ul>
<p>In the past few years, the strength of this ecosystem has been a key asset for Java Card, together with the fact that it remains today the dominant platform for defining APIs for smart cards, regardless of the target vertical (once again an ecosystem aspect).</p>
<h2>Not dead, not frozen, just slow and conservative</h2>
<p>Another striking feature of Java Card is its lack of evolution. The core features of the platform have remained vastly unchanged since release 2.1. Several attempts to make the platform evolve have failed over the years:</p>
<ul>
<li>Java Card RMI was introduced with Java Card 2.2, with the objective of making it easier to design new smart card applications, but it was never adopted by the community. Support of Java Card RMI has been optional in the latest releases, and it was close from being deprecated a few times.</li>
<li>Java Card 3.0 Connected was a bolder attempt at reaching new markets, this time arounod Smart Card Web Servers. This specification is very nice, and it defines a Web application model that can be implemented in half a megabyte, all included (OS, VM, Web container, content management, and a few apps). Yet, smart card web servers never caught, and this specification has never been implemented in a real product since its 2009 release.</li>
<li>An annotation framework for security interoperability was added recently, but the industry hasn&#8217;t been able to agree on a semantics for these annotations, and it has not been adopted.</li>
</ul>
<p>In the latest 3.0.5 release, we have attempted to add a few simple things, hoping that they will be adopted, but this will only happen in a while, because of another interesting specificity of Java Card. It takes around a year to develop a new platform after the release of a specification, at least another year to get a full certification (functional and security), and another year to sell, produce and deploy it. That&#8217;s about 3 years between the specification and the actual availability of products.</p>
<p>This development rate partly explains the slow evolution of Java Card. The smart card ecosystem globally evolves very slowly, and to observers who are used to Web-like evolution, it may look life completely frozen. However, it keeps evolving at its specific and very slow rate. Since 2009, Java Card has become much better adapted to contactless cards, it has adopted a number of cryptographic technologies, and a few other features have evolved to follow the evolution of smart card hardware. Such changes are invisible to the non-specialist, but they keep the Java Card framework in synch with smart card technology, and this is what really counts.</p>
]]></content:encoded>
			<wfw:commentRss>https://javacard.vetilles.com/2016/05/09/java-card-a-farewell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fiction (maybe): Who will refuse to break a secure element?</title>
		<link>https://javacard.vetilles.com/2016/02/19/fiction-maybe-who-will-refuse-to-break-a-secure-element/</link>
		<comments>https://javacard.vetilles.com/2016/02/19/fiction-maybe-who-will-refuse-to-break-a-secure-element/#comments</comments>
		<pubDate>Fri, 19 Feb 2016 18:44:41 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[Java Card 2.x]]></category>
		<category><![CDATA[Mobile Security]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[logical attack]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/?p=25857</guid>
		<description><![CDATA[Apple is refusing to break an iPhone for the FBI. I believe that they are right to do so, but also that this position isn&#8217;t that easy to stand for everybody. So, here is a little fiction (well, I think it is fiction) about this. The iPhone is a secure device, so the best way [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Apple is refusing to break an iPhone for the FBI. I believe that they are right to do so, but also that this position isn&#8217;t that easy to stand for everybody. So, here is a little fiction (well, I think it is fiction) about this.</p>
<p>The iPhone is a secure device, so the best way for Apple to refuse breaking the phone is to claim that they can&#8217;t do it. Here is the story line:</p>
<ul>
<li>The iPhone includes a secure element.</li>
<li>The security code is stored and verified in the secure element.</li>
<li>The phone encryption key also is stored in the secure element.</li>
<li>In order to get that key from the secure element, the security code must be presented.</li>
<li>We don&#8217;t know how to break into the secure element, so we can&#8217;t bypass that security mechanism.</li>
</ul>
<p>It is a bit technical, but it is true from the point of view of Apple and &#8220;standard&#8221; developers. But the last statement (we don&#8217;t know how to break into the secure element) may not work for everybody.</p>
<p>First, regardless of the secure element, physical attacks are feasible, and there are many kinds. Some of them, like power analysis, do not even require to destroy the chip in any way. Of course, many such attacks will require &#8220;opening&#8221; the secure element to expose the chip and do other things that may destroy it. In the case of the FBI, who wants to attack a single chip that they must not destroy, this is not really nice.</p>
<p>Then, the secure element on the iPhone is most likely based on Java Card. This means that it is possible to load applications on it. Of course, Java Card includes security measures, so the application needs to be a malicious one; well, there are malicious applications around, and here, we are working with software. This makes a big difference. Now, here is the checklist for FBI:</p>
<ol>
<li>Get Apple to provide 100 secure elements configured exactly like the targeted one, with the card management keys (required to load an app).</li>
<li>Get some hacker to develop a malicious application that gets the value of the code, or bypasses the code check, or gets the value of the encryption key, &#8230;</li>
<li>Establish an attack procedure and test it on actual phones.</li>
<li>Get Apple to provide the management key for the targeted phone.</li>
<li>Run the attack on the targeted phone, and bingo!</li>
</ol>
<p>This is slightly different. Apple still needs to collaborate, but not at the same level. Step 4, in particular, is about providing a key that can only be used on the terrorist&#8217;s phone. Step 1 is a bit more difficult, since Apple needs to support hacking efforts on their phones.</p>
<p>There is also a need to get a hacker. This may not be as difficult as it sounds, because as far as I know, the population of hackers capable of doing such a thing is small but includes:</p>
<ul>
<li>security evaluators working at labs who necessarily have ties to NIST (very close to NSA, here), or to the equivalent in another country;</li>
<li>people working in various companies and institutions who depend greatly on government contracts;</li>
<li>and a few real hackers, who could do some work for money, fame, or both.</li>
</ul>
<p>All these people, for various reasons, are far more vulnerable than Apple, and it is quite likely that FBI will be able to find one to cooperate with them.</p>
<p>And then, what&#8217;s left? Well, the security of some secure elements and Java Card implementations are really really good, and they will be protected against more attacks, performed by most attackers. Luckily, the handful of guys who may be able to break these implementations may not be willing to do so.</p>
<p>Still, it sounds like a good idea to support Apple here.</p>
<p><strong>Final thought</strong></p>
<p>This is now a problem that every security professional/company who is involved in the development, testing, or evaluation of consumer or industrial devices must think about: How will I react to injunctions from law enforcement? Should I make sure that I don&#8217;t know how to hack my device? </p>
]]></content:encoded>
			<wfw:commentRss>https://javacard.vetilles.com/2016/02/19/fiction-maybe-who-will-refuse-to-break-a-secure-element/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Off-Card Bytecode Verifier is fine, thank you!</title>
		<link>https://javacard.vetilles.com/2013/11/21/the-off-card-byte-code-verifier-is-fine-thank-you/</link>
		<comments>https://javacard.vetilles.com/2013/11/21/the-off-card-byte-code-verifier-is-fine-thank-you/#comments</comments>
		<pubDate>Thu, 21 Nov 2013 13:42:50 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[Discussions]]></category>
		<category><![CDATA[Java Card 2.x]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[logical attack]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/?p=877</guid>
		<description><![CDATA[REWRITTEN on 23 Nov. 2013. A few weeks ago, a friend sent me a link to the Cardis program, with the message &#8220;A bug in the verifier?&#8221;. Looking at the program, I saw a paper entitled Manipulating frame information with an Underflow attack undetected by the Off-Card Verifier, by Thales Communications and Security. This sounded [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>REWRITTEN on 23 Nov. 2013.</p>
<p>A few weeks ago, a friend sent me a link to the <a href="http://cardis.sec.t-labs.tu-berlin.de/program.html" class="liexternal">Cardis</a> program, with the message &#8220;A bug in the verifier?&#8221;. Looking at the program, I saw a paper entitled <em>Manipulating frame information with an Underflow attack undetected by the Off-Card Verifier</em>, by Thales Communications and Security. This sounded like bad news, so I got a copy of the paper and read it. </p>
<p>The good news is that there is no bug. Nevertheless, reading the paper made me unhappy. As a consequence, the first version of this blog post was a flame, in which I qualified the paper of &#8220;dishonest, not innovative, and misleading&#8221;.</p>
<p>Publishing the flame triggered some discussions, with people at Thalès and with other people, in particular with Jean-Louis Lanet of XLIM. They provided me their views on the topic, and I have decided to revise my original flame into a more mundane and constructive post.</p>
<h4>Dishonest, or just a bad title.</h4>
<p>As mentioned above, the paper&#8217;s title is&#8221;Manipulating frame information with an Underflow attack undetected by the Off-Card Verifier&#8221;. However, section 3.2 of the paper surprisingly starts with the sentence: &#8220;The standard Oracle bytecode verifier detects the underflow attack&#8221;. There is no other reference to a verifier that would not detect that attack, and that makes the title sound really dishonest, at least the &#8220;undetected&#8221; part of it.</p>
<p>More specifically, it seems that the objective of the paper is not to point to an issue in the off-card verifier, as the title seems to, but rather to point to the fact that there exist ways to bypass the verification. A revision of the title in the proceedings would do just fine.</p>
<h4>Not innovative, or not published.</h4>
<p>The paper describes an attack that uses the <code>dup_x</code> instruction to perform a stack underflow. This stack underflow allows the authors to access the content of a stack frame, including the current context, and to change it. The question is: is this a new attack? As a virtual machine implementer and evaluator, I would say no immediately. This attack very easily comes to mind as soon as you know the content of a stack frame (as an implementer does). This attack has therefore been in my &#8220;bag of tricks&#8221; when I was an evaluator, and was even quite a practical one.</p>
<p>Now, the smart card industry is secretive, and evaluators are even more secretive. Very few actual attacks have been described in scientific papers. It seems that the attack to mention stack underflow is the EMAN2 attack described by Bouffard <em>et al.</em> at Cardis in 2011. However, they only abuse the return address, labeling the current context &#8220;unknown value&#8221;. In that context, it seems that this paper describes something that has not been published before. For this one, my apologies, as I forgot the secrecy of the industry, and kudos for actually publishing this rather than keeping it secret.</p>
<p>So now, the community knows that, unverified bytecode can lead on some cards to allowing an attacker to run attacker-provided code in a chosen context. This is about as bad as it gets, and now, additional attacks will fall in my &#8220;tricks&#8221; category, in which an attacker/evaluator uses a new illegal bytecode combination because the previously known ones don&#8217;t work on a card. I hope that we won&#8217;t see more scientific papers about such tricks (see Jean-Louis Lanet&#8217;s second comment about this).</p>
<h4>Misleading, or missing its target.</h4>
<p>Of course, since the off-card verifier catches all of these logical attacks, they are not supposed to occur in real life, where bytecode verifiers are systematically used.</p>
<p>Let&#8217;s make a parallel between two typical components, RSA and a virtual machine. RSA is a crypto algorithm, a function <em>RSA(K,M)</em> that takes as input a key <em>K</em> and a message <em>M</em>, and produces a result. Similarly, a virtual machine is a function <em>VM(P,I)</em>, where <em>P</em> is a program (in bytecode) and <em>I</em> some input data, and produces a result. The RSA and VM functions share something important: the key <em>K</em> and the program <em>P</em> need to obey some properties. If the don&#8217;t, the algorithms don&#8217;t work. </p>
<p>If the RSA prime factors are not prime numbers, or if the program provided to the VM is not valid, their results may not be satisfactory: although they are functionally correct, they will not have the expected security properties. In order to avoid bad keys and bad programs, we use appropriate algorithms to perform primality checks, and to verify bytecode. Just as it is important to ensure that an attacker cannot tamper with the key generation scheme, it is important to ensure that bytecode is verified before to be executed. But is it sufficient?</p>
<p>Well, that may be sufficient if you run your VM or your RSA on a device that is physically protected from attackers. But on a smart card, it isn&#8217;t sufficient, at least for RSA. There have been many attacks published on smart card implementations of RSA, using fault induction, power analysis, and more. The VM is just as sensitive to these attacks; in particular, combined attacks can be used to dynamically create illegal code on a card, as mentioned in the paper.</p>
<p>If we continue the analogy, RSA is still used on cards, even though attacks exist. During security evaluations, the robustness of the implementation is verified by a lab, which ensures that well-known attacks don&#8217;t work. Naturally, the same thing must be done with the VM: a high-security implementation must include significant countermeasures against attacks on VM, such as combined attacks. The implementers have the choice of the countermeasures; they can include additional checks in the virtual machine, attempt to detect the faults, or both, or anything else, as long as it works.</p>
<p>According to my discussion with Thales, this is more or less the point that the paper tries to make, in particular in its last part. However, the paper insists on the malicious application rather than on the attacks, especially in its last sentence:</p>
<blockquote><p>
Finally, this paper shows that during open platform evaluations, it is necessary to take into account malicious applications, and make detailed analysis of each requirement included in the platform guidance.
</p></blockquote>
<p>I definitely agree on the platform guidance aspect. Requiring bytecode verification is not sufficient, as the management of the verification context is also important to avoid logical attacks. However, during evaluations, malicious applications are not the real issue, attacks on the virtual machine are. In that context, malicious applications are for now tied to combined attacks, where a fault triggers the logical attack. What the community often fails to understand is that, on a smart card, a virtual machine is a component like any other: it can be subject to physical attacks. And that&#8217;s the reason why specific countermeasures are required.</p>
<h4>So what?</h4>
<p>In Cardis, the proceedings are collected after the conference, so authors have an opportunity to revise their paper before publication. After our exchanges, I hope that some revisions will be made before publication, in particular on the title and on the last part (making a stronger point about evaluation requirements). And so, I replaced my flame with this. </p>
]]></content:encoded>
			<wfw:commentRss>https://javacard.vetilles.com/2013/11/21/the-off-card-byte-code-verifier-is-fine-thank-you/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Chip to Cloud, day 2: Automated analysis of Java Card applets</title>
		<link>https://javacard.vetilles.com/2012/09/20/chip-to-cloud-day-2-automated-analysis-of-java-card-applets/</link>
		<comments>https://javacard.vetilles.com/2012/09/20/chip-to-cloud-day-2-automated-analysis-of-java-card-applets/#comments</comments>
		<pubDate>Thu, 20 Sep 2012 13:31:17 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[Java Card 2.x]]></category>
		<category><![CDATA[Research]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Java Card]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/2012/09/20/chip-to-cloud-day-2-automated-analysis-of-java-card-applets/</guid>
		<description><![CDATA[This is a presentation by Jean-Baptiste Machemie, from the University of Limoges and a new project called Arya Security. The topic is automated analysis of Java Card applets, which is one of my favorite topics, and I am very happy to see interest from academia, as well as the emergence of companies who distribute such [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>This is a presentation by Jean-Baptiste Machemie, from the University of Limoges and a new project called <a href="http://www.arya-security.com/en/home.php" class="liexternal">Arya Security</a>. The topic is automated analysis of Java Card applets, which is one of my favorite topics, and I am very happy to see interest from academia, as well as the emergence of companies who distribute such tools.</p>
<p>The first question is to understand why automated analysis is required for NFC. One of the issues of NFC is the scalability of security evalution processes. There are good schemes forf so-called sensitive applets, which are relate to payment, identity, or other schemes that have strong certification requirements, usually requiring a full evaluation, incouding attacks.</p>
<p>The other applications, so called non-sensitive, are provided by security companies who do not require security certification. Some analysis is required, at least to make sure that they don&#8217;t interfere with the sensitive applications. Today, this analysis is performed manually by laboratories, which is error-prone, effort intensive, and not scalable.</p>
<p>Static analysis is a technology that allows us to completely automate this security analysis. This is done directly on the binary CAP file, without running the application, but simply by analyzing how the code could behave. It is possible to verify plenty of rules, including those defined by AFSCM or by GlobalPlatform. Luckily for Arya Security, these rules have been defined by people who were actually thinking about static analysis, and who made sure that the rules would be easy enough to analyze.</p>
<p>I strongly believe in static analysis, and I have written and talked about it multiple times. I am quite happy that some people get in this market and propose a tool for Java Card. I haven&#8217;t directly tried their tool, but I hope that its algorithms are good enough to avoid lost of false positives, and that they will be adopted.</p>
<p>The main barrier for them is actually NFC adoption. However, if it works, I am quite convinced that static analysis is the only way to go, because any non-automated techniques are not going to be scalable enough. Another company whose fate is linked to the success of NFC (in card emulation mode).</p>
]]></content:encoded>
			<wfw:commentRss>https://javacard.vetilles.com/2012/09/20/chip-to-cloud-day-2-automated-analysis-of-java-card-applets/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Chip to Cloud, day 2: Java Card, 15 years later</title>
		<link>https://javacard.vetilles.com/2012/09/20/chip-to-cloud-day-2-java-card-15-years-later/</link>
		<comments>https://javacard.vetilles.com/2012/09/20/chip-to-cloud-day-2-java-card-15-years-later/#comments</comments>
		<pubDate>Thu, 20 Sep 2012 12:29:51 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[History]]></category>
		<category><![CDATA[Java Card 2.x]]></category>
		<category><![CDATA[Java Card]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/2012/09/20/chip-to-cloud-day-2-java-card-15-years-later/</guid>
		<description><![CDATA[Yes, this is my own session, so this is not really live. The idea is here to identify the most important events in the past 15 years of Java Card, and to take a look at the future. So, here are the selected events: 1996, Java on a smart card. That&#8217;s even more than 15 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Yes, this is my own session, so this is not really live. The idea is here to identify the most important events in the past 15 years of Java Card, and to take a look at the future. So, here are the selected events:</p>
<ul>
<li>1996, Java on a smart card. That&#8217;s even more than 15 years ago, and that&#8217;s when some maniacs at Schlumberger&#8217;s Austin lab came up with the crazy idea of putting a Java virtual machine on a microcontroller with under 1k of RAM. It worked, and that was Cyberflex.</li>
<li>1997: the industry organizes. The Java Card Forum is created in April, and the Java Card 2.0 is released, with two demos at Cartes, Cyberflex and GemXpresso. Cyberflex gets the Sesames award that they deserved. Also, Java Card becomes a bit more Java-like, with data stored in objects rather than files, applets, and a few more things.</li>
<li>1998: OpenPlatform is created. OpenPlatform has been created by Visa, as the first initiative from issuers to work on the management of multi-application cards. A spec is rapidly issued, which is the ancestor of today&#8217;s GlobalPlatform Card Specification.</li>
<li>1999: Java Card 2.1 and interoperability. We took more time to release 2.1, because this was <em>the</em> release. The new features include binary interoperability, with the definition of the CAP file, the finalization of the application model, including transient objects and sharing.</li>
<li>1999: The SIM Toolkit API is released. This is the first hit for Java Card, which has been essential to its success in the mobile industry, still present in billions of cards.</li>
<li>2001: SIM Alliance release Interoperability Stepping Stones. This is a major industry forum, representing vendors, issuing a document that removes them a potential differentiation. Interoperability is not just for geeks any more.</li>
<li>2002: Java Card and RMI. This has been a long story, starting with the 1997 Cartes demo by Gemplus. Five years later, RMI gets in the Java Card spec as a mandatory feature, allowing Java Card developers to go beyond APDUs. Or not.</li>
<li>2009: Java Card 3.0, Connected Edition. That&#8217;s the end of a cycle in which we add more and more features. Starting in 2002 from forecasts of 1Mb chips in 2006 and a big need for content on cards, we went to high-speed communication, better VM, and a Web server. In the end, we had an iPhone, and rather small chips. And enough new features to last for 10 years.</li>
<li>2001: The first CC certificate. The Vocable was a bit crazy. Launched in 2000, the idea was to get a Common Criteria certification for a Java smart card. It was highly experimental, training the evaluation lab Serma about Java software, even discussing principles with the certification authority. But it worked, and we got the certificate. Certification matters.</li>
<li>2003: The Java Card Protection Profile. This initiative has defined a common base for the certification of Java Card products, and one of the most commonly used PPs, even today. It has also helped us grow a security ecosystem around the security of Java Card.</li>
<li>2010: EMVCo certifies a Java Card platform. It took a long time to convince issuers that it was interesting to certify platforms as well as applications. What got them there is NFC, because they now have to share a platform selected by others. And this is a great move ahead, because it is a first step toward security interoperability. We are not there yet, but Java Card is slowly getting there.</li>
<li>2009: NFC wallets require Java Card. This is important, because NFC is the first market in which Java Card is an obvious choice. Nobody has discussed this choice, since interoperability and openness are key properties. A very strong use case for Java Card.</li>
<li>2012: Embedding the card. With M2M and NFC embedded secure elements, there are talks about embedding Java Card. Once again, this is a strong use case, as the ability to add or update applications is important in this context. In a riskier move, I can mention eUICC, although network operators don&#8217;t like this much. The big news about embedded? It changes the control of the secure element, giving more power to device vendors, and taking it away from issuers.</li>
<li>2015: The Internet of Things. That&#8217;s a natural step. Everybody is talking about these billions of connected devices. At least some of them will need security, and Java Card will be around to provide this. It is recognized, and not linked to a single technology.</li>
<li>2020 and beyond: The security subsystem. That&#8217;s a bit far to bet on form factors, and I don&#8217;t know if secure elements will still be around, if they will be integrated in the main chipsets, or if software only will be needed, but I am convinced that a security subsystem will be around, and Java Card is a good candidate to run on it. Why? Because Java Card is small and constrained, but it is also provable in many ways, and can be evaluated with high assurance levels. And in security terms, these things matter.</li>
</ul>
<p>To conclude, what is happening today? Well, Java Card security is drawing some interest from the research community, and we are seeing great results. For instance, Guillaume Barbu has done great work in his Ph.D. thesis about logical attacks and countermeasures. More work is happening at Limoges, Nijmegen, Royal Holloway, and more. Students who work on that then get jobs at evaluation labs, and we got presentations from Emilie Faugeron and Jean-Baptiste Machemie about new evaluation offers.</p>
<p>Of course, Java Card is everywhere around NFC, and it was present, explicitly or implicitly, in most presentations I saw from the NFC World Congress.</p>
<p>Finally, a personal note or this blog. I have been personnally involved almost full time on Java Card fornthe past 15 years, and I participated in a way or another to most of the events noted here, except of course the initial idea from the Schlumberger guys. I am very proud of everything we have achieved during these years, and I hope that many more people are just as proud of this  success. After all, over 10,000,000,000 cards with Java Card have been produced, and this is a big number. Actually, I don&#8217;t know of any application framework that can show such numbers. So thank you everybody, and let&#8217;s continue for 15 more years!</p>
]]></content:encoded>
			<wfw:commentRss>https://javacard.vetilles.com/2012/09/20/chip-to-cloud-day-2-java-card-15-years-later/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The misuse of bytecode verification</title>
		<link>https://javacard.vetilles.com/2011/10/19/the-misuse-of-bytecode-verification/</link>
		<comments>https://javacard.vetilles.com/2011/10/19/the-misuse-of-bytecode-verification/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 08:42:21 +0000</pubDate>
		<dc:creator><![CDATA[Eric Vétillard]]></dc:creator>
				<category><![CDATA[Discussions]]></category>
		<category><![CDATA[Java Card 2.x]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Virtual machine]]></category>
		<category><![CDATA[bytecode]]></category>
		<category><![CDATA[GlobalPlatform]]></category>
		<category><![CDATA[static analysis]]></category>

		<guid isPermaLink="false">http://javacard.vetilles.com/?p=759</guid>
		<description><![CDATA[Bytecode verification has been an interesting debate since the very beginning of Java Card. Back then, in 1997, Java was very much about Java applets, and the bytecode verifier was the essential piece of software that allowed untrusted code to run in a browser efficiently (i.e., without doing expensive runtime checks, and without having to [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Bytecode verification has been an interesting debate since the very beginning of Java Card. Back then, in 1997, Java was very much about Java applets, and the bytecode verifier was the essential piece of software that allowed untrusted code to run in a browser efficiently (<em>i.e.</em>, without doing expensive runtime checks, and without having to setup a complex process of applet vetting). We inherited this view of bytecode verification in Java Card, and the verifier was integrated in the Java Card virtual machine.</p>
<p>Since then, there have been many debates about bytecode verification, and my own position has evolved over the years. Today, my opinion is a bit contrasted, some may even say contradictory. Nevertheless, here it is:</p>
<ul>
<li>Bytecode verification has limited use for Java Card runtime security.</li>
<li>Extended bytecode verification is a very good tool for application vetting.</li>
</ul>
<p>Let me give a few more details about these two opinions.</p>
<h4>Bytecode verification and runtime security</h4>
<p>The idea of runtime verification is that it is performed after getting the code, and right before to run it. The code that runs is therefore known correct, at least regarding bytecode execution (unrelated attacks remain possible, of course).</p>
<p>The first big issue with bytecode verification is that, in Java Card, with the split virtual machine model, verification is not performed on the card, but outside of the card, before/during/after converting the application into Java Card&#8217;s specific binary format (CAP file). Then, the application is sent to the card over some channel that may be attacked. Here, we rely on GlobalPlatform&#8217;s cryptography-based security to protect the integrity of the code. So, basically, we still need to establish trust, and we must say goodbye to the power of running untrusted code from arbitrary developers.</p>
<p>This is not a big issue in practice, because there is no business model that allows arbitrary code to be loaded on cards. However, this causes an organizational problem, as the verification process needs to be well organized. Researchers from Nijmegen and Limoges have shown that it is possible to fool the verification process with fake export files, and then load on a card verified code that will perform type confusion attacks.</p>
<p>Going beyond that, some people have designed applications that can be verified, but have been designed to be attacked through hardware attacks (fault induction, usually). Such attacks, usually known as hybrid attacks, completely fool the bytecode verification process.</p>
<p>Most security experts will then remind you at this point of the discussion that bytecode verification is only one part of the process, that GlobalPlatform is also important, that the origin of code is usually known, that this makes it very difficult to include attack code in an application, <em>etc</em>. By doing this, they are just about accepting the fact that bytecode verification is useless or at best  marginally useful: the real security of cards is in the trust between issuers and application providers, and some cryptographic process. Basically, this works because the ecosystems are small enough to be controlled (which is true for cards, and fine for me).</p>
<p>Finally, some vendors claim to have developed defensive virtual machines, which do not require a bytecode verifier, and perform enough runtime verifications to accept any bytecode, good or bad, without any risk. In that case, bytecode verification is really useless, and I believe that it makes things much simpler. Of course, such virtual machines are difficult to design and implement efficiently, but this is definitely possible, and I think that it has been done in the past (or at least that some people has come very close to it).</p>
<p>To conclude, I will get back many years ago. In 2000, Trusted Logic was very proud of its on-card bytecode verifier; the technology worked, but it has not been widely adopted. I believe that the first factor was performance, as verification made the loading and linking process much slower. I also believe that a second factor, less obvious, is that on-card bytecode verification makes the card&#8217;s security more brittle, by encouraging VM developers to rely too much on static verification rather than runtime checks (which also prevent other runtime attacks, for instance using fault induction). More than ten years later, most people admit that this was not the way to go, and I just go one step further by stating that bytecode verification is not that useful for runtime security.</p>
<h4>Bytecode verification and application vetting</h4>
<p>Bytecode verification simply consists of a very simple static analysis of the application code. Basically, this is is a program proof, but a very simple one, whose complexity can be controlled. The objective of such simple proofs is not to demonstrate that a program is correct with respect to its specification, but that this program obeys a predefined set of properties.</p>
<p>For Java bytecode verification, these properties are related to the proper ues of the bytecode instructions. However, the same algorithms can be extended in order to prove many more properties, covering many aspects of application security. Among the things that can be proven, we have the following:</p>
<ul>
<li>Method <em>M</em> is not called.</li>
<li>Method <em>M</em> is not called with arguments <em>A1</em>, &#8230;, <em>An</em>.</li>
<li>Method <em>M</em> is always called before/after method <em>N</em>.</li>
<li>Method <em>M</em> never throws a <code>NullPointerException</code> (or any other exception).</li>
<li>Command <em>INS</em> can only return status codes <em>SW1</em>, &#8230;, <em>SWn</em></li>
<li>Toolkit buffers are only used when they are available.</li>
<li>and many more.</li>
</ul>
<p>Of course, there is no magic. When extending static analysis to many properties, it becomes more and more difficult to avoid false positives, <em>i.e.</em> errors that are caused by weaknesses in the algorithms. Put simply, an application is rejected although it is in fact correct.</p>
<p>Apart from working on the algorithms to make them better, there are two ways to deal with this issue:</p>
<ul>
<li>Providing the verification tool to developers, together with explanations about the rules to follow. Usually, it is rather simple for developers to ensure that their application can be verified, provided that they can use the tool throughout the development process.</li>
<li>Use the tool in a vetting process as a guide for evaluators, who then perform additional verifications. In that case, broken rules are considered as warnings, and then verified by the evaluators. Simple applications can usually be verified easily, and more complex verification requires a few checks, simplified by the fact that the most boring tasks are performed automatically.</li>
</ul>
<p>I believe in both approaches, but the second one has been proven efficient by my then colleagues of Trusted Labs. By using such a static analysis tool, they are able to optimize the vetting process of Java Card applications (and MIDlets, but this is another story) significantly, by allowing them to focus on the the most important parts of the applications.</p>
<p>In addition, this approach allows us to include many more security rules. For instance, hybrid applications must include code that can be modified into attack code through a simple attack. It is possible to build a library of patterns of such code sequences, and to check for them statically. Then, evaluators can be warned of the possible presence of an hybrid attack and check for it. This can be promising, because such checks (very boring to do, but very unlikely to lead to anything) are usually poorly performed by humans.</p>
<p>Finally, extended bytecode verification, or static analysis, has been proven to be a very efficient optimization tool. All optimizing compilers include a static analysis phase to perform their most complex optimizations. Java Card can take great advantage of this, because of the isolation between applications, and also because of the closed world hypothesis that is sometimes possible, when cards are closed (no additional applications can be downloaded).</p>
<p>So, bytecode verification has many uses in Java Card, but runtime security just isn&#8217;t the most compelling.</p>
]]></content:encoded>
			<wfw:commentRss>https://javacard.vetilles.com/2011/10/19/the-misuse-of-bytecode-verification/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
