Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Intel CET's instructions #49

Open
Romop5 opened this issue Aug 19, 2020 · 0 comments
Open

Support Intel CET's instructions #49

Romop5 opened this issue Aug 19, 2020 · 0 comments

Comments

@Romop5
Copy link

Romop5 commented Aug 19, 2020

Intel® Control-Flow Enforcement Technology (Intel CET)

Problem

Since 2018, compilers started placing ENDBR instructions at the beginning of functions/branch, making it impossible for subhook to make a trampoline.

At my environment, whole glibc is compiled with such instructions, making it impossible for me to hook & trampoline any standard function.

Moreover, with modern processors, absence of ENDBR prevents indirect jumping at arbitrary address, and thus, requires small redesign of subhook's trampoline construction.

Proposed fix

  • A quick fix (for old processors)
    Detect a single, 4-bytes long ENDBR32 or ENDBR64 instruction. As ENDBR are equal to NOP for processors with old ISA, prior to circa. 2019, we can carry on with copying / discarding the instruction.

  • A proper fix
    I presume that a proper fix would require you to change both JMPs to include No-track prefix, and put the jump to trampoline AFTER ENDBR instruction of original function.
    This can be, however, problematic, as I noticed that you use RET for AMD64 architecture, which will probably cause troubles with so-called Shadow stack, requiring you to work around with special Intel's instructions to for changing the stack.

In either case, with Indirect Branch Tracking enabled by both CPU and binary file, subhook will not work, because in such case, every function starts with ENDBR.

To get familiar, see Black Hat's PDF file

Romop5 added a commit to Romop5/subhook that referenced this issue Aug 19, 2020
- see issue Zeex#49 for more details
 (Zeex#49)
- fixed by hardcoded both instructions into disassembler
- will not work on modern CPUs (2018+) AND with IAT enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant