NSA urges orgs to use memory-safe programming languages
# Infosec Memory Safety<p>## Hardware<p>- Memory protection:
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Memory_protection" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Memory_protection</a><p>- NX Bit: 
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;NX_bit" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;NX_bit</a><p>- Can non-compiled languages (e.g. those with mutable code objects like Python) utilize the NX bit that the processor supports?<p>- Can TLA+ find side-channels (which bypass all software memory protection features other than encryption-in-RAM)?<p>- How do DMA and IOMMU hardware features impact software memory safety controls?
  <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23993763" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=23993763</a><p>- DMA: Direct Memory Access<p>- DMA attack &gt; Mitigations: 
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;DMA_attack" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;DMA_attack</a><p>- IOMMU: I-O Memory Management Unit; GPUs, Virtualization,
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Input–output_memory_management_unit" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Input–output_memory_ma...</a><p>- Kernel IOMMU parameters: Ctrl-F &quot;iommu&quot;:
  <a href="https:&#x2F;&#x2F;www.kernel.org&#x2F;doc&#x2F;html&#x2F;latest&#x2F;admin-guide&#x2F;kernel-parameters.html?highlight=iommu" rel="nofollow">https:&#x2F;&#x2F;www.kernel.org&#x2F;doc&#x2F;html&#x2F;latest&#x2F;admin-guide&#x2F;kernel-pa...</a><p>- RDMA: Remote direct memory access
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Remote_direct_memory_access" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Remote_direct_memory_access</a><p>## Software<p>- Type safety &gt; Memory management and type safety: 
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Type_safety#Memory_management_and_type_safety" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Type_safety#Memory_management_...</a><p>- Memory safety &gt; Types of memory errors: 
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Memory_safety#Types_of_memory_errors" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Memory_safety#Types_of_memory_...</a><p>- Template:Memory management
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Template:Memory_management" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Template:Memory_management</a><p>- Category:Memory_management
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Category:Memory_management" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Category:Memory_management</a><p>- Reference (computerscience) 
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Reference_(computer_science)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Reference_(computer_science)</a><p>- Pointer (computer programming)
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Pointer_(computer_programming)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Pointer_(computer_programming)</a><p>- Smart pointer (computer programming) in C++: unique_ptr, shared_ptr and weak_ptr; Python: weakref, Arrow Plasma IPC,
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Smart_pointer" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Smart_pointer</a><p>- Manual Memory Management &gt; Resource Acquisition Is Initialization
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Manual_memory_management#Resource_Acquisition_Is_Initialization" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Manual_memory_management#Resou...</a><p>- Resource acquisition is initialization (C++ (1980s), D, Ada, Vala, Rust), #Reference_counting (Perl, Python (CPython,), PHP,)
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Resource_acquisition_is_initialization" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Resource_acquisition_is_initia...</a><p>- Ada &gt; Language constructs &gt; Concurrency
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Ada_(programming_language)#Concurrency" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Ada_(programming_language)#Con...</a><p>- C_dynamic_memory_allocation#Common_errors:
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;C_dynamic_memory_allocation#Common_errors" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;C_dynamic_memory_allocation#Co...</a><p>- Python 3 &gt; C-API &gt; Memory Managment:
  <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;c-api&#x2F;memory.html" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;3&#x2F;c-api&#x2F;memory.html</a><p>- The Rust Programming Language &gt; 4. Understanding Ownership &gt; 4.1. What is Ownership?
  <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch04-00-understanding-ownership.html" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch04-00-understanding-ownersh...</a><p>- The Rust Programming Language &gt; 6. Fearless Concurrency &gt; Using Message Passing to Transfer Data Between Threads
  <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch16-02-message-passing.html#using-message-passing-to-transfer-data-between-threads" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch16-02-message-passing.html#...</a><p>&gt; <i>One increasingly popular approach to ensuring safe concurrency is message passing, where threads or actors communicate by sending each other messages containing data. Here’s the idea in a slogan from the Go language documentation: “Do not communicate by sharing memory; instead, share memory by communicating.”</i><p>&gt; <i>To accomplish message-sending concurrency, Rust&#x27;s standard library provides an implementation of channels. A channel is a general programming concept by which data is sent from one thread to another.</i><p>&gt; <i>You can imagine a channel in programming as being like a directional channel of water, such as a stream or a river. If you put something like a rubber duck into a river, it will travel downstream to the end of the waterway.</i><p>- The Rust Programming Language &gt; 15. Smart Pointers &gt; Smart Pointers: 
  <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch15-00-smart-pointers.html" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch15-00-smart-pointers.html</a><p>- The Rust Programming Language &gt; 19. Advanced Features &gt; Unsafe Rust: 
  <a href="https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch19-01-unsafe-rust.html" rel="nofollow">https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;ch19-01-unsafe-rust.html</a><p>- Secure Rust Guidelines &gt; Memory management, &gt; Checklist &gt; Memory management: 
  <a href="https:&#x2F;&#x2F;anssi-fr.github.io&#x2F;rust-guide&#x2F;05_memory.html" rel="nofollow">https:&#x2F;&#x2F;anssi-fr.github.io&#x2F;rust-guide&#x2F;05_memory.html</a><p>- Go 101 &gt; &quot;Type-Unsafe Pointers&quot; 
  <a href="https:&#x2F;&#x2F;go101.org&#x2F;article&#x2F;unsafe.html" rel="nofollow">https:&#x2F;&#x2F;go101.org&#x2F;article&#x2F;unsafe.html</a>
  <a href="https:&#x2F;&#x2F;pkg.go.dev&#x2F;unsafe" rel="nofollow">https:&#x2F;&#x2F;pkg.go.dev&#x2F;unsafe</a><p>- <a href="https:&#x2F;&#x2F;github.com&#x2F;rust-secure-code&#x2F;projects#side-channel-vulnerability-checking" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rust-secure-code&#x2F;projects#side-channel-vu...</a><p>- Segmentation fault &gt; Causes, Examples, : 
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Segmentation_fault" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Segmentation_fault</a><p>- &quot;CWE CATEGORY: Pointer Issues&quot;
  <a href="https:&#x2F;&#x2F;cwe.mitre.org&#x2F;data&#x2F;definitions&#x2F;465.html" rel="nofollow">https:&#x2F;&#x2F;cwe.mitre.org&#x2F;data&#x2F;definitions&#x2F;465.html</a><p>- &quot;CWE CATEGORY: Memory Buffer Errors&quot;
  <a href="https:&#x2F;&#x2F;cwe.mitre.org&#x2F;data&#x2F;definitions&#x2F;1218.html" rel="nofollow">https:&#x2F;&#x2F;cwe.mitre.org&#x2F;data&#x2F;definitions&#x2F;1218.html</a><p>- &quot;CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer&quot;
  <a href="https:&#x2F;&#x2F;cwe.mitre.org&#x2F;data&#x2F;definitions&#x2F;119.html" rel="nofollow">https:&#x2F;&#x2F;cwe.mitre.org&#x2F;data&#x2F;definitions&#x2F;119.html</a><p>- &quot;CWE CATEGORY: SEI CERT C Coding Standard - Guidelines 08. Memory Management (MEM)&quot;
  <a href="https:&#x2F;&#x2F;cwe.mitre.org&#x2F;data&#x2F;definitions&#x2F;1162.html" rel="nofollow">https:&#x2F;&#x2F;cwe.mitre.org&#x2F;data&#x2F;definitions&#x2F;1162.html</a><p>- &quot;CWE CATEGORY: CERT C++ Secure Coding Section 08 - Memory Management (MEM)&quot;
  <a href="https:&#x2F;&#x2F;cwe.mitre.org&#x2F;data&#x2F;definitions&#x2F;876.html" rel="nofollow">https:&#x2F;&#x2F;cwe.mitre.org&#x2F;data&#x2F;definitions&#x2F;876.html</a><p>- SEI CERT C Coding Standard &gt; &quot;Rule 08. Memory Management (MEM)&quot;
  <a href="https:&#x2F;&#x2F;wiki.sei.cmu.edu&#x2F;confluence&#x2F;pages&#x2F;viewpage.action?pageId=87152142" rel="nofollow">https:&#x2F;&#x2F;wiki.sei.cmu.edu&#x2F;confluence&#x2F;pages&#x2F;viewpage.action?pa...</a><p>- SEI CERT C Coding Standard &gt; &quot;Rec. 08. Memory Management (MEM)&quot;
  <a href="https:&#x2F;&#x2F;wiki.sei.cmu.edu&#x2F;confluence&#x2F;pages&#x2F;viewpage.action?pageId=87151930" rel="nofollow">https:&#x2F;&#x2F;wiki.sei.cmu.edu&#x2F;confluence&#x2F;pages&#x2F;viewpage.action?pa...</a><p>- Invariance (computer science) 
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Invariant_(mathematics)#Invariants_in_computer_science" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Invariant_(mathematics)#Invari...</a><p>- TLA+ Model checker
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;TLA+#Model_checker" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;TLA+#Model_checker</a>
  &gt; <i>The TLC model checker builds a finite state model of TLA+ specifications for checking invariance properties. </i><p>- Data remnance; after the process fails or is ended, RAM is not zeroed: 
  <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Data_remanence" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Data_remanence</a><p>- Memory debugger; valgrind, <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Memory_debugger" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Memory_debugger</a><p>-  awesome-safety-critical <a href="https:&#x2F;&#x2F;awesome-safety-critical.readthedocs.io&#x2F;en&#x2F;latest&#x2F;#software-safety-standards" rel="nofollow">https:&#x2F;&#x2F;awesome-safety-critical.readthedocs.io&#x2F;en&#x2F;latest&#x2F;#so...</a> ; Software Safety Standards, Handbooks; Formal Verification; backup&#x2F;
  <a href="https:&#x2F;&#x2F;github.com&#x2F;stanislaw&#x2F;awesome-safety-critical&#x2F;tree&#x2F;master&#x2F;Backup" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;stanislaw&#x2F;awesome-safety-critical&#x2F;tree&#x2F;ma...</a><p>- &gt; <i>Additional lists of static analysis, dynamic analysis, SAST, DAST, and other source code analysis tools:</i> <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24511280" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=24511280</a>