angietechcafe.medium.com 7 min read Original Source

CI/CD and Build Security TryHackMe Writeup | THM Walkthrough

DevOps + Cloud Security Series by Angie

Hello everyone! In today’s post, I will walk you through TryHackMe’s CI/CD and Build Security room. This is part of the DevSecOps learning path. I will also note that this is a paid room. Let’s begin!

What is CI/CD and Build Security?

What element of a CI/CD pipeline coordinates and manages the automation of build and deployment environments?

Flag: build orchestrator

  • The build orchestrator is an essential component of a CI/CD pipeline. It manages the automation of build and deployment environments, ensuring that all steps in the pipeline are executed properly, with correct resource allocation and error handling.
  • This helps to facilitate smooth and efficient continuous integration and deployment processes.

What element of a CI/CD pipeline builds, tests, and packages code?

Flag: build agents

  • Build agents play a crucial role in a CI/CD pipeline by managing tasks such as building, testing, and packaging code. They are important because they carry out the actual work of compiling source code, executing automated tests, and producing deployable artifacts.
  • These tasks are essential for maintaining code quality and getting software ready for deployment.

What fundamental of CI/CD promotes developers in having access to the latest builds and code in order to understand and see the changes that have been made?

Flag: maximum visibility

  • Full visibility in CI/CD fosters openness by providing developers with the most recent builds and code modifications.
  • This is important because it allows team members to remain updated on project advancements, promptly detect and resolve issues, and work together more efficiently. This ultimately results in quicker development cycles and better software quality.

Creating your own Pipeline

What is the name of the build agent that can be used with Gitlab?

Flag: Gitlab Runner

  • GitLab Runner is a specialized build agent tailored for seamless integration with GitLab’s CI/CD system.
  • It is notable for enabling GitLab users to run their CI/CD jobs across different platforms and environments, offering versatility and expandability for integrating continuous integration and deployment processes within the GitLab environment.

What is the value of the flag you receive once authenticated to Timekeep?

Flag: THM{Welcome.to.CICD.Pipelines}

Securing the Build Source

Which file specifies which directories and files should be excluded for version control?

Flag: .gitignore

  • The .gitignore file indicates the directories and files that should not be included in version control in Git. It keeps repositories tidy by avoiding the tracking of unnecessary or sensitive files, such as build artifacts, temporary files, or configuration files containing confidential information.
  • This practice enhances performance and upholds security.

What can be used to ensure that remote access to the build server can be performed securely?

Flag: branches

  • You can maintain secure remote access to build servers by using branches and implementing branch protection rules, environment-specific branches, and branch-based permissions.
  • These approaches provide precise access control, restricting the ability to initiate builds or deployments on particular branches, thereby enhancing the security of build server access.

What issue does lack of access control and unauthorised code changes lead to?

Flag: unauthorised tampering

  • It’s essential to remember that a lack of access control and unauthorized code changes can result in unauthorized alterations to the codebase or pipeline.
  • This is significant because it risks the integrity and security of the software development process, potentially introducing weaknesses, errors, or harmful code that could jeopardize the final product or the organization’s systems.

What is the API key stored within the Mobile application that can be accessed by any Gitlab user?

Flag: THM{You.Found.The.API.Key}

Securing the Build Process

Where should you store artefacts to prevent tampering?

Flag: secure registry

  • It’s important to have a reliable registry for storing artifacts in a CI/CD pipeline to prevent any unauthorized modifications.
  • This centralized, access-controlled repository ensures the integrity and authenticity of the built artifacts, providing a secure and trustworthy source for deployments.

What mechanism should you always use to store and inject sensitive data?

Flag: secret management

  • Maintaining the confidentiality of sensitive information in a CI/CD pipeline is essential. This can ensure a secure method for handling private data such as API keys, passwords, and certificates.
  • This can prevent the accidental exposure of this information in code repositories or logs and guarantees that only authorized procedures can retrieve these confidential details during the build and deployment process.

What attack can malicious actors perform to inject malicious code in the build process?

Flag: dependency confusion

  • Dependency confusion refers to an exploit in which bad actors take advantage of package managers by releasing harmful packages with names that resemble those of genuine internal dependencies.
  • This is significant because it enables attackers to insert malicious code into the development process of companies that utilize both public and private package repositories, potentially jeopardizing the entire software distribution system.

Authenticate to Mother and follow the process to claim Flag 1. What is Flag 1?

Flag: THM{7753f7e9–6543–4914–90ad-7153609831c3}

Securing the Build Server

What can be used to ensure that remote access to the build server can be performed securely?

Flag: VPN

  • Using a Virtual Private Network, VPN enables secure remote access to the build server.
  • This is important because it establishes an encrypted connection between the remote user and the build server, safeguarding sensitive information and access credentials from potential interception or unauthorized access.
  • This is essential for upholding the security and reliability of the CI/CD pipeline.

What can be used to add an additional layer of authentication security for build agents?

Flag: Token-Based Authentication

  • Token-based authentication adds an additional level of security for build agents by demanding a distinct, temporary token for every authentication effort.
  • This is significant as it bolsters security in CI/CD pipelines, diminishing the chances of unauthorized entry to crucial build environments and defending against possible security violations that could imperil the integrity of the software development process.

Authenticate to Mother and follow the process to claim Flag 2. What is Flag 2?

Flag: THM{1769f776-e03c-40b6-b2eb-b298297c15cc}

Securing the Build Pipeline

What can we add so that merges are raised for review instead of pushing the changes to code directly?

Flag: merge requests

  • Merge requests, also known as pull requests in certain systems, allow developers to suggest modifications to the codebase for review before merging.
  • This is important as it facilitates code review, teamwork, and quality assurance, allowing teams to identify issues early and uphold code standards before implementing changes in the primary branch.

What should we do so that only trusted runners execute CI/CD jobs?

Flag: Limit Runner Access

  • Restricting runner access is essential to guaranteeing that only reliable runners can execute CI/CD jobs.
  • This precaution is vital as it improves security by stopping unauthorized entry to confidential code and resources, thus minimizing the likelihood of malicious activities or data breaches in your CI/CD pipeline.

Authenticate to Mother and follow the process to claim Flag 3. What is Flag 3?

Flag: THM{2411b26f-b213–462e-b94c-39d974e503e6}

Securing the Build Environment

What should you do so that a compromised environment doesn’t affect other environments?

Flag: isolate environments

  • Isolating environments is essential to preventing the impact of a compromised environment on other parts of a CI/CD pipeline.
  • This is important for improving security by containing potential breaches, reducing the risk of contamination across environments, and ensuring that problems in one environment do not affect others, thus preserving the integrity of the entire system.

Authenticate to Mother and follow the process to claim Flag 4 from the DEV environment. What is Flag 4?

Flag: THM{28f36e4a-7c35–4e4d-bede-be698ddf0883}

Authenticate to Mother and follow the process to claim Flag 5 from the PROD environment. What is Flag 5?

Flag: THM{e9f99dbe-6bae-4849-adf7–18a449c93fe6}

Securing the Build Secrets

Is using environment variables enough to protect the build secrets? (yay or nay)

Flag: Nay

  • Storing build secrets solely through environment variables doesn’t provide adequate protection.
  • Implementing stronger security measures, such as encryption at rest and in transit, access controls, and secure key management systems, is crucial for safeguarding build secrets in the CI/CD pipeline.

What is the value of the PROD API_KEY?

Flag: THM{Secrets.are.meant.to.be.kept.Secret}

Takeaways

The CI/CD and Build Security room taught me the significance of integrating security into the CI/CD pipeline to ensure data integrity and code security. When managing access control, it’s important to only provide users with the permissions they need, not extras. Implementing runner security, authentication, masking security variables, and continuous monitoring will significantly enhance an organization’s security.

Having different environments to reduce the risk of compromised data is also crucial. Lastly, cybersecurity awareness training is essential for all teams in an organization. Have you recently started the DevSecOps learning path? Comment below! This concludes the walkthrough. See you in the next post!

Reference

TryHackMe | Cyber Security Training
TryHackMe is a free online platform for learning cyber security, using hands-on exercises and labs, all through your…

Read More Tech Content Here ⬇️

All Tech Things
Edit description

Enjoying this content? Please support me on Buy Me a Coffee ☕️

Angie is Creating videos and blogs
Hello, awesome and amazing people! My name is Angie, and I’m a Digital Creator, a lifelong learner, and the founder of…

Thanks for reading!

One moment. You should get my articles in your inbox. Subscribe here.

👩‍💻 Follow me on GitHub | Substack for lifestyle & cyber education 👩‍💻

I hope that you have a wonderful day. ✨

Follow for more: