Skip to content

Commit 0f18d2b

Browse files
committed
update
1 parent e1fc98f commit 0f18d2b

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎fundamentals/memorysafety.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: Memory Safety
3+
short_title: Memory Safety
4+
---
5+
6+
:::{attention} Importance of memory safety for software
7+
:class: dropdown
8+
Memory safety is a foundational property in programming languages that prevents programmers from making mistakes when managing computer memory. When a programming language is memory-safe, the language runtime or compiler automatically guards against bugs where a program accesses, modifies, or frees memory it shouldn't.
9+
:::
10+
11+
Many cybersecurity vulnerabilities in software stem from a class of defects commonly known as memory safety issues or buffer overflows. When software mishandles memory during execution, it can lead to application crashes or create openings that malicious actors can exploit to compromise the system.
12+
13+
A primary defence against these flaws is the use of a memory-safe programming language. In a memory-safe language, manual memory management—such as explicit allocation and deallocation—is abstracted away and handled automatically by the language's runtime environment or interpreter rather than the developer. This significantly reduces the likelihood of introducing critical memory-related bugs.
14+
15+
* Memory-safe languages include: Rust, Go, C#, Java, Swift, Python, and JavaScript.
16+
* Memory-unsafe languages include: C, C++, Fortran and Assembly.
17+
18+
Python is a language with built-in memory management (such as automatic garbage collection).
19+
20+
By default you do not interact directly with raw memory using Python code. **So Python is considered a memory-safe language by default.** This shields developers from entire categories of common weaknesses like buffer overflows.
21+
22+
:::{note} CPython can have bugs
23+
:class: dropdown
24+
Since 100% security does not exist and AI and humans do make mistakes:
25+
In rare occasions CPython can have bugs that relate to memory management.
26+
27+
CPython (the standard and most widely used implementation of Python) is written in C. Because C is a memory-unsafe language, the underlying interpreter codebase is susceptible to traditional memory bugs like buffer overflows, use-after-free errors, and reference-counting mistakes.
28+
29+
Despite rigorous code reviews, automated testing, and fuzzing, Python's core developers (who are human) occasionally introduce or miss subtle memory corruption bugs.
30+
:::
31+
32+
However, relying on a memory-safe language like Python is only one component of a comprehensive application security strategy. While Python protects against memory-related exploits, it does not prevent logic flaws, injection attacks, insecure data handling, or other non-memory vulnerabilities.
33+

‎toc.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ project:
1111
- file: fundamentals/fundamentals_intro.md #section Fundamentals
1212
children: #dropdown menu
1313
- file: fundamentals/executionmodel.md
14+
- file: fundamentals/memorysafety.md
1415
- file: fundamentals/cpython_security.md
1516
- file: fundamentals/bytecode.md
1617
- file: fundamentals/threatmodel.md

0 commit comments

Comments
 (0)