pe_map_image: reject an empty relocation directory when rebasing #86

Closed
opened 2026-11-21 15:41:39 +00:00 by vanya890 · 1 comment
vanya890 commented 2026-11-21 15:41:39 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by vanya890 on 2026-11-21T15:41:39Z.


Bug

The mapper deliberately allocates the image away from its preferred base so that the relocation path runs. It then computes a non-zero base delta and checks the IMAGE_FILE_RELOCS_STRIPPED flag, but an empty base-relocation directory can pass validation when that flag is clear.

If relocs.Size == 0 while the allocated base differs from opt.ImageBase, the relocation loop processes no entries and the image can be returned with absolute addresses still referring to the preferred base.

Expected behavior

When the image is mapped at a different base, reject it if the relocation directory is empty (or otherwise cannot provide the relocations required for the delta). Alternatively, allocate at the preferred base when possible and only require relocations when rebasing is unavoidable.

This is based on static code inspection; I have not run a crafted-PE reproducer.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6530899071 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/87). Originally posted by [vanya890](https://github.com/vanya890) on 2026-11-21T15:41:39Z. --- ## Bug The mapper deliberately allocates the image away from its preferred base so that the relocation path runs. It then computes a non-zero base delta and checks the `IMAGE_FILE_RELOCS_STRIPPED` flag, but an empty base-relocation directory can pass validation when that flag is clear. If `relocs.Size == 0` while the allocated base differs from `opt.ImageBase`, the relocation loop processes no entries and the image can be returned with absolute addresses still referring to the preferred base. ## Expected behavior When the image is mapped at a different base, reject it if the relocation directory is empty (or otherwise cannot provide the relocations required for the delta). Alternatively, allocate at the preferred base when possible and only require relocations when rebasing is unavoidable. This is based on static code inspection; I have not run a crafted-PE reproducer.
R0Y00 commented 2026-11-24 06:47:35 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T15:46:46Z.


Thanks for reporting this. Duplicate of #77, where the Windows loader comparison and proposed regression test are being tracked.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7065136336 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/87#issuecomment-7065136336). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T15:46:46Z. --- Thanks for reporting this. Duplicate of #77, where the Windows loader comparison and proposed regression test are being tracked.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#86
No description provided.