Follow @nxtchg

Author Topic: Keys in memory  (Read 604 times)

NxtChg

  • Overlord
  • *****
  • Posts: 1114
  • Respect: +61
    • View Profile
Keys in memory
« on: February 12, 2015, 01:29:27 pm »
0
Right now the master key is stored as a simple global variable. This makes it relatively easy to extract from the process memory (dump), because the offset is always the same.

I thought about doing some tricks to make it harder, but not sure if it is possible at all: if the program can find it, the attacker can do so too.

Any ideas about this? Should I complicate the code by trying to hide the master key somehow?

It's also probably worth it to encrypt it, so the attacker needs to get to two memory locations to be able to read it, and that might be more difficult.
Tentacle Overlord, The Deranged Genius of The Abyss

wizzardTim

  • Jr. Minion
  • **
  • Posts: 80
  • Respect: +5
    • View Profile
Re: Keys in memory
« Reply #1 on: February 12, 2015, 10:45:53 pm »
0
Some thoughts:

What if the offset varies depending on something like the length of the key?
Can the variable break into more variables? If yes, would that make it more difficult to hack? Will it change the offset position(s)?
If the offset depends on the memory that the variable uses, can you make the allocation harder? Eg add some bytes between the key, filled with irrelevant data, that only a function can decrypt.

What if that function is encrypted too?   8)

NxtChg

  • Overlord
  • *****
  • Posts: 1114
  • Respect: +61
    • View Profile
Re: Keys in memory
« Reply #2 on: February 12, 2015, 10:56:28 pm »
0
The length of the key will be stored in memory too :)

So in principle, I think, nothing can stop the attacker if he has full access to your memory.

The only thing we can make harder is something like the Heartbleed vulnerability, where it's difficult for the attacker to access memory.

Then, if he has to access 2 locations to get the key, it might just be too difficult to pull off.

So currently I think that encryption is probably overkill, but allocating the key dynamically might help. Maybe also lock it so it can't be paged out.
Tentacle Overlord, The Deranged Genius of The Abyss