TSnippet: An Online Tool for Investigating Undefined Behaviors in C Programs

Despite valid alternatives, the C programming language is still largely used in industry and taught to students.

The C language is unsafe, meaning that the execution of erroneous operations causes the program’s behavior to be unpredictable. The ISO C standard tells that erroneous operations have undefined behavior.

Undefined behavior is a serious matter. Most C programmers know that accessing an out-of-bounds array element is an erroneous operation. Few of them understand that the related undefined behavior is a security flaw that could lead, for example, to a stack smashing attack.

Understanding undefined behaviors is so tricky that it is pretty much impossible to avoid them when writing nontrivial C programs. Programmers should then use verification tools ensuring that their code is correct.

Today TrustInSoft unveils TSnippet, the easiest way to guarantee the absence of undefined behaviors in C programs.

 

TSnippet: Type In, Analyze, Check Result and Start Again!

 

TSnippet is a free, cloud-powered, advanced static source code analyzer, built on top of TrustInSoft Kernel, that guarantees the absence of subtle bugs, notably those related with undefined behaviors, in single-file snippets of C source code.

Users are not required to be experienced in software verification. A minimalist user interface allows TSnippet to provide a lightweight and intuitive C code analysis workflow: Users just need to type in their program and click on a button to know whether their code is correct.

This is how TSnippet looks like:

On the left, the Source Code Editor panel allows users to directly type in a C code snippet. Then, an analysis is triggered either by a click on the toolbar button Analyze or automatically after choosing a target architecture. Finally, the outcome of the analysis is shown in the bottom-left Overview area.

The Overview displays a verdict on the users’ program. The verdict is positive if TSnippet has determined the program correct. This means that the provided code is mathematically guaranteed to be free of runtime errors, i.e. it has no undefined behavior. Otherwise, the verdict is negative, and TSnippet warns the user that it has found a flaw in the code snippet.

The precise violation is reported as a failed assertion in the right panel Analyzer View. The latter shows an interactive version of the original code, and provides the majority of TrustInSoft Analyzer’s advanced debugging features which help the user to understand the root causes of the detected flaw. In particular, users can investigate variables in multiple ways:

•  Inspect the possible runtime values of variables, at any point in the program,

•  Track variables to check how their values evolve all along the program,

•  View the values of variables per callstack, to check what values are taken by variables for specific chains of function calls,

•  Inspect which statements might have influenced the values of particular variables.

The user may then iterate the edit-analyze-check result process as many times as needed till all the problems in the program are fixed, and TSnippet finally declares it correct.

Simply put, TSnippet provides a step-by-step interactive workflow towards correct C code snippets, backed by a source code analyzer that will not miss anything. This is especially valuable for engineers needing to check for undefined behaviors since the early stages of software prototyping, or for teachers showing their students what it really means to program correctly in C.

 

Sharing knowledge

 

Mostly nobody knows about all the C language quirks, especially for what concerns undefined behaviors.

TSnippet is useful in this regard too, as a tool for teaching and spreading knowledge about correct C programming. Indeed, the tool supports a sharing service which allows sharing C code snippets, together with their respective analysis outcomes.

At any moment, users can choose to share their C code analysis with a click on the toolbar button Share. TSnippet will provide a URL that, when visited, will reproduce the original analysis session.

 

Conclusion

 

TSnippet is a free, cloud-powered, advanced static source code analyzer for single-file C code snippets. Users can directly type in some C code, and immediately get warned if it exhibits an undefined behavior. Users may also share their code snippets and respective analysis sessions.

(TSnippet is powered by TrustInSoft Kernel, available at https://github.com/TrustInSoft/tis-kernel as Open Source Software. At the moment, TSnippet allows single-file code snippets only. For more comprehensive analyses, on actual C code bases, please take a look at the TrustInSoft tools designed for such tasks at https://taas.trust-in-soft.com)

How can essential operators be better prepared to face upcoming cybersecurity challenges?

How can essential operators be better prepared to face upcoming cybersecurity challenges, whether they are located within the EU or elsewhere in the world?

The European Commission and the High Representative have proposed concrete measures to ensure safety and security of essential operators, betting on cooperation across member states and across EU structures.

These concrete measures can be found in this cybersecurity factsheet that shows how European citizens and businesses rely on digital services & technologies. It also highlights the rise of cyber incidents and attacks, but also underlines that awareness and knowledge of cybersecurity issues is still insufficient. The factsheet sums-up The Commission and High Representative’s different proposals to reinforce the EU’s resilience to cyber-attacks.

European Commission President, Jean-Claude Juncker could not have said it better “Cyber-attacks can be more dangerous to the stability of democracies than guns and tanks (…) Cyber-attacks know no borders and no one is immune.”

80% of European companies have experienced at least one cybersecurity incident last year (2015), according to PwC 2016 global state of information security survey. This is the biggest increase in Cyber-attacks in a decade.

In a context where attackers have unprecedented opportunities, means and scale of operations, exposed software must be hardened using the strongest techniques. TrustInSoft uses formal methods to ensure the total absence of vulnerabilities in legacy software, developed in simpler times and used in the infrastructures of essential operators.

Achieve ISO-26262 compliance with TrustInSoft Analyzer

In one year, over 60 million vehicles were recalled in the U.S. With more than 50% of recalls resulting from bad code, the stakes have never been higher. In today’s connected world, there’s no room for guesswork—you need safety guarantees. 

Design and implementation software validation expenses have risen dramatically since ISO-26262 went into effect. TrustInSoft’s award-winning technology provides key functions that will help you cost-effectively ensure ISO-26262 compliance and maintain unprecedented software safety guarantees.

Learn how TrustInSoft Analyzer allows you to Reduce Risk & Comply with ISO-26262

Download our white paper here:

Download

This document describes how to use the TrustInSoft Analyzer platform in order to automatically verify the source code requirements of the ISO-26262 standard. It contains an extract of the ISO-26262 standard that lists all the requirements related to the source code as well as their recommendation tables for the required ASIL.