<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>CWE-476 on guy@secdev.uk</title>
    <link>https://www.secdev.uk/blog/tags/cwe-476/</link>
    <description>Recent content in CWE-476 on guy@secdev.uk</description>
    <generator>Hugo</generator>
    <language>en-gb</language>
    <copyright>Guy Dixon | guy@secdev.uk</copyright>
    <lastBuildDate>Sat, 14 Mar 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.secdev.uk/blog/tags/cwe-476/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Memory Safety Without Rust: Defensive C and C&#43;&#43; Patterns</title>
      <link>https://www.secdev.uk/blog/technology/2026-03-14-memory-safety-without-rust/</link>
      <pubDate>Sat, 14 Mar 2026 00:00:00 +0000</pubDate>
      <guid>https://www.secdev.uk/blog/technology/2026-03-14-memory-safety-without-rust/</guid>
      <description>&lt;p&gt;I hear &amp;ldquo;just rewrite it in Rust&amp;rdquo; a lot these days, and while Rust&amp;rsquo;s ownership model genuinely does eliminate entire classes of memory safety bugs at compile time, that advice ignores reality. The vast majority of systems code &amp;ndash; operating systems, embedded firmware, database engines, network stacks &amp;ndash; is written in C and C++ and will remain so for decades. Rewriting is not always an option. So I wanted to dig into the defensive patterns, compiler features, and runtime tools that bring memory safety closer to C and C++ codebases without a language migration. What I found is that while none of these approaches match Rust&amp;rsquo;s compile-time guarantees, the combination of them makes a real difference.&lt;/p&gt;</description>
    </item>
    <item>
      <title>C&#43;&#43; Security: Smart Pointers Aren&#39;t Always Smart Enough</title>
      <link>https://www.secdev.uk/blog/technology/2025-11-08-cpp-security-smart-pointers/</link>
      <pubDate>Sat, 08 Nov 2025 00:00:00 +0000</pubDate>
      <guid>https://www.secdev.uk/blog/technology/2025-11-08-cpp-security-smart-pointers/</guid>
      <description>&lt;p&gt;The more I dug into C++ codebases, the more I noticed a recurring assumption: developers who think that switching to smart pointers and STL containers means they&amp;rsquo;re safe from memory bugs. C++ adds RAII, smart pointers, containers, and type-safe abstractions on top of C&amp;rsquo;s manual memory model, and these features genuinely eliminate many of C&amp;rsquo;s most common vulnerabilities, &lt;code&gt;std::string&lt;/code&gt; prevents buffer overflows, &lt;code&gt;std::unique_ptr&lt;/code&gt; prevents memory leaks, and &lt;code&gt;std::vector&lt;/code&gt; provides bounds-checked access via &lt;code&gt;.at()&lt;/code&gt;. But C++ also introduces new attack surfaces that turn out to be even trickier to spot: dangling references from moved-from objects, iterator invalidation, implicit conversions in template code, and the false sense of security that comes from using &amp;ldquo;safe&amp;rdquo; abstractions incorrectly. In this post, I want to cover the C++-specific anti-patterns that survive code review because they look correct to developers who trust the standard library.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Null Pointer Dereference</title>
      <link>https://www.secdev.uk/blog/technology/2025-07-19-null-pointer-dereference/</link>
      <pubDate>Sat, 19 Jul 2025 00:00:00 +0000</pubDate>
      <guid>https://www.secdev.uk/blog/technology/2025-07-19-null-pointer-dereference/</guid>
      <description>&lt;p&gt;Null pointer dereference (CWE-476) is one of those bugs that shows up across every language, and the more I researched it for this post, the more I was struck by how much damage it can do depending on context. The consequences vary dramatically: C programs crash with a segfault (or worse, the kernel maps page zero and an attacker gets code execution), C++ invokes undefined behaviour that the compiler may optimise into literally anything, Go panics with a nil pointer dereference that kills the goroutine or the whole program, and Java throws a &lt;code&gt;NullPointerException&lt;/code&gt; that can crash the app or leak stack traces to an attacker. MITRE ranks CWE-476 consistently in the top 25 most dangerous software weaknesses, and digging into the CVE data, that ranking is well deserved. I want to walk through C, C++, Go, and Java here, from the obvious unchecked &lt;code&gt;malloc&lt;/code&gt; return to the subtle nil interface trap in Go and the conditional path where null silently propagates through multiple function calls.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
