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

Shim 15.4 for ZeronsoftN #147

Closed
8 tasks done
joseph-zeronsoftn opened this issue Apr 1, 2021 · 28 comments
Closed
8 tasks done

Shim 15.4 for ZeronsoftN #147

joseph-zeronsoftn opened this issue Apr 1, 2021 · 28 comments
Labels
accepted Submission is ready for sysdev new vendor This is a new vendor

Comments

@joseph-zeronsoftn
Copy link

joseph-zeronsoftn commented Apr 1, 2021

Make sure you have provided the following information:

What organization or people are asking to have this signed:
ZeronsoftN Inc
What product or service is this for:
ZeroUp & ZeroCle
Please create your shim binaries starting with the 15.4 shim release tar file:
https://github.com/rhboot/shim/releases/download/15.4/shim-15.4.tar.bz2
This matches https://github.com/rhboot/shim/releases/tag/15.4 and contains
the appropriate gnu-efi source.
Please confirm this as the origin your shim.
Yes

You can see at https://github.com/zeronsoftn/shim-builder/tree/zeron/15.4-1

What's the justification that this really does need to be signed for the whole world to be able to boot it:
ZeroUp is a system recovery solution. Before booting, should be able to enter recovery mode (by grub).

ZeroCle is a disk sanitize solution, booting into Linux is required for sanitize disk.
How do you manage and protect the keys used in your SHIM?
It is managed through SafeNet's HSM Token.
FIPS 140-2 level 3
Do you use EV certificates as embedded certificates in the SHIM?
No
If you use new vendor_db functionality, are any hashes allow-listed, and if yes: for what binaries ?
None
Is kernel upstream commit 75b0cea7bf307f362057cc778efe89af4c615354 present in your kernel, if you boot chain includes a Linux kernel ?
Yes, we use alpine kernel-lts (5.10.25).
if SHIM is loading GRUB2 bootloader, are CVEs CVE-2020-14372,
CVE-2020-25632, CVE-2020-25647, CVE-2020-27749, CVE-2020-27779,
CVE-2021-20225, CVE-2021-20233, CVE-2020-10713, CVE-2020-14308,
CVE-2020-14309, CVE-2020-14310, CVE-2020-14311, CVE-2020-15705,
( July 2020 grub2 CVE list + March 2021 grub2 CVE list )
and if you are shipping the shim_lock module CVE-2021-3418
fixed ?
We will use Ubuntu's `debian/2.04-1ubuntu26.9`

Details: https://github.com/zeronsoftn/grub2/blob/zeron/2.04-1zeron01/debian/changelog (Exactly matches Ubuntu's debian/2.04-1ubuntu26.9 commit)

"Please specifically confirm that you add a vendor specific SBAT entry for SBAT header in each binary that supports SBAT metadata
( grub2, fwupd, fwupdate, shim + all child shim binaries )" to shim review doc ?
Please provide exact SBAT entries for all SBAT binaries you are booting or planning to boot directly through shim

SHIM :

sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
shim,1,UEFI shim,shim,1,https://github.com/rhboot/shim
shim.zeronsoftn,1,ZeronsoftN,shim,15.4,https://github.com/zeronsoftn/shim-release

GRUB

sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
grub,1,Free Software Foundation,grub,2.04,https://www.gnu.org/software/grub/
grub.zeronsoftn,1,ZeronsoftN,grub2,grub2.04-1zeron01,https://github.com/zeronsoftn/grub2
Were your old SHIM hashes provided to Microsoft ?
We haven't used shims before.
Did you change your certificate strategy, so that affected by CVE-2020-14372, CVE-2020-25632, CVE-2020-25647, CVE-2020-27749,
CVE-2020-27779, CVE-2021-20225, CVE-2021-20233, CVE-2020-10713,
CVE-2020-14308, CVE-2020-14309, CVE-2020-14310, CVE-2020-14311, CVE-2020-15705 ( July 2020 grub2 CVE list + March 2021 grub2 CVE list )
grub2 bootloaders can not be verified ?
Yes, We will use Ubuntu's `debian/2.04-1ubuntu26.9`
Details: https://github.com/zeronsoftn/grub2/blob/zeron/2.04-1zeron01/debian/changelog (Exactly matches Ubuntu's debian/2.04-1ubuntu26.9 commit)
What exact implementation of Secureboot in grub2 ( if this is your bootloader ) you have ?
* Upstream grub2 shim_lock verifier or * Downstream RHEL/Fedora/Debian/Canonical like implementation ?
Upstream grub2
What is the origin and full version number of your bootloader (GRUB or other)?
2.04-1zeron01 (https://github.com/zeronsoftn/grub2/blob/zeron/2.04-1zeron01)
(Exactly matches Ubuntu's debian/2.04-1ubuntu26.9 commit)
If your SHIM launches any other components, please provide further details on what is launched

No

If your GRUB2 launches any other binaries that are not Linux kernel in SecureBoot mode,
please provide further details on what is launched and how it enforces Secureboot lockdown

None

If you are re-using a previously used (CA) certificate, you
will need to add the hashes of the previous GRUB2 binaries
exposed to the CVEs to vendor_dbx in shim in order to prevent
GRUB2 from being able to chainload those older GRUB2 binaries. If
you are changing to a new (CA) certificate, this does not
apply. Please describe your strategy.
We will change the certificate in case of problems in the future.
How do the launched components prevent execution of unauthenticated code?
Make an image that check_signatures enabled, with grub-mkstandalone.
All files, such as settings, must be signed with the gpg key to be read.
Also, only kernels signed through Secure Boot will work.
Does your SHIM load any loaders that support loading unsigned kernels (e.g. GRUB)?
No
What kernel are you using? Which patches does it includes to enforce Secure Boot?
Alpine Linux v3.13 LTS Kernel (Kernel version is 5.10.25)
Yes.
What changes were made since your SHIM was last signed?

(None)
This is first submission.

What is the SHA256 hash of your final SHIM binary?
9d42b6fbf64d7b465582b47e3d740b44a27162cfd2728f2de67a737bd46cfea2  shimaa64.efi
9fb127e29dbf749831d8f562c9d9f018f211f99435e63295e347c3491739ce11  shimia32.efi
461bdb877c6f8a1089cbb8639b93f18e4ed740ec4fe0f329793ca3c60f0c6347  shimx64.efi

How to reproduce the build:

$ git clone https://github.com/zeronsoftn/shim-review.git
$ cd shim-review
$ git checkout -f zeronsoftn-shim-x86_64-20210416
$ ./build.sh
@joseph-zeronsoftn
Copy link
Author

Accepted ubuntu's grub looks better.
Change grub2 to 2.04-1ubuntu45 based.

git source : https://github.com/zeronsoftn/grub2/tree/zeron/2.04-1zeron02

grub SBAT:

sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
grub,1,Free Software Foundation,grub,2.04,https://www.gnu.org/software/grub/
grub.zeronsoftn,1,ZeronsoftN,grub2,2.04-1zeron02,https://github.com/zeronsoftn/grub2

@Doncuppjr
Copy link

Step 10/20 : COPY [ "patches", "/tmp/patches" ]
COPY failed: stat /var/lib/docker/tmp/docker-builder061414985/patches: no such file or directory
tar: output.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

@Doncuppjr
Copy link

Also, a 1 year cert is very short. I would guess you have your EV certificate on the SafeNET token, but is your CA private key also on an HSM?

@joseph-zeronsoftn
Copy link
Author

joseph-zeronsoftn commented Apr 15, 2021

Thanks @Doncuppjr

Both the CA certificate and the Secure Boot certificate have the key on the HSM.

The patches directory was empty, so it wasn't uploaded to git. Fixed it.
vendor_cert also increased the validity period. 2048 bit can be safe until about 2030. So we changed it to 2028.

New Review Branch:
https://github.com/zeronsoftn/shim-review/tree/zeronsoftn-shim-x86_64-20210415

New Builder Tag:
https://github.com/zeronsoftn/shim-builder/blob/zeron/15.4-1

pesign:

$ pesign --hash --padding --in=review/shimx64.efi
hash: a4c2ca98fbb2973122c273296b399e5ec53ffc27ea87b6ee49b6c417fd890d56
$ pesign --hash --padding --in=review/shimaa64.efi
hash: 9b296514189acad1e3fc5a6e2b70ff6d85ad04345e263127a2d419c389820364
$ pesign --hash --padding --in=review/shimia32.efi
hash: 5ce3e06eff8ac95c31aa4a70f3d76e56c1cdba3b3410751305e7744dd23fe586

review/hashs.txt (sha256sum):

69471abef2a6b93a54a4334e19a08fb150eeb8d04c6ec4eb091eaf3b8cb8e69c  shimaa64.efi
9633ce235c063d66bc4fb594227c6a6f517f357da1babd476a94df767cd6bc39  shimia32.efi
1f0b937c031a5a7d8b91867d65b47300c2a9d83f60d0ced51e3c53eb3e06e9d8  shimx64.efi

@Doncuppjr
Copy link

I was able to confirm the hashes. I did run into the following issue.

Successfully tagged zeron-shim-builder:latest
cp: cannot create regular file '/mnt/output/output.tar': Permission denied
tar: output.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

Also, you didn't tag your shim-review, you branched it. I would have also liked to have the build scripts in the shim-review git, not a separate one. I'll let the approver caveat anything else.

@joseph-zeronsoftn
Copy link
Author

joseph-zeronsoftn commented Apr 16, 2021

This issue has not been reproduced. The build script works fine.

I tagged it instead of a branch.
Also moved the build script to review.
https://github.com/zeronsoftn/shim-review/tree/zeronsoftn-shim-x86_64-20210416

github workflow log:
https://github.com/zeronsoftn/shim-review/runs/2358089895#step:3:3108


The hash changed because I modified the sbat

hash:

9d42b6fbf64d7b465582b47e3d740b44a27162cfd2728f2de67a737bd46cfea2  shimaa64.efi
9fb127e29dbf749831d8f562c9d9f018f211f99435e63295e347c3491739ce11  shimia32.efi
461bdb877c6f8a1089cbb8639b93f18e4ed740ec4fe0f329793ca3c60f0c6347  shimx64.efi

pesign:

$ pesign --hash --padding --in=review/shimx64.efi
hash: 747fbe0fbcb3761d54d3d45d0ccd8a353a7e9c6b34789a504a3a8936c8821062
$ pesign --hash --padding --in=review/shimaa64.efi
hash: 5bf05d07d12959c0e9dcfd2509298c79eabc8315b988c225d4b97254309250a5
$ pesign --hash --padding --in=review/shimia32.efi
hash: a98f3ca1a68490fdfd4b389630937c2202e8de9302cd9819816549ed10c7f41c

@Doncuppjr
Copy link

I still get the following error when running your script.
Successfully built 82cd2f16cc6a
Successfully tagged zeron-shim-builder:latest
cp: cannot create regular file '/mnt/output/output.tar': Permission denied
tar: output.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

aside from that, I get the following hashes
1f0b937c031a5a7d8b91867d65b47300c2a9d83f60d0ced51e3c53eb3e06e9d8 shimx64.efi
9633ce235c063d66bc4fb594227c6a6f517f357da1babd476a94df767cd6bc39 shimia32.efi
69471abef2a6b93a54a4334e19a08fb150eeb8d04c6ec4eb091eaf3b8cb8e69c shimaa64.efi

I think your sbat entry shouldn't point to a tree, but rather be a point of contact, so maybe just https://github.com/zeronsoftn/shim-builder and not the exact tree, right now I get the following entry which does not match the submission.

d0000 73626174 2c312c53 42415420 56657273 sbat,1,SBAT Vers
d0010 696f6e2c 73626174 2c312c68 74747073 ion,sbat,1,https
d0020 3a2f2f67 69746875 622e636f 6d2f7268 ://github.com/rh
d0030 626f6f74 2f736869 6d2f626c 6f622f6d boot/shim/blob/m
d0040 61696e2f 53424154 2e6d640a 7368696d ain/SBAT.md.shim
d0050 2c312c55 45464920 7368696d 2c736869 ,1,UEFI shim,shi
d0060 6d2c312c 68747470 733a2f2f 67697468 m,1,https://gith
d0070 75622e63 6f6d2f72 68626f6f 742f7368 ub.com/rhboot/sh
d0080 696d0a73 68696d2e 7a65726f 6e736f66 im.shim.zeronsof
d0090 746e2c31 2c5a6572 6f6e736f 66744e2c tn,1,ZeronsoftN,
d00a0 7368696d 2c31352e 342c6874 7470733a shim,15.4,https:
d00b0 2f2f6769 74687562 2e636f6d 2f7a6572 //github.com/zer
d00c0 6f6e736f 66746e2f 7368696d 2d627569 onsoftn/shim-bui
d00d0 6c646572 2f747265 652f7a65 726f6e2f lder/tree/zeron/
d00e0 31352e34 2d310a 15.4-1.

@jc-lab
Copy link

jc-lab commented Apr 16, 2021

The shim-builder repository is deprecated.
I moved the Dockerfile to the shim-review repository and modified the sbat as well.

In the last comment I said.

Also moved the build script to review
The hash changed because I modified the sbat

New sbat:
https://github.com/zeronsoftn/shim-review/blob/zeronsoftn-shim-x86_64-20210416/docker/sbat.csv

The output.tar error seems to be due to your environment.
The github workflow worked fine too.
You can check the workflow log in the comments above.

The Dockerfile itself prints the hash.
So, to check reproduce, you can delete all below line 16 of build.sh.
https://github.com/zeronsoftn/shim-review/blob/9b8fdd7f394ded4c12f646f469dbce6fac973349/build.sh#L16

@steve-mcintyre
Copy link
Collaborator

The builds are reproducible here for me - good

@steve-mcintyre
Copy link
Collaborator

You're using a plain 15.4 build, which is good. Except... :-(

There are two patches since 15.4 that you're likely to want:

4068fd42 mok: allocate MOK config table as BootServicesData
5b3ca0d2 Fix a broken file header on ia32

The first is important if your kernel includes https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7e1550b8f20
The second is important if you're building for ia32 (as you are)

@steve-mcintyre
Copy link
Collaborator

Looking at your grub next.

Also: you're using the kernel from Alpine? What SB/lockdown patches do they have included?

@steve-mcintyre
Copy link
Collaborator

Cool, grub looks good. Obviously, you'll need to make a small tweak to the build to add your own SBAT data rather than Ubuntu's.

@steve-mcintyre steve-mcintyre added new vendor This is a new vendor question Reviewer(s) waiting on response labels Apr 19, 2021
@joseph-zeronsoftn
Copy link
Author

joseph-zeronsoftn commented Apr 19, 2021

SBAT section will be put in through grub2-mkstandalone. So don't have to touch the grub2 source tree. :)
Thank you.

The following patch have been applied to the kernel version.
torvalds/linux@75b0cea :
image

4068fd42 mok: allocate MOK config table as BootServicesData
5b3ca0d2 Fix a broken file header on ia32

I applied the above two patches.
patched tag:

hashs:

4e77e5f08b1cf00b8fcaad705320753ad05aa0b3ef27a9e24de7da78b0de1168  shimaa64.efi
395fd34c1ce3f784c75a2a19841d24cd419653bf72411b5b37b901c7bb864e70  shimia32.efi
077058201d81596f9a115bcc1023c77608d5ed4a128239673fa043de3513d2be  shimx64.efi

pesign:

shimaa64.efi : 1c9aa645d239a812b406189e08c37dcd64003afbaa3780e5533f92d6a7184e39
shimia32.efi : b7de13f6145076843e477ab1920da19bb00d885add4cc62793fda9e77d259e5f
shimx64.efi : 9812e22f2813f109fe515c4ebf94d760516c62290da2e1046ca9fd040109c73d

@steve-mcintyre steve-mcintyre removed the question Reviewer(s) waiting on response label Apr 19, 2021
@steve-mcintyre
Copy link
Collaborator

Sorry to do this to you, but I should also point out more issues that you may want to add patches for - see #165 . If you expect to work on older Mac systems, you will definitely want to take the fix for #364

@joseph-zeronsoftn
Copy link
Author

@steve-mcintyre Thanks for the advice. I also saw the issue.
By the way, our solution does not support Mac System. So #364 is not needed.
But if #364 doesn't apply, can have possibly any security issues? Otherwise, I don't think I need it.
I also built arm64 just in case, but I don't need it right now.

@steve-mcintyre
Copy link
Collaborator

Bug #364 isn't a security bug, it stops machines with older EFI firmware (like older Macs) from booting. If that's not a worry for you, then you're probably good here. I'm happy, but I'd like to get a second reviewer to look too. I'll go and prod some people...

@steve-mcintyre steve-mcintyre added the extra review wanted Initial review(s) look good, another review desired label Apr 25, 2021
@jsetje
Copy link
Collaborator

jsetje commented Apr 26, 2021

I'm unable to run the docker build, did something change?

E: Malformed entry 2 in list file /etc/apt/sources.list (URI parse) E: The list of sources could not be read. The command '/bin/sh -c mkdir -p /work && echo "\ndeb $APT_REPO focal main restricted universe multiverse\ndeb $APT_REPO focal-updates main restricted universe multiverse\ndeb $APT_REPO focal-backports main restricted universe multiverse\ndeb $APT_REPO focal-security main restricted universe multiverse\n" | tee /etc/apt/sources.list && apt-get update -y && apt-get install -y ca-certificates openssl coreutils bash curl tar xz-utils bzip2 git sed diffutils patch make pesign libelf-dev binutils-x86-64-linux-gnu gcc binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu' returned a non-zero code: 100

@steve-mcintyre
Copy link
Collaborator

"build.sh" is a wrapper which sets variables for the docker build. Not ideal, but it worked for me.

I think lots of people are not used to driving docker with just "docker build ." etc. :-/

@Doncuppjr
Copy link

Everybody loves a wrapper.

@jsetje
Copy link
Collaborator

jsetje commented Apr 26, 2021

Thanks! That script then runs _build_impl.sh which uses http://mirror.kakao.com/ubuntu/ is that an official ubuntu mirror?

@jc-lab
Copy link

jc-lab commented Apr 26, 2021

This is a very popular mirror in South Korea.
This is an Official Mirror and can be found under the name Kakao Corp.
https://launchpad.net/ubuntu/+archivemirrors

@steve-mcintyre
Copy link
Collaborator

Hmm, looking again... arm64 shim is being quite problematic for people at the moment. If you're not looking to actively use it immediately, then you might be better to hang back. (See issue #366 for more details)

@jc-lab
Copy link

jc-lab commented Apr 27, 2021

I also saw the issue.
The arm64 build is not yet in use, but is for the future.
So far we only need x86.

@jsetje
Copy link
Collaborator

jsetje commented Apr 27, 2021

If you don't need the arm shim urgently today, I would like to urge you to drop the arm shim at this point. You can then submit another review when you are ready to use it and the arm builds are more mature and stable. It should be pretty simple to get a quick review that's essentially the same as a previously approved ia32/x64 one.

@jsetje
Copy link
Collaborator

jsetje commented Apr 27, 2021

FWIW, your ia32 and x64 builds do reproduce for me.

@joseph-zeronsoftn
Copy link
Author

Thank you. Please ignore arm64 in this review.

We need shim very soon to get our new products to market. What else is needed for this review to be accepted?

@steve-mcintyre steve-mcintyre added accepted Submission is ready for sysdev and removed extra review wanted Initial review(s) look good, another review desired labels Apr 27, 2021
@steve-mcintyre
Copy link
Collaborator

Marking accepted now

@joseph-zeronsoftn
Copy link
Author

Thanks to everyone in the review process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Submission is ready for sysdev new vendor This is a new vendor
Projects
None yet
Development

No branches or pull requests

4 participants