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

Undefined x86 opcodes known to be used for syscall-like functionality #201

Open
tremalrik opened this issue Aug 27, 2021 · 2 comments
Open
Labels
A-decoder Area: Decoder C-question Category: Question and assistance with usage

Comments

@tremalrik
Copy link

There are a number of undefined x86 instruction encodings that have been used to provide syscall-like functionality through the #UD (int 6) invalid opcode exception handler. The ones I've been able to find are:

The question would then be - should Zydis recognize any of these encodings?

@athre0z athre0z added A-decoder Area: Decoder C-question Category: Question and assistance with usage labels Aug 27, 2021
@athre0z
Copy link
Member

athre0z commented Aug 27, 2021

Thanks for the issue! We have considered this before, but decided against it. We only support what is implemented in hardware by Intel, AMD and VIA.

With these software instructions, it's hard to decide where to draw the line. There are hundreds (if not thousands) of hobby-hypervisors. There are very old hypervisors that are mostly dead (e.g. VirtualPC). Some hypervisors even use valid privileged instructions that happen to cause an exit to the hypervisor. All of them would need dedicated decoder modes and filters. We also don't want to just enable them by default, because obfuscators could emit them and confuse users into thinking that a valid instruction is going to be executed. We simply don't think it's worth the hassle.

@Keith-Cancel
Copy link

I was looking through open issues. I thought I would just add a thought. I am not sure if it's been considered, but malware sometimes use instructions like these to detect if they are running in a VM. Then for instance and it will behave differently. This can make analysis more difficult.

But yea there are lots of random hypervisors, and yea it does make sense to not show any of these by default for users in case users think they are valid, for what end up often being sorta of a hack/unintended use. "LOCK NOP" is kinda of a fun example of a hack since it's LOCK is not permitted on NOP and will trigger a trap, but bad idea at the same time since future hardware could change that behavior and handle the non-permitted LOCK prefix byte in a different manner why L4 decided to use this is kinda funny to me. (Also not VM related)

Still issues like these are common enough that some how handling them seems useful to me. Where to draw the line that something is too obscure to include seems a challenge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-decoder Area: Decoder C-question Category: Question and assistance with usage
Projects
None yet
Development

No branches or pull requests

3 participants