Stack stamping is a binary hardening technique to help mitigate ROP style attacks. It works by 'stamping' the return address on the stack, thus encrypting it. Before the address is popped off the stack and used, it is decrypted by 'un-stamping' it. This can be an efficient protection, as no registers are needed, and while flags are affected, they are only affected at function entry/exits where they do not need to be preserved. Encoding and decoding the return address makes the ROP attacker's task more difficult; to succed, the attacker would need to make sure that any replacement data is properly encoded, so that when it is un-stamped, it results in the desired address.
We have created a binary software transform to perform stack stamping, based on our GTIRB intermediate representation and tooling. An open-source version of this transform is available on GitHub at grammatech/gtirb-stack-stamp; however, the open-source version is simplified and does not include full support for the many types of exotic returns, tail-calls, and non-contiguous functions found in many real-world binaries.
This material is based upon work supported by the Navy and the Office of Naval Research under Contract(s) No. N68335-17-C-0700. Any opinions, findings and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the Navy or the Office of Naval Research.