The Power of 10: Key Rules for Secure Coding in Critical Systems

The Power of 10: Key Rules for Secure Coding in Critical Systems

Why only ten rules?

In many corporate environments, coding guidelines often exceed one hundred recommendations. However, their effectiveness is limited when they cannot be easily validated by automated tools. Holzmann's proposal is simple but powerful: fewer rules, but more effective.

Here are the 10 essential rules:

Simplicity in the control flow

No goto, no setjmp/longjmp, no recursion. Predictable code facilitates static testing and analysis.

Explicit limits on loops

Every iteration must have a demonstrable maximum number of iterations. This avoids overflows or unexpected infinite behavior.

Do not use dynamic memory after initialization

No malloc or free. Static memory management reduces common errors such as memory leaks and dangling pointers.

Short and readable functions

A function should not exceed what fits on a printed sheet (~60 lines). Facilitates revisions and improves comprehension.

Active use of assertions

At least two assertions per function help to detect logical errors before they escalate. Assertions should be free of side effects.

Variables with the smallest possible scope

Avoids data contamination and improves debugging by reducing the context of possible errors.

Verification of returns and parameters

Each value returned by a function must be evaluated. Parameters must be validated within each function that receives them.

Limited use of preprocessor

Avoiding complex macros and excessive conditional directives prevents hidden errors and improves code clarity.

Restricted use of pointers

Only one level of dereferencing is allowed. No function pointers. Encourages automated analysis.

Compile with zero warnings

Code must compile without warnings, with demanding configurations and pass static analysis tools on a daily basis.

Why are these rules important?

These rules not only protect against software failures; they also reduce the cost of maintenance, improve collaboration between teams and make code auditing more transparent. In regulated or highly sensitive industries, such as banking, healthcare or aerospace, their application can make the difference between success and catastrophe.

At T&M Consulting, we adopt secure and efficient coding practices like these to ensure reliable, scalable solutions aligned with the highest international standards.

Does your company need to strengthen its secure development standards?

Let's talk tmconsulting.mx 

Ready for the next step?

Tell us about your challenge and we will build a clear roadmap with you: assessment, proposal and measurable results.

Contact us