Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide plain text in program memory? [duplicate]

I'm writing program that load encoded string into memory and decode it with special algorithm.

Sequences of program work:

  1. Load data from encoded file (base64 string)
  2. Decode base64 string to encoded data string (Rijndael 256)
  3. Decode encoded data string (Rijndael256) to plain text code
  4. Run code and store state in data structure
  5. Delete plain text from memory
  6. ...

The problem is in sequence #3 if user create dump of program memory, he can get code as plain text which must be secure. My question is - there is any way to protect my plain text string in memory?

Program is written in C++.

like image 945
Adams Avatar asked Feb 27 '26 02:02

Adams


1 Answers

Presumably the plain text is needed in memory, at least briefly, for proper execution. If, at that point, a memory dump happens, yes, they have access to it, and no, there isn't much you can do about it. Keeping it in plain text as short as time as possible will help, as well "secure zeroing" the memory after you're done with it.

like image 139
mark Avatar answered Mar 01 '26 09:03

mark