avatarTeri Radichel

Summary

The web content discusses the implementation of GitHub Protected Branches and Rulesets to enhance repository security by preventing unauthorized changes, with a focus on automating these security measures and their potential impact on preventing breaches like the SolarWinds hack.

Abstract

The article emphasizes the importance of GitHub Protected Branches and Rulesets in maintaining code integrity and preventing security breaches. It provides insights into how protected branches can restrict certain actions, such as deletions and merges, and require specific conditions like signed commits. The author references the SolarWinds breach as an example of where such protections might have mitigated the introduction of malicious code. The content also explores the use of the GitHub API for automating the creation and management of protected branches and rulesets, which are not currently supported by the GitHub CLI. The author plans to add automation code for these features in future posts and discusses the layering of multiple rulesets to ensure comprehensive security compliance.

Opinions

  • The author suggests that the security controls provided by protected branches could have potentially prevented the SolarWinds breach.
  • It is implied that automating protected branches and rulesets using the GitHub API is necessary due to the lack of support in the GitHub CLI.
  • The author expresses the need for layering rulesets to ensure that the most restrictive security measures are applied.
  • There is an opinion that the aggregation of rules from multiple rulesets provides a robust mechanism for enforcing compliance.
  • The author intends to enhance their GitHub repository script by adding automation for creating security rules, indicating a commitment to continuous improvement in security practices.
  • The article promotes the idea that enforcing code reviews at certain stages of the workflow is beneficial, though it does not elaborate on the specific benefits.
  • The author's background and credentials in cybersecurity are presented to establish credibility and expertise on the subject matter.

Protected Git Branches

ACM.234 GitHub Protected branches and Rulesets to prevent unauthorized and unwanted deletions, merges, and unsigned commits

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

⚙️ Part of my series on Automating Cybersecurity Metrics. The Code.

🔒 Related Stories: GitHub Security | Application Security | Secure Code

💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In the last post I wrote about preventing sensitive files from getting into your repo using a .gitignore file.

GitHub Protected Branches

Creating a protected Git Branch disables certain settings that prevent unauthorized changes to your code unless you allow them.

These settings may have helped prevent the SolarWinds breach, though I don’t have full insight into exactly how the code got into the packet sent to customers. Some additional security controls may have been required after the point the code leaves source control. As a reminder this was the largest breach of the US government in history at the time it occurred. Somehow the attackers inserted code into product update process.

Here are some of the settings that are disabled and only enabled if you take the step to all them.

Here’s the link to set up a protected branch on GitHub

I took a look at the options currently associated with repo for the GitHub CLI commit command. I don’t see anything here for enabling protected repos or rulesets.

In order to automate protected branches it appears that we need to use the GitHub API. I’ll add this code in an upcoming post.

GitHub Rulesets

Related to protected repos are GitHub rulesets. Here’s a list of rules you can create and apply to branches.

From the documentation:

Unlike protection rules, multiple rulesets can apply at the same time, so you can be confident that every rule targeting a branch or tag in your repository will be evaluated when someone interacts with that branch or tag.

You can layer rulesets:

A ruleset does not have a priority. Instead, if multiple rulesets target the same branch or tag in a repository, the rules in each of these rulesets are aggregated. If the same rule is defined in different ways across the aggregated rulesets, the most restrictive version of the rule applies.

I also see no options for rulesets with the GitHub CLI.

Once again we’re looking at the API for this functionality.

Protections, rules, and compliance

With the above rules you could set up a mechanism to automatically fail non-compliant commits.

Protections, rules, and code reviews

One of the things you can do with these rules is enforce code reviews at certain points in your workflow.

I’ll add the automation to create some rules to my GitHub repo script at some point.

Follow for updates.

Teri Radichel | © 2nd Sight Lab 2023

About Teri Radichel:
~~~~~~~~~~~~~~~~~~~~
⭐️ Author: Cybersecurity Books
⭐️ Presentations: Presentations by Teri Radichel
⭐️ Recognition: SANS Award, AWS Security Hero, IANS Faculty
⭐️ Certifications: SANS ~ GSE 240
⭐️ Education: BA Business, Master of Software Engineering, Master of Infosec
⭐️ Company: Penetration Tests, Assessments, Phone Consulting ~ 2nd Sight Lab
Need Help With Cybersecurity, Cloud, or Application Security?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
🔒 Request a penetration test or security assessment
🔒 Schedule a consulting call
🔒 Cybersecurity Speaker for Presentation
Follow for more stories like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
❤️ Sign Up my Medium Email List
❤️ Twitter: @teriradichel
❤️ LinkedIn: https://www.linkedin.com/in/teriradichel
❤️ Mastodon: @teriradichel@infosec.exchange
❤️ Facebook: 2nd Sight Lab
❤️ YouTube: @2ndsightlab
Github
Protected Branch
Ruleset
Security
Secure Code
Recommended from ReadMedium