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

santad: add critical system binaries #296

Merged
merged 3 commits into from Sep 20, 2018
Merged

Conversation

tburgin
Copy link
Member

@tburgin tburgin commented Sep 19, 2018

  • In Mojave /usr/libexec/trustd needs to run in order to check arbitrary code signatures. This may be a departure from previous version of macOS. If trustd is killed, Santa can cause a deadlock. This fix pre-validates and whitelists trustd at santad startup time.
  • Fixes System freeze on MacOS Mojave #295

fileSHA256:nil
certificateSHA256:csInfo.leafCertificate.SHA256];
cd.certCommonName = csInfo.leafCertificate.commonName;
cd.certCommonName = csInfo.leafCertificate.commonName;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might be easier to follow if it were structured as

if (!cd) {
  // declare csInfo
  if (binInfo.isMachO) {
    // get csInfo
  }
  // get cd from policyProcessor
}

instead of having two separate checks for !cd

Copy link
Member Author

Choose a reason for hiding this comment

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

done

cd.certCommonName = csInfo.leafCertificate.commonName;

bins[binInfo.SHA256] = cd;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

log error if signing info doesn't match?

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea

// TODO(tburgin): Add the Santa components to this feature and remove the santadCertSHA rule.
NSMutableDictionary *bins = [NSMutableDictionary dictionary];
for (NSString *path in @[ @"/usr/libexec/trustd" ]) {
SNTFileInfo *binInfo = [[SNTFileInfo alloc] initWithPath:path];
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this fail the right way if there's no file at path? I'm guessing csInfo will end up nil and then the call to signingInformationMatches: will return NO?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, if csInfo is nil, sending any message to it will return nil.

@@ -116,21 +116,28 @@ - (void)validateBinaryWithMessage:(santa_message_t)message {
}

// Get codesigning info about the file but only if it's a Mach-O.
// If the binary is a critical system binary, don't check its signiture. The binary was validated
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: signiture -> signature

Copy link
Member Author

Choose a reason for hiding this comment

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

oops

Copy link
Member Author

@tburgin tburgin left a comment

Choose a reason for hiding this comment

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

PTAL

// TODO(tburgin): Add the Santa components to this feature and remove the santadCertSHA rule.
NSMutableDictionary *bins = [NSMutableDictionary dictionary];
for (NSString *path in @[ @"/usr/libexec/trustd" ]) {
SNTFileInfo *binInfo = [[SNTFileInfo alloc] initWithPath:path];
Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, if csInfo is nil, sending any message to it will return nil.

cd.certCommonName = csInfo.leafCertificate.commonName;

bins[binInfo.SHA256] = cd;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

good idea

@@ -116,21 +116,28 @@ - (void)validateBinaryWithMessage:(santa_message_t)message {
}

// Get codesigning info about the file but only if it's a Mach-O.
// If the binary is a critical system binary, don't check its signiture. The binary was validated
Copy link
Member Author

Choose a reason for hiding this comment

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

oops

fileSHA256:nil
certificateSHA256:csInfo.leafCertificate.SHA256];
cd.certCommonName = csInfo.leafCertificate.commonName;
cd.certCommonName = csInfo.leafCertificate.commonName;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

done

nguyen-phillip
nguyen-phillip previously approved these changes Sep 20, 2018
@tburgin
Copy link
Member Author

tburgin commented Sep 20, 2018

PTAL

Copy link
Contributor

@nguyen-phillip nguyen-phillip left a comment

Choose a reason for hiding this comment

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

LGTM

@tburgin tburgin merged commit 90b894b into google:master Sep 20, 2018
@ameyah
Copy link

ameyah commented Sep 21, 2018

Thanks a ton for this fix @tburgin

I was wondering when the next release would be? :)

@russellhancox
Copy link
Collaborator

A couple of hours, most likely

@ameyah
Copy link

ameyah commented Sep 21, 2018

Awesome, Thanks again!

dskfh pushed a commit to dskfh/santa that referenced this pull request Jul 17, 2020
* santad: add critical system binaries

* review updates

* use a getter
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.

System freeze on MacOS Mojave
4 participants