-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Update ad-hoc signing to hash only __TEXT segment for macOS 26 compatibility #121826
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
base: main
Are you sure you want to change the base?
Conversation
…ibility Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
|
Agh, I may have missed something when I found the difference in codesign behavior locally. It looks like the range hashed in the logs of #121373 was the same. @copilot can you make the test print more details of the managed signature when MatchesCodesignOutput fails? See the examples below: This is what This is what we output: We should try to make out output match the codesign output as much as possible, add more details about the CMS blob, and remove redundant hashes. |
Co-authored-by: jtschuster <36744439+jtschuster@users.noreply.github.com>
Done in ff4b945. Added
The enhanced |
Fixes #121373
Description
macOS 26 changed
codesignto hash only the__TEXTsegment instead of the entire file. Updated the managed ad-hoc signing implementation to match this behavior and added enhanced diagnostic output for test failures.Changes:
Create()to accept__TEXTsegment boundaries and hash only that range instead of the entire file up to signature. Updated code slot count calculation accordingly. AddedToCodesignString()method for formatting output to match codesign's format. EnhancedEquals()to output detailed diagnostics usingDebug.WriteLine()when comparisons fail.AssertEquivalent()to output diagnostic details when blob comparisons fail, including full CodeDirectory details in codesign format.__TEXTsegment VM address range and file bounds, pass toCodeDirectoryBlob.Create(). SetsexecSegmentBaseandexecSegmentLimitCodeDirectory header fields to__TEXTVM address range.MatchesCodesignOutputtest.Backwards compatible: falls back to legacy behavior (hash entire file) when
textSegmentFileEndparameter is not provided.Diagnostic Output: When signature validation fails, the test now outputs detailed information in codesign-compatible format including identifier, CodeDirectory version/size/flags, hash type, executable segment details, page size, and all special slot and code hashes with proper numbering (-7 to -1 for special slots, 0 to N for code hashes).
Customer Impact
Without this fix, managed code signing produces signatures that don't match
codesignoutput on macOS 26, breaking validation for .NET apps on the latest macOS.Regression
No, this addresses a behavioral change in macOS 26
codesigntool.Testing
Code builds without errors. Test suite includes
MatchesCodesignOutputwhich validates signatures match Apple'scodesignon both macOS 26 and 15. Enhanced diagnostic output will help identify any signature mismatches during testing.Risk
Low. Changes are isolated to Mach-O code signing implementation. Debug assertion verifies
__TEXTsegment structure assumptions. Falls back to existing behavior when new parameters aren't provided. Diagnostic output only activates on test failures and usesDebug.WriteLine()which doesn't impact production code.Original prompt
__TEXTsegment #121825💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.