← Effective AI Code Development

Rust Series Part 2: Is Rust Really Safer? What the Data Says

Is Rust safer than other languages? A look at the memory-safety data from Microsoft, Google and Android, government guidance, and how Rust compares with C/C++, Java, Go and Python.

·10 min read·
#Rust#Memory Safety#Type Safety#Security#Programming Languages#AI Engineering#AI-SDLC

Rust is often described as a safer alternative to traditional systems programming languages such as C and C++.

There is strong evidence behind that claim, particularly when discussing memory safety.

Historical vulnerability research from Microsoft, Chromium, and Android shows that memory-safety defects account for a substantial proportion of security vulnerabilities in large C and C++ codebases.

Rust addresses many of these problems through ownership, borrowing, type checking, and bounds checking, without requiring a garbage collector.

However, the comparison changes when we consider memory-safe languages such as Java, Go, Python, and C#.

Rust is not automatically more secure than every other programming language. Its advantages depend on the type of software being built, the runtime requirements, and the security properties that matter.

Let's examine the evidence and understand where Rust makes a meaningful difference.

Introduction

In Part 1 of this series, we explored Rust's immutability-by-default behavior, type system, ownership model, and basic programming constructs through a Fibonacci example.

One question naturally follows:

Is Rust really safer than other programming languages?

We often hear that Rust prevents memory vulnerabilities, eliminates entire classes of bugs, and provides C/C++-level performance without compromising safety.

These claims have a technical foundation, but they need context.

Safer against which vulnerabilities? Compared with which languages? And what evidence do we have from real production systems?

Rather than relying only on language features, let's examine what security research and large-scale software projects tell us.

1. Why Memory Safety Matters

Memory-safety vulnerabilities occur when software accesses memory in ways that violate the intended boundaries or lifetime of allocated objects.

Common examples include:

  • Buffer overflow: Writing beyond the boundaries of allocated memory.
  • Use-after-free: Accessing memory after it has been released.
  • Double free: Attempting to release the same allocation more than once.
  • Out-of-bounds access: Reading or writing outside the valid range of an object.
  • Dangling pointers: Using pointers that no longer refer to valid objects.

These defects can cause application crashes, data corruption, information disclosure, or arbitrary code execution.

In languages such as C and C++, developers have considerable control over memory management.

That control is useful for systems programming, but it also introduces responsibilities around pointer validity, allocation, object lifetime, and synchronization.

Modern C and C++ development uses safer abstractions, sanitizers, static analysis, fuzzing, and other controls to reduce these risks.

However, the languages do not generally enforce the same memory-safety guarantees that safe Rust provides.

2. Where Does the 70% Figure Come From?

A frequently cited statement in software security is that approximately 70% of vulnerabilities are related to memory safety.

This number should not be interpreted as a universal statistic covering all software, programming languages, or CVEs.

It comes from historical analysis of specific large software codebases.

Microsoft's findings

In 2019, Microsoft security researchers reported that approximately 70% of the vulnerabilities addressed through their security processes were memory-safety issues.

This highlighted how frequently memory-corruption defects appeared even in mature software maintained by experienced engineering teams.

Google's Chromium findings

Google's Chromium security team similarly reported that around 70% of high-severity security bugs in Chrome were memory-safety problems.

These included use-after-free vulnerabilities and other memory-corruption defects associated with C and C++ code.

Why these findings matter

The important observation is not that every software project has exactly the same vulnerability distribution.

It is that memory-safety defects repeatedly appeared as a major security concern in large systems built with memory-unsafe languages.

This makes memory-safe programming languages an important engineering option.

If a programming language can prevent certain vulnerability classes by design, developers can reduce their reliance on detecting those problems later through testing and security reviews.

That doesn't eliminate the need for testing, but it changes which problems can reach production.

3. What Happened When Google Introduced Rust into Android?

Android provides one of the more interesting real-world examples of adopting memory-safe languages in a large existing software platform.

Rather than rewriting the entire operating system, Google increasingly prioritized memory-safe languages for new development.

This included Rust for systems-level components and languages such as Kotlin for appropriate application and framework development.

What did Google observe?

Google reported that the proportion of Android vulnerabilities attributed to memory-safety defects declined significantly.

Its published figures showed a reduction from approximately 76% in 2019 to 24% in 2024.

This is an important result, but we should interpret it carefully.

The improvement cannot be attributed entirely to Rust.

Android's security strategy also included broader use of memory-safe languages, improvements in existing components, vulnerability mitigation, and changes in how new code was developed.

What about the 1,000-fold improvement?

In November 2025, Google reported that the estimated density of memory-safety vulnerabilities in its Rust code was more than 1,000 times lower than in its historical C/C++ code.

The analysis involved approximately five million lines of Rust and one potential memory-safety vulnerability identified before public release.

This is significant evidence from a large production environment.

However, it is not a universal guarantee that every Rust application will have 1,000 times fewer vulnerabilities.

Vulnerability density depends on code maturity, functionality, threat exposure, implementation quality, and the measurement methodology.

The practical lesson is that writing new systems components in memory-safe languages can substantially reduce the introduction of memory-safety defects.

This approach can be more realistic than attempting to rewrite an entire mature system.

4. Why Governments Recommend Memory-Safe Languages

Memory safety has increasingly become a software supply-chain and national cybersecurity concern.

Several government agencies have published guidance encouraging software manufacturers to reduce their dependence on memory-unsafe programming languages.

NSA guidance

In 2022, the US National Security Agency published guidance encouraging organizations to consider memory-safe languages when developing software.

The guidance identified memory-safety vulnerabilities as an important source of exploitable security defects.

CISA guidance

In 2023, CISA and international partners published The Case for Memory Safe Roadmaps.

The guidance encouraged software manufacturers to establish plans for reducing memory-safety risks across their products.

White House ONCD guidance

In February 2024, the White House Office of the National Cyber Director published Back to the Building Blocks: A Path Toward Secure and Measurable Software.

The report encouraged the adoption of memory-safe programming languages and improved software security measurement.

Rust is one of the languages relevant to this transition, especially for low-level systems development.

These recommendations are not mandates to rewrite every application in Rust.

The broader objective is to reduce preventable memory-safety vulnerabilities by selecting safer implementation approaches where practical.

5. Rust Compared with C and C++

Rust and C/C++ are often compared because they can be used to build similar categories of software.

Examples include operating-system components, embedded systems, networking software, databases, infrastructure utilities, and performance-sensitive applications.

Memory management

C and C++ provide direct access to memory and allow operations that can become unsafe if pointers, allocation lifetimes, or synchronization are handled incorrectly.

Rust uses ownership and borrowing rules to enforce important memory-safety invariants.

For example:

fn main() {
    let message = String::from("Hello");

    let another = message;

    println!("{}", another);

    // println!("{}", message);
}

The last statement would fail to compile because ownership of the String has moved to another.

This prevents the original binding from being used after the move.

Rust also checks ordinary array indexing at runtime.

fn main() {
    let numbers = [10, 20, 30];

    println!("{}", numbers[1]);
}

Accessing an invalid index through safe indexing causes a panic rather than an unchecked out-of-bounds memory access.

Rust therefore combines compile-time checks with runtime checks where necessary.

Performance

Rust compiles to native machine code and does not require a garbage collector.

It can deliver performance comparable to C and C++ for many workloads.

However, identical performance is not guaranteed.

Performance depends on algorithms, memory allocation, data structures, compiler optimization, and workload characteristics.

Rust's advantage is that many memory-safety guarantees can be achieved without introducing a garbage-collected runtime.

6. Rust Compared with Java, Go, Python, and C#

The comparison becomes different when we consider languages that already provide substantial memory-safety guarantees.

Java, Go, Python, and C# generally protect application developers from the raw pointer and manual memory-management problems common in C and C++.

Their mainstream implementations typically use managed memory, garbage collection, or other runtime mechanisms.

Rust's distinction is primarily how it achieves memory safety.

Memory management

Rust uses ownership and deterministic destruction for many resources.

Managed languages commonly use garbage collection to reclaim unreachable objects.

Garbage collection can introduce memory and runtime overhead, but modern collectors are highly optimized and can provide excellent throughput and latency characteristics.

It would be inaccurate to describe managed languages as inherently slow or unsuitable for high-performance applications.

Null handling

Rust's safe references cannot be null.

When a value may be absent, Rust commonly uses Option<T>.

fn find_user(id: u32) -> Option<String> {
    if id == 1 {
        Some(String::from("Saravanan"))
    } else {
        None
    }
}

fn main() {
    match find_user(2) {
        Some(user) => println!("Found: {}", user),
        None => println!("User not found"),
    }
}

The match expression requires both cases to be covered.

This helps developers handle missing values explicitly.

However, Rust can still panic if developers use methods such as unwrap() without ensuring a value is present.

Raw pointers can also be null, so the statement that Rust has no null values anywhere would be incorrect.

Error handling

Rust uses Result<T, E> to represent many recoverable failures.

fn divide(a: i32, b: i32) -> Result<i32, String> {
    if b == 0 {
        Err(String::from("Division by zero"))
    } else {
        Ok(a / b)
    }
}

This makes the possibility of failure visible in the return type.

However, Result does not guarantee that every failure will be handled correctly. Developers can still ignore results or introduce incorrect error-handling logic.

Concurrency

Rust's type system and the Send and Sync traits help prevent data races in safe code.

This is particularly useful in concurrent systems.

But Rust does not eliminate deadlocks, incorrect synchronization protocols, or logical race conditions.

7. A Practical Comparison

Language categoryMemory-safety approachTypical strengthsImportant trade-offs
C / C++Manual management, abstractions, runtime checks and external toolingLow-level control, mature ecosystem, native performanceMemory-safety risks remain possible
Java / C#Managed runtimes and garbage collectionEnterprise applications, mature frameworks, developer productivityRuntime and memory-management overhead
GoGarbage collection, runtime checks and language-level safetyNetwork services, cloud tooling, concurrency, simple deploymentGC overhead and different low-level control trade-offs
PythonManaged object model and runtime checksAutomation, scripting, data science, AI applicationsInterpreter overhead and native-extension security boundaries
RustOwnership, borrowing, type checking and runtime bounds checksNative systems software, predictable resource management, memory safetyLearning curve, compile-time constraints, unsafe boundary complexity

There is no universally safest language for every software system.

The right choice depends on the problem being solved.

8. What Rust Still Cannot Prevent

Rust's memory-safety guarantees do not automatically prevent application-level vulnerabilities.

For example:

  • A banking application may implement incorrect withdrawal rules.
  • A web service may construct SQL queries unsafely.
  • An API may expose data without proper authorization.
  • A network service may allocate unbounded memory from user input.
  • A dependency may contain malicious code.
  • An unsafe Rust implementation may violate memory-safety invariants.

These problems require application security, testing, architecture reviews, dependency governance, and operational controls.

A language can eliminate certain classes of errors without eliminating the need for secure software engineering.

Conclusion

Rust represents an important advancement in systems programming because it provides strong memory-safety guarantees without requiring a garbage collector.

The evidence from Microsoft, Chromium, and Android shows why reducing memory-unsafe code matters.

However, the right conclusion is not that Rust is automatically safer than every other language.

Rust is particularly valuable when developing software that needs low-level control, native performance, and strong memory-safety guarantees.

For application development, language selection should still consider maintainability, ecosystem maturity, team expertise, runtime requirements, and security architecture.

The programming language is one part of software security. The engineering practices around it remain equally important.

In the next article, we'll examine where Rust applications can still be vulnerable, including unsafe code, FFI boundaries, application logic, and software supply-chain threats.

Key Takeaways

  • Historical Microsoft and Chromium data show that memory-safety defects represented a substantial proportion of serious vulnerabilities.
  • Android's adoption of memory-safe languages contributed to a significant reduction in memory-safety vulnerability exposure.
  • Google's reported Rust vulnerability-density improvement is compelling production evidence, not a universal performance or security guarantee.
  • Rust provides stronger memory-safety guarantees than ordinary C/C++ code.
  • Java, Go, Python, and C# already provide substantial memory safety through different mechanisms.
  • Rust's security advantages do not eliminate logical vulnerabilities, unsafe-code defects, or supply-chain risks.

References

  1. Google Security Blog — Android security research
  2. Chromium — Memory Safety
  3. CISA — The Case for Memory Safe Roadmaps
  4. White House ONCD — Back to the Building Blocks
  5. The Rust Programming Language
  6. ACM — Safe Systems Programming in Rust

Public profile lookup

Ask AI About the Author

Open this query in ChatGPT, Claude, or Perplexity.

Comments

Comments are open to confirmed email subscribers. Use the email you subscribed with. To edit a comment, delete it and post a new one.

0/2000
Verify:

    Subscribe to get the new blogs.

    Field notes from someone who ships before they write about it. Sovereign AI, AI-SDLC, DevOps, and what 59 production deployments teach you. No spam. Unsubscribe anytime.

    More in this series

    1. Part 1
      Rust Series Part 1: Getting Started with Rust — Immutability and Type Safety

    Related field notes