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

fix: sbctl-batch-sign: Better handling of batch file signing by blacklisting known improper PE/COFF executables #129

Merged
merged 6 commits into from
Feb 6, 2025

Conversation

1Naim
Copy link
Member

@1Naim 1Naim commented Feb 5, 2025

Unfortunately, the prior version of the script caused massive issues for upstream[1][2] due to being poorly written and without any safeguards (mostly due to a lot of assumptions). The script is now hopefully better implemented due better protect against these issues by:

  1. Actually filtering for unsigned files only this time; see 6d49e37
  2. Ignore ESP files from Microsoft and known files that are not proper PE executables; see 070ff71 and eb4baca
  3. Protect against weird edgecases which may occur from the script due to empty output from either sbctl or find, and hypothetical filenames with spaces.

[1] Foxboron/sbctl#414
[2] Foxboron/sbctl#376

1Naim added 4 commits February 5, 2025 17:07
Using `read` in a while loop makes the script for foolproof because the script will not run on empty STDOUT.
Filenames with spaces (who??) are also handled correctly now instead of being treated as different files
in the previous implementation.

Signed-off-by: Eric Naim <[email protected]>
Previously, the script was just grabbing all files recognized by sbctl and mass signing them. This was used
to check if the script was working correctly (i.e. signing files with sbctl) but wasn't changed to filter
for unsigned files instead after checking it worked correctly.

I left it untouched because it didn't seem like a problem at the time, but issues are arising now due to
this poorly written script.

Signed-off-by: Eric Naim <[email protected]>
Filter absolute file paths using awk instead. Alternatively, `find` has -name to filter for filenames so there
was never any reason to use grep here too.

Signed-off-by: Eric Naim <[email protected]>
We expect users who use this script to enroll sbctl created keys alongside Microsoft's. With that in mind,
there's no need for the script to go sign ESP files from Microsoft/Windows.

This should better avoid  crashes from sbctl due to unproper PE/COFF executables from Microsoft.

Signed-off-by: Eric Naim <[email protected]>
@1Naim 1Naim requested review from vnepogodin and ventureoo February 5, 2025 13:21
Copy link
Member

@ptr1337 ptr1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it works fine.

@1Naim 1Naim force-pushed the fix/sbctl-win-sign branch from eb4baca to bc8e15d Compare February 6, 2025 01:49
@1Naim 1Naim marked this pull request as draft February 6, 2025 10:25
1Naim added 2 commits February 6, 2025 20:12
Technically these files can live anywhere in the boot directory, not just in Microsoft's own folder. Better
safeguard against these files by placing additional checks.

Signed-off-by: Eric Naim <[email protected]>
@1Naim 1Naim force-pushed the fix/sbctl-win-sign branch from bc8e15d to d8d9f92 Compare February 6, 2025 12:12
@1Naim 1Naim requested a review from ptr1337 February 6, 2025 12:13
@1Naim 1Naim marked this pull request as ready for review February 6, 2025 12:13
@ptr1337 ptr1337 merged commit 31bb63c into master Feb 6, 2025
@ptr1337 ptr1337 deleted the fix/sbctl-win-sign branch February 6, 2025 15:40
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

Successfully merging this pull request may close these issues.

2 participants