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

TLS handling referencing the wrong headers #133

Open
gitjdm opened this issue Aug 25, 2023 · 0 comments
Open

TLS handling referencing the wrong headers #133

gitjdm opened this issue Aug 25, 2023 · 0 comments

Comments

@gitjdm
Copy link

gitjdm commented Aug 25, 2023

The code responsible for TLS handling is referencing the decoy module headers, not the original PE headers, when using a decoy module and header overwriting. In my specific testing scenario, this manifested in a crash on Windows Server 2019 but things working fine on Windows 10. The loader was treating the decoy module's PE checksum value as the RVA for the TLS directory, which happened to be a valid address pointing to null data with the Windows 10 version of the DLL, so the check at line 490 in inmem_pe.c prevented a crash in that instance.

This should be a quick fix in inmem_pe.c by changing line 478 to the following, so the original PE headers (ntc) are referenced instead of the decoy module headers (ntnew):

rva = ntc.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_TLS].VirtualAddress;

Thanks for everything!

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