<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>CWE-787 on guy@secdev.uk</title>
    <link>https://www.secdev.uk/blog/tags/cwe-787/</link>
    <description>Recent content in CWE-787 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-787/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>C Security: Manual Memory Management and Its Consequences</title>
      <link>https://www.secdev.uk/blog/technology/2025-10-25-c-security-manual-memory-management/</link>
      <pubDate>Sat, 25 Oct 2025 00:00:00 +0000</pubDate>
      <guid>https://www.secdev.uk/blog/technology/2025-10-25-c-security-manual-memory-management/</guid>
      <description>&lt;p&gt;C gives you direct control over memory allocation, pointer arithmetic, and hardware interaction. I respect that. But that control comes with absolutely no safety net: no bounds checking, no garbage collection, no type safety beyond what you enforce manually. Every buffer overflow, use-after-free, double-free, format string vulnerability, and null pointer dereference in C is a direct consequence of this design. C remains the language of operating systems, embedded systems, and performance-critical libraries, so its security pitfalls affect every layer of the software stack. When I started digging into the patterns behind C vulnerabilities, the same shapes kept appearing, from the textbook &lt;code&gt;strcpy&lt;/code&gt; overflow to the subtle integer promotion that bypasses a bounds check. Let me walk through them.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Rust Security: When unsafe Breaks the Promise</title>
      <link>https://www.secdev.uk/blog/technology/2025-10-11-rust-security-unsafe-breaks-promise/</link>
      <pubDate>Sat, 11 Oct 2025 00:00:00 +0000</pubDate>
      <guid>https://www.secdev.uk/blog/technology/2025-10-11-rust-security-unsafe-breaks-promise/</guid>
      <description>&lt;p&gt;I love Rust. I genuinely do. Its ownership system, borrow checker, and type system wipe out entire classes of vulnerabilities at compile time, use-after-free, double-free, data races, null pointer dereferences, buffer overflows. But here&amp;rsquo;s the thing: Rust gives you an escape hatch called &lt;code&gt;unsafe&lt;/code&gt;, and when it&amp;rsquo;s used incorrectly, it reintroduces every single vulnerability that Rust was designed to prevent. The more I dug into real-world Rust codebases, the more I found this happening. Beyond &lt;code&gt;unsafe&lt;/code&gt;, Rust has its own quirky set of security pitfalls: integer overflow behaviour that differs between debug and release builds, FFI boundaries that trust C code unconditionally, and logic errors that the type system simply cannot catch. In this post, I want to walk through the Rust-specific anti-patterns that break the safety promise.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Out-of-Bounds Writes</title>
      <link>https://www.secdev.uk/blog/technology/2025-06-21-out-of-bounds-writes/</link>
      <pubDate>Sat, 21 Jun 2025 00:00:00 +0000</pubDate>
      <guid>https://www.secdev.uk/blog/technology/2025-06-21-out-of-bounds-writes/</guid>
      <description>&lt;p&gt;Out-of-bounds writes (CWE-787) are the single most dangerous class of memory corruption vulnerabilities on the SANS/CWE Top 25, and they&amp;rsquo;ve held that position for years. The reason is clear once you dig into the mechanics: writing past the end of a buffer can overwrite return addresses, function pointers, vtable entries, and adjacent heap metadata, giving attackers arbitrary code execution. Unlike higher-level languages where the runtime catches array index violations, C and C++ silently corrupt memory, and the consequences may not manifest until thousands of instructions later. Even Rust, with its ownership model, is vulnerable when &lt;code&gt;unsafe&lt;/code&gt; blocks bypass the borrow checker. In this post I&amp;rsquo;ll dissect out-of-bounds writes in C, C++, and Rust, from the classic &lt;code&gt;strcpy&lt;/code&gt; overflow to the subtle off-by-one in pointer arithmetic that can survive expert review.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
