Changeset 106968 in vbox for trunk/src/VBox
- Timestamp:
- Nov 12, 2024 4:35:48 PM (3 months ago)
- Location:
- trunk/src/VBox/HostDrivers/Support
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/Makefile.kmk
r106945 r106968 120 120 TimeRootOracle1=Timestamp-VBoxLegacyWinSha1CA.taf \ 121 121 TrustedCertVBox0=Trusted-OracleCorporationVirtualBox-05308b76ac2e15b29720fb4395f65f38.taf \ 122 TrustedCertVBox1=Trusted-OracleAmerica-060e2f8f9e1b8be518d5fe2b69cfccb1.taf \ 122 123 AppleRoot0=AppleRoot-2bd06947947609fef46b8d2e40a6f7474d7f085e.taf \ 123 124 AppleRoot1=AppleRoot-G2-c499136c1803c27bc0a3a00d7f72807a1c77268d.taf -
trunk/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
r106061 r106968 1875 1875 { 1876 1876 # ifdef VBOX_WITH_HARDENING 1877 uint32_t fFlags = SUPHNTVI_F_REQUIRE_KERNEL_CODE_SIGNING; 1877 /** @todo do we need to validate the fMaybe3rdParty claim here? I.e. only 1878 * apply it if 'ExtensionPacks' is part of the path. */ 1879 uint32_t fFlags = SUPHNTVI_F_REQUIRE_CODE_SIGNING; 1878 1880 if (!fMaybe3rdParty) 1879 1881 fFlags = SUPHNTVI_F_REQUIRE_BUILD_CERT; -
trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerify-win.h
r106061 r106968 146 146 * was signed with. */ 147 147 # define SUPHNTVI_F_REQUIRE_BUILD_CERT RT_BIT(0) 148 /** The signing certificate must be one the build certificate or one of the 149 * one used by Oracle to sign the extension pack. */ 150 # define SUPHNTVI_F_REQUIRE_SPECIAL_TRUST_CERT RT_BIT(1) 151 /** Require regular code signing. */ 152 # define SUPHNTVI_F_REQUIRE_CODE_SIGNING RT_BIT(2) 148 153 /** Require kernel code signing level. */ 149 # define SUPHNTVI_F_REQUIRE_KERNEL_CODE_SIGNING RT_BIT( 1)154 # define SUPHNTVI_F_REQUIRE_KERNEL_CODE_SIGNING RT_BIT(3) 150 155 /** Require the image to force the memory mapper to do signature checking. */ 151 # define SUPHNTVI_F_REQUIRE_SIGNATURE_ENFORCEMENT RT_BIT( 2)156 # define SUPHNTVI_F_REQUIRE_SIGNATURE_ENFORCEMENT RT_BIT(4) 152 157 /** Whether to allow image verification by catalog file. */ 153 # define SUPHNTVI_F_ALLOW_CAT_FILE_VERIFICATION RT_BIT( 3)158 # define SUPHNTVI_F_ALLOW_CAT_FILE_VERIFICATION RT_BIT(5) 154 159 /** The file owner must be TrustedInstaller, Builtin\\Administrators 155 160 * (S-1-5-32-544) or local system (S-1-5-21) on Vista+. */ 156 # define SUPHNTVI_F_TRUSTED_INSTALLER_OR_SIMILAR_OWNER RT_BIT( 4)161 # define SUPHNTVI_F_TRUSTED_INSTALLER_OR_SIMILAR_OWNER RT_BIT(6) 157 162 /** Ignore the image architecture (otherwise it must match the verification 158 163 * code). Used with resource images and such. */ … … 229 234 #endif /* IN_RING3 && !VBOX_PERMIT_EVEN_MORE */ 230 235 extern SUPSYSROOTDIRBUF g_SupLibHardenedExeNtPath; 231 extern SUPSYSROOTDIRBUF g_SupLibHardenedAppBinNtPath;232 236 233 237 # ifdef IN_RING0 -
trunk/src/VBox/HostDrivers/Support/win/SUPHardenedVerifyImage-win.cpp
r106893 r106968 130 130 /** The build certificate. */ 131 131 static RTCRX509CERTIFICATE g_BuildX509Cert; 132 133 /** Store for certificates that we put special trust it, like the build 134 * certificate and the ones used by the Oracle extension pack. */ 135 static RTCRSTORE g_hSpecialTrustStore = NIL_RTCRSTORE; 132 136 133 137 /** Store for root software publisher certificates. */ … … 771 775 RT_NOREF1(hLdrMod); 772 776 773 if (fFlags & (SUPHNTVI_F_REQUIRE_BUILD_CERT | SUPHNTVI_F_REQUIRE_KERNEL_CODE_SIGNING)) 777 if (fFlags & ( SUPHNTVI_F_REQUIRE_BUILD_CERT 778 | SUPHNTVI_F_REQUIRE_SPECIAL_TRUST_CERT 779 | SUPHNTVI_F_REQUIRE_CODE_SIGNING 780 | SUPHNTVI_F_REQUIRE_KERNEL_CODE_SIGNING)) 774 781 return rc; 775 782 … … 1042 1049 1043 1050 /* 1044 * Standard code signing capabilites required .1051 * Standard code signing capabilites required (SUPHNTVI_F_REQUIRE_CODE_SIGNING is implied here). 1045 1052 */ 1046 1053 int rc = RTCrPkcs7VerifyCertCallbackCodeSigning(pCert, hCertPaths, fFlags, NULL, pErrInfo); … … 1201 1208 g_BuildX509Cert.TbsCertificate.SerialNumber.Asn1Core.uData.pv); 1202 1209 } 1210 /** @todo apply these to all signatures, but don't fail in a bad way for 1211 * stuff with extra signatures (typically from microsoft). */ 1212 else if ( (pNtViRdr->fFlags & SUPHNTVI_F_REQUIRE_SPECIAL_TRUST_CERT) 1213 && pInfo->iSignature == 0) 1214 { 1215 PCRTCRCERTCTX const pCertCtx = RTCrStoreCertByIssuerAndSerialNo(g_hSpecialTrustStore, 1216 &pSignerInfo->IssuerAndSerialNumber.Name, 1217 &pSignerInfo->IssuerAndSerialNumber.SerialNumber); 1218 if (!pCertCtx) 1219 return RTErrInfoSetF(pErrInfo, VERR_SUP_VP_NOT_SIGNED_WITH_SPECIALLY_TRUSTED_CERT, 1220 "Signature #%u/%u: Not signed with the build certificate or any of the specially trusted ones (serial %.*Rhxs)", 1221 pInfo->iSignature + 1, pInfo->cSignatures, 1222 pSignerInfo->IssuerAndSerialNumber.SerialNumber.Asn1Core.cb, 1223 pSignerInfo->IssuerAndSerialNumber.SerialNumber.Asn1Core.uData.pv); 1224 RTCrCertCtxRelease(pCertCtx); 1225 } 1203 1226 1204 1227 /* … … 1272 1295 1273 1296 #ifdef IN_RING3 /* Hack alert! (see above) */ 1274 if ((pNtViRdr->fFlags & SUPHNTVI_F_REQUIRE_BUILD_CERT) && g_uBuildTimestampHack == 0 && cTimes > 1) 1297 if ( (pNtViRdr->fFlags & (SUPHNTVI_F_REQUIRE_BUILD_CERT | SUPHNTVI_F_REQUIRE_SPECIAL_TRUST_CERT)) 1298 && g_uBuildTimestampHack == 0 1299 && cTimes > 1) 1275 1300 g_uBuildTimestampHack = uTimestamp; 1276 1301 #endif … … 1325 1350 1326 1351 /* This leniency is not applicable to build certificate requirements (signature #1 only). */ 1327 if ( !(pNtViRdr->fFlags & SUPHNTVI_F_REQUIRE_BUILD_CERT)1352 if ( !(pNtViRdr->fFlags & (SUPHNTVI_F_REQUIRE_BUILD_CERT | SUPHNTVI_F_REQUIRE_SPECIAL_TRUST_CERT)) 1328 1353 || pInfo->iSignature != 0) 1329 1354 { … … 1993 2018 */ 1994 2019 rc = supHardNtViCertInit(&g_BuildX509Cert, g_abSUPBuildCert, g_cbSUPBuildCert, pErrInfo, "BuildCertificate"); 2020 SUPTAENTRY const aBuildCerts[1] = { { g_abSUPBuildCert, g_cbSUPBuildCert }, }; 2021 if (RT_SUCCESS(rc)) 2022 rc = supHardNtViCertStoreInit(&g_hSpecialTrustStore, 2023 aBuildCerts, RT_ELEMENTS(aBuildCerts), 2024 g_aSUPTrustedTAs, g_cSUPTrustedTAs, 2025 NULL, 0, 2026 pErrInfo, "SpecialTrustStore"); 1995 2027 if (RT_SUCCESS(rc)) 1996 2028 rc = supHardNtViCertStoreInit(&g_hSpcRootStore, g_aSUPSpcRootTAs, g_cSUPSpcRootTAs, … … 2076 2108 RTCrStoreRelease(g_hSpcRootStore); 2077 2109 g_hSpcRootStore = NIL_RTCRSTORE; 2110 2111 RTCrStoreRelease(g_hSpecialTrustStore); 2112 g_hSpecialTrustStore = NIL_RTCRSTORE; 2078 2113 } 2079 2114 -
trunk/src/VBox/HostDrivers/Support/win/SUPR3HardenedMain-win.cpp
r106897 r106968 318 318 SUPSYSROOTDIRBUF g_SupLibHardenedExeNtPath; 319 319 /** The NT path of the application binary directory. */ 320 SUPSYSROOTDIRBUF g_SupLibHardenedAppBinNtPath; 320 static SUPSYSROOTDIRBUF g_SupLibHardenedAppBinNtPath; 321 /** The NT path of the extension packs directory. */ 322 static SUPSYSROOTDIRBUF g_SupLibHardenedExtPacksNtPath; 321 323 /** The offset into g_SupLibHardenedExeNtPath of the executable name (WCHAR, 322 324 * not byte). This also gives the length of the exectuable directory path, … … 1509 1511 * 1. System32 - normal code or cat signing, owner TrustedInstaller/Administrators/LocalSystem. 1510 1512 * 2. WinSxS - normal code or cat signing, owner TrustedInstaller/Administrators/LocalSystem. 1511 * 3. VirtualBox - build with: 1513 * 3. ExtPacks - VBox built with: 1514 * - regular code signing cert: regular code signing, owner TrustedInstaller/Administrators/LocalSystem. 1515 * - kernel code signing cert: kernel code signing and integrity checks. 1516 * 4. VirtualBox - VBox built with: 1512 1517 * - regular code signing cert: build cert code signing, owner TrustedInstaller/Administrators/LocalSystem. 1513 1518 * - kernel code signing cert: kernel code signing and integrity checks. 1514 * 4. AppPatchDir - normal code or cat signing, owner TrustedInstaller/Administrators/LocalSystem.1515 * 5. Program Files - normal code or cat signing, owner TrustedInstaller/Administrators/LocalSystem.1516 * 6. Common Files - normal code or cat signing, owner TrustedInstaller/Administrators/LocalSystem.1517 * 7. x86 variations of 4 & 5- ditto.1519 * 5. AppPatchDir - normal code or cat signing, owner TrustedInstaller/Administrators/LocalSystem. 1520 * 6. Program Files - normal code or cat signing, owner TrustedInstaller/Administrators/LocalSystem. 1521 * 7. Common Files - normal code or cat signing, owner TrustedInstaller/Administrators/LocalSystem. 1522 * 8. x86 variations of 5 & 6 - ditto. 1518 1523 * 1519 1524 * Note! VBOX_WITHOUT_KERNEL_CODE_SIGNING_CERT means the /IntegrityCheck does … … 1527 1532 else if (supHardViUniStrPathStartsWithUniStr(&uBuf.UniStr, &g_WinSxSNtPath.UniStr, true /*fCheckSlash*/)) 1528 1533 fFlags |= SUPHNTVI_F_ALLOW_CAT_FILE_VERIFICATION | SUPHNTVI_F_TRUSTED_INSTALLER_OR_SIMILAR_OWNER; 1534 else if (supHardViUniStrPathStartsWithUniStr(&uBuf.UniStr, &g_SupLibHardenedExtPacksNtPath.UniStr, true /*fCheckSlash*/)) 1535 # ifdef VBOX_WITHOUT_WINDOWS_KERNEL_CODE_SIGNING_CERT 1536 fFlags |= SUPHNTVI_F_REQUIRE_CODE_SIGNING | SUPHNTVI_F_TRUSTED_INSTALLER_OR_SIMILAR_OWNER; 1537 # else 1538 fFlags |= SUPHNTVI_F_REQUIRE_KERNEL_CODE_SIGNING | SUPHNTVI_F_REQUIRE_SIGNATURE_ENFORCEMENT; 1539 # endif 1529 1540 else if (supHardViUniStrPathStartsWithUniStr(&uBuf.UniStr, &g_SupLibHardenedAppBinNtPath.UniStr, true /*fCheckSlash*/)) 1530 1541 # ifdef VBOX_WITHOUT_WINDOWS_KERNEL_CODE_SIGNING_CERT 1531 /** @todo r=bird: See SUPHNTVI_F_REQUIRE_BUILD_CERT comment below (in the1532 * code that's actually used). */1533 1542 fFlags |= SUPHNTVI_F_REQUIRE_BUILD_CERT | SUPHNTVI_F_TRUSTED_INSTALLER_OR_SIMILAR_OWNER; 1534 1543 # else … … 1575 1584 * Require trusted installer + some kind of signature on everything, except 1576 1585 * for the VBox bits where we have extra requirements depending on the signing 1577 * certificate used: 1578 * - regular code signing cert: build cert code signing, owner TrustedInstaller/Administrators/LocalSystem. 1579 * - kernel code signing cert: kernel code signing and integrity checks. 1586 * certificate used. 1587 * 1. ExtPacks - VBox built with: 1588 * - regular code signing cert: regular code signing, owner TrustedInstaller/Administrators/LocalSystem. 1589 * - kernel code signing cert: kernel code signing and integrity checks. 1590 * 2. VirtualBox - VBox built with: 1591 * - regular code signing cert: build cert code signing, owner TrustedInstaller/Administrators/LocalSystem. 1592 * - kernel code signing cert: kernel code signing and integrity checks. 1593 * 3. Everything else: allow .cat-file verification, , owner TrustedInstaller/Administrators/LocalSystem. 1580 1594 */ 1581 1595 uint32_t fFlags = 0; 1582 if (supHardViUniStrPathStartsWithUniStr(&uBuf.UniStr, &g_SupLibHardened AppBinNtPath.UniStr, true /*fCheckSlash*/))1596 if (supHardViUniStrPathStartsWithUniStr(&uBuf.UniStr, &g_SupLibHardenedExtPacksNtPath.UniStr, true /*fCheckSlash*/)) 1583 1597 # ifdef VBOX_WITHOUT_WINDOWS_KERNEL_CODE_SIGNING_CERT 1584 /** @todo r=bird: Since extension packs are installed under 1585 * g_SupLibHardenedAppBinNtPath and I'm pretty sure that everything loaded into 1586 * a VBox VM process goes thru this validation step at DLL load time, this means 1587 * only we can now sign extension packs. 1588 * 1589 * I suspect we have to relax the signing restrictions on the ExtensionPacks 1590 * subdirectory to keep 3rd party extensions working. */ 1598 fFlags |= SUPHNTVI_F_REQUIRE_CODE_SIGNING | SUPHNTVI_F_TRUSTED_INSTALLER_OR_SIMILAR_OWNER; 1599 # else 1600 fFlags |= SUPHNTVI_F_REQUIRE_KERNEL_CODE_SIGNING | SUPHNTVI_F_REQUIRE_SIGNATURE_ENFORCEMENT; 1601 # endif 1602 else if (supHardViUniStrPathStartsWithUniStr(&uBuf.UniStr, &g_SupLibHardenedAppBinNtPath.UniStr, true /*fCheckSlash*/)) 1603 # ifdef VBOX_WITHOUT_WINDOWS_KERNEL_CODE_SIGNING_CERT 1591 1604 fFlags |= SUPHNTVI_F_REQUIRE_BUILD_CERT | SUPHNTVI_F_TRUSTED_INSTALLER_OR_SIMILAR_OWNER; 1592 1605 # else … … 5993 6006 5994 6007 /** 5995 * Initializes the application binary directory path .6008 * Initializes the application binary directory path and the extpacks path. 5996 6009 * 5997 6010 * This is called once or twice. … … 6036 6049 g_SupLibHardenedAppBinNtPath.UniStr.MaximumLength = sizeof(g_SupLibHardenedAppBinNtPath.awcBuffer); 6037 6050 SUP_DPRINTF(("supR3HardenedWinInitAppBin(%#x): '%ls'\n", fFlags, g_SupLibHardenedAppBinNtPath.UniStr.Buffer)); 6051 6052 /* Extension packs: */ 6053 static wchar_t const s_wszExtPacks[] = L"\\ExtensionPacks"; 6054 if (g_SupLibHardenedAppBinNtPath.UniStr.Buffer[cwc - 1] == '\\' || g_SupLibHardenedAppBinNtPath.UniStr.Buffer[cwc - 1] == '/') 6055 cwc--; 6056 if (cwc + RT_ELEMENTS(s_wszExtPacks) > RT_ELEMENTS(g_SupLibHardenedExtPacksNtPath.awcBuffer)) 6057 supR3HardenedFatal("supR3HardenedWinInitAppBin: Location is too deep! (cwc=%#x)\n", cwc); 6058 g_SupLibHardenedExtPacksNtPath.UniStr.Buffer = g_SupLibHardenedExtPacksNtPath.awcBuffer; 6059 memcpy(g_SupLibHardenedExtPacksNtPath.UniStr.Buffer, g_SupLibHardenedAppBinNtPath.UniStr.Buffer, cwc * sizeof(WCHAR)); 6060 memcpy(&g_SupLibHardenedExtPacksNtPath.UniStr.Buffer[cwc], s_wszExtPacks, RT_ELEMENTS(s_wszExtPacks) * sizeof(WCHAR)); 6061 g_SupLibHardenedExtPacksNtPath.UniStr.Length = (cwc + RT_ELEMENTS(s_wszExtPacks) - 1) * sizeof(WCHAR); 6062 g_SupLibHardenedExtPacksNtPath.UniStr.MaximumLength = sizeof(g_SupLibHardenedExtPacksNtPath.awcBuffer); 6038 6063 } 6039 6064
Note:
See TracChangeset
for help on using the changeset viewer.