Skip to content

Commit a6b5d9c

Browse files
authored
Merge pull request #24900 from brave/bsc-elevation-service-trusted-path
Implement a trusted source check for `Elevator::InstallVPNServices`
2 parents d37c544 + 367ed6f commit a6b5d9c

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

chromium_src/chrome/elevation_service/elevator.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,38 @@
2828
namespace elevation_service {
2929

3030
HRESULT Elevator::InstallVPNServices() {
31+
// Perform a trusted source check.
32+
// This ensures the caller is an executable in `%PROGRAMFILES%`.
33+
// For more info, see https://github.com/brave/brave-core/pull/24900
34+
HRESULT hr = ::CoImpersonateClient();
35+
if (FAILED(hr)) {
36+
return hr;
37+
}
38+
39+
{
40+
absl::Cleanup revert_to_self = [] { ::CoRevertToSelf(); };
41+
42+
const auto process = GetCallingProcess();
43+
if (!process.IsValid()) {
44+
return kErrorCouldNotObtainCallingProcess;
45+
}
46+
const auto validation_data = GenerateValidationData(
47+
ProtectionLevel::PROTECTION_PATH_VALIDATION, process);
48+
if (!validation_data.has_value()) {
49+
return validation_data.error();
50+
}
51+
const auto data = std::vector<uint8_t>(validation_data->cbegin(),
52+
validation_data->cend());
53+
54+
// Note: Validation should always be done using caller impersonation token.
55+
std::string log_message;
56+
HRESULT validation_result = ValidateData(process, data, &log_message);
57+
if (FAILED(validation_result)) {
58+
return validation_result;
59+
}
60+
}
61+
// End of trusted source check
62+
3163
#if BUILDFLAG(ENABLE_BRAVE_VPN)
3264
if (!brave_vpn::IsBraveVPNHelperServiceInstalled()) {
3365
auto success = brave_vpn::InstallBraveVPNHelperService(

wq

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Implement a trusted source check for Elevator::InstallVPNServices
2+
3+
Fixes https://github.com/brave/brave-browser/issues/39029
4+
5+
This is based on an example from Chromium in:
6+
https://source.chromium.org/chromium/chromium/src/+/main:chrome/elevation_service/elevator.cc
7+
8+
Please see the references in the code there to `ValidateData`.
9+
10+
# Please enter the commit message for your changes. Lines starting
11+
# with '#' will be ignored, and an empty message aborts the commit.
12+
#
13+
# Date: Tue Jul 23 16:26:01 2024 -0700
14+
#
15+
# On branch bsc-elevation-service-trusted-path
16+
# Your branch is up to date with 'origin2/bsc-elevation-service-trusted-path'.
17+
#
18+
# Changes to be committed:
19+
# modified: chromium_src/chrome/elevation_service/elevator.cc
20+
#

0 commit comments

Comments
 (0)