Using realloc() to resize buffers containing secrets like passwords or keys can leave that sensitive data exposed in memory, as the original data is not securely erased.
When a program uses realloc() to enlarge a memory block, the system often allocates a new, larger chunk of memory and copies the old data over. The original memory block, still containing your sensitive information, becomes inaccessible to your program but remains physically present in the heap. This creates a dangerous window where the uncleared secrets are left behind, ripe for inspection. An attacker exploiting this weakness could perform a heap inspection attack by reading the process's memory through a dump or debugger. Since your code lost the pointer to the old location, it cannot overwrite that data, leaving passwords, encryption keys, or other confidential details fully visible to the attacker. To prevent this, you must manually clear sensitive data from a buffer before resizing it or use secure, dedicated functions designed for zeroing memory.
Impact: Read MemoryOther
Be careful using vfork() and fork() in security sensitive code. The process state will not be cleaned up and will contain traces of data from past use.
c