Software sandbox for storage of sensitive information in memory.
Find a file
2025-08-27 22:18:50 +00:00
.github Add Github Actions pipelines (#168) 2025-07-11 20:06:20 +01:00
core Improve concurrent test; replace depreciated Slice conversion (#172) 2025-08-27 22:18:50 +00:00
examples Fix deadlock when Panic is called during Purge (#156) 2023-12-04 10:28:59 +00:00
AUTHORS Update AUTHORS 2020-04-16 15:12:00 +01:00
buffer.go Removes drop based finalizer (#157) 2024-03-28 15:16:02 -04:00
buffer_test.go Removes drop based finalizer (#157) 2024-03-28 15:16:02 -04:00
docs.go remove clone; implement tests and repr methods 2019-05-26 19:08:26 +01:00
enclave.go Add test and minor changes 2019-09-29 16:53:16 +01:00
enclave_test.go Add buffer<->enclave size equality check 2019-10-01 10:29:11 +01:00
go.mod go: update dependencies (#171) 2025-08-27 21:38:21 +01:00
go.sum go: update dependencies (#171) 2025-08-27 21:38:21 +01:00
LICENSE Relicence project under Apache-v2 (#9) 2017-05-02 22:23:45 +01:00
logo.svg Initial commit 2017-04-22 09:16:20 +01:00
memguard.go fix following dead lock problems 2020-04-20 17:04:12 +08:00
memguard_test.go crypto: use local custom emtropy pool 2019-05-13 17:08:37 +01:00
README.md Update status badge 2025-07-13 18:53:19 +01:00
signals.go Update dependencies, removal of deprecated funcs (#145) 2023-05-31 14:10:37 +01:00
signals_test.go Update dependencies, removal of deprecated funcs (#145) 2023-05-31 14:10:37 +01:00
stream.go massive improvements to stream speed 2020-05-20 22:48:15 +01:00
stream_test.go Fix benchmark 2020-05-20 23:35:51 +01:00

MemGuard

Software enclave for storage of sensitive information in memory.


This package attempts to reduce the likelihood of sensitive data being exposed when in memory. It aims to support all major operating systems and is written in pure Go.

Features

  • Sensitive data is encrypted and authenticated in memory with XSalsa20Poly1305. The scheme used also defends against cold-boot attacks.
  • Memory allocation bypasses the language runtime by using system calls to query the kernel for resources directly. This avoids interference from the garbage-collector.
  • Buffers that store plaintext data are fortified with guard pages and canary values to detect spurious accesses and overflows.
  • Effort is taken to prevent sensitive data from touching the disk. This includes locking memory to prevent swapping and handling core dumps.
  • Kernel-level immutability is implemented so that attempted modification of protected regions results in an access violation.
  • Multiple endpoints provide session purging and safe termination capabilities as well as signal handling to prevent remnant data being left behind.
  • Side-channel attacks are mitigated against by making sure that the copying and comparison of data is done in constant-time.

Some features were inspired by libsodium, so credits to them.

Full documentation and a complete overview of the API can be found here. Interesting and useful code samples can be found within the examples subpackage.

Installation

$ go get github.com/awnumar/memguard

API is experimental and may have unstable changes. You should pin a version. [modules]

Contributing

  • Submitting program samples to ./examples.
  • Reporting bugs, vulnerabilities, and any difficulties in using the API.
  • Writing useful security and crypto libraries that utilise memguard.
  • Implementing kernel-specific/cpu-specific protections.
  • Submitting performance improvements.

Issues are for reporting bugs and for discussion on proposals. Pull requests should be made against master.