Hello,
I'm facing a weird issue when application bundle is corrupted during installation. The corruption always look the same - a certain sequence of bytes is erased (zeroed) in the file at multiple places, which obviously breaks the bundle signature.
It's a pkg built with productbuild, containing three component packages, up until recently no issue occurred. Everything is correctly signed and notarized and I don't do anything special in preinstall or postinstall scripts but I run gktool scan which reports "Scan completed, but failed because the software has been altered" which makes me believe that bundle is corrupted during installation or decompression. I'm using --compression latest for the bundle's component package.
I don't have a reliable repro but I see it happen a lot to our customers. I was suspecting a deployment tool or "security software" but I've seen the issue for manually installed packages too. It seems it happens only on Sonoma, but that may be related to fact most users are on latest macOS.
Is there any known issue with installer which could lead to bundle being corrupted this way? Did anyone faced anything similar?
I'll be honest, this has me completely baffled. I have a few comment below, but here's what I'd like you to do:
-
File a code support incident using the button at the bottom of this page. In that request, make sure you mention that I asked you to and include the link to that forum post. I want to get my hands on the actual files involved, so lets move this off the forums.
-
I'd like to get my hands on "all" the data you've got and it may be to big to send as an attachment. If you can include a link I can download it all from, that would be helpful.
-
If you're in contact with any of your users how are able to reproduce the issue, then what would be most helpful is for them to reproduce the issue (install them app, wait a moment, launch the app and watch it fail), then collect a sysdiagnose. A few notes on that:
-
It's helpful to reboot the machine before testing and to avoid running anything that isn't part of the test.
-
It doesn't matter if the log is collected a few minutes after the issue and, in fact, it makes it easier to follow the log if you wait a few minutes before you trigger the sysdiagnose. The collection process itself generates a lot of logging, so doing it "immediately" can end up mixing that log noise into the "interesting" data.
-
Don't reboot the machine before you collect the sysdiagnose. The reboot process ends up deleting a lot of log data, which often makes it basically useless.
On that last point, if a user has experienced the issue and HASN'T rebooted since it happened then the sysdiagnose might still be useful, even several days after the fact. Just makes sure they can provide some indication of when the issue actually happened, as digging through a large log "blind" doesn't really work.
- The sysdiagnose is going to be large (300+ MB), so you'll need to work out how the user gets it to you and then over to me.
Looking at the details:
The modification is always a replacement of meaningful ASCII string in Mach-O (main executable or dylibs). It's often a single sequence, but sometimes it's two where the second one is subsequence of the first.
Is it always the same "5f45 4545"
value being replaced?
It looks like the string is always replaced in both architectures in Mach-O, so it makes me think that whatever is doing that is aware of the executable format.
The bizarre thing here is that it looks like those are all mangled C++ method names, which means those are probably just symbol names that were left in the executable. There's really NO reason anything would be modifying that data, as it doesn't have any impact on actual execution. Frankly, if you were specifically trying to corrupt an executable, this seems like silly way to do so.
I'd like to understand how on earth this is happening but if you're looking for a solution "now", it's possible that making sure your executable was completely stripped of symbols before signing would bypass the entire problem. It's not exactly elegant, but if this is really tied to a particular byte sequence, then the problem won't happen without that byte sequence.
On this point:
It's interesting that not all occurrences of the string are replaced in the whole file.
How closely have you looked at the ones that aren't replaced? It's tricky to confirm this from an image but, as far as I can tell, all three of those changed this exact byte sequence:
45 4е53 5f39 616c 6c6f 6361 746f 7249 5337 5f45 4545 45
To this one:
45 4е53 5f39 616c 6c6f 6361 746f 7249 5337 0000 0000 45
I have no idea why that would have happened, but it would be interesting to confirm whether or not that pattern holds more broadly.
I get the zipped application bundles from customers and then compare the corrupted files to the bundles I extracted from pkg they use for install.
Just to clarify, was that the specific installer pkg they had, not just the same version? I want to make sure you've ruled out the possibility that the bad file wasn't already inside the installer.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware