close
close

attack bypassing MemTag protection on ARM processors

A few days ago, the news was announced that A team of researchers from Seoul University and Samsung have developed an attack techniquecalled TikTagcapable of bypass the MemTag hardware protection mechanism (Memory Tagging Extension, MTE) on ARMv8.5-A based systems.

This attack exploits data leaks resulting from speculative execution CPU instructions to determine the contents of memory tags (MemTags) at arbitrary memory addresses.

Attack TikTag enables the identification of tags associated with memory blocks and bypass MemTag protection. Researchers demonstrated the feasibility of the attack by exploiting vulnerabilities in the Linux kernel and Chrome browser. Using sequences of instructions (gadgets) present in these products, they performed speculative code execution.

These gadgets when run in speculative mode using code that operates with pointers, enables reading of MemTag metadata based on external conditions manipulated by the attacker. In case of a false prediction, the result of the speculative execution is discarded, but the resulting data remains in the cache and can be recovered by side-channel analysis.

MemTag is a technology designed to bind tags to memory areas and perform checks on the correct use of pointers to block exploitation of vulnerabilities such as access to already freed memory blocks, buffer overflows, and pre-initialization access. For every 16 bytes of physical memory, a 4-bit tag is created that acts as a key to access this memory.

Applications generate a label for the allocated memory area using special processor instructions and save it in the upper, unused parts of the pointer. When accessing memory using a labeled pointer, the processor checks whether the label associated with the pointer matches the labels of the memory blocks and allows access only if the labels match.

MTE tag leakMTE label escape

In the tests carried out the probability of successfully defeating the MemTag protection was estimated at 95% if the attack is executed in about 4 seconds. This vulnerability poses a significant security risk to ARMv8.5-A-based systems and highlights the need for continued improvements to hardware protection mechanisms.

To summarize, we conclude that for a template to filter the MTE tag, the following three conditions must be met: (i) CHECK must contain at least two charges guess ; (II) TESTS can be modified must have access Test point (whether loading or storage, dependent or independent of CHECK ) and (iii) CHECK must be close BR (less than 5 CPU cycles) TESTS can be modified must be far away CHECK (over 10 CPU cycles).

Scientists mention that Two types of gadgets have been identified that leak information about MemTags in the TikTag attack technique:

  • In the first case, speculative execution occurs when a branch is incorrectly predicted and the gadget’s execution conditions can be manipulated via system calls. This type of gadget is effective in attacking the Linux kernel.
  • In the second case, speculative execution exploits errors in predicting the relationship between reads and writes, using STLF (Store-To-Load-Forwarding) optimizations. This type of gadget is useful for attacking the V8 JavaScript engine used in Chromium-based browsers.

ARM confirmed This Cortex-X2, Cortex-X3, Cortex-A510, Cortex-A520, Cortex-A710, Cortex-A715 and Cortex-A720 processors are vulnerable to this type of attack, but indicated that they have no plans to make changes to the CPU to mitigate this problem. They argue that MemTags are not sensitive data for applications in the current architecture.

As for mitigation measures, researchers I suggest using instructions like sb or isb to disable speculative execution during critical memory operations. It is also recommended to include padding with other instructions between branch instructions and memory access instructions as an additional measure to prevent exploitation of these gadgets.

Finally, it is worth mentioning that researchers have published a prototype of the TikTag attack on GitHub, which proves its ability to exploit these two types of gadgets in vulnerable environments.

If you are interested, you can check out the details at the link below