Git Product home page Git Product logo

l1gh7w34ver / cicd-goat_fork_experiment Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cider-security-research/cicd-goat

0.0 0.0 0.0 66.09 MB

A deliberately vulnerable CI/CD environment. Learn CI/CD security through multiple challenges.

License: Apache License 2.0

Shell 3.66% JavaScript 12.85% Python 72.33% Perl 0.87% Groovy 0.21% Go 0.01% TypeScript 0.12% CSS 0.10% TeX 0.02% Makefile 0.31% HTML 6.78% Mako 0.01% Batchfile 0.19% HCL 0.16% Vue 1.63% Dockerfile 0.13% SCSS 0.62% Nunjucks 0.02%

cicd-goat_fork_experiment's Introduction

cicd-goat

Maintained by Cider Security .github/workflows/release.yaml CircleCI Docker pulls Version

Deliberately vulnerable CI/CD environment. Hack CI/CD pipelines, capture the flags. 🚩

Created by Cider Security.

Table of Contents

Description

The CI/CD Goat project allows engineers and security practitioners to learn and practice CI/CD security through a set of 11 challenges, enacted against a real, full blown CI/CD environment. The scenarios are of varying difficulty levels, with each scenario focusing on one primary attack vector.

The challenges cover the Top 10 CI/CD Security Risks, including Insufficient Flow Control Mechanisms, PPE (Poisoned Pipeline Execution), Dependency Chain Abuse, PBAC (Pipeline-Based Access Controls), and more.
The different challenges are inspired by Alice in Wonderland, each one is themed as a different character.

The project’s environment is based on Docker containers and can be run locally. These containers are:

  1. Gitea (minimal git server)
  2. Jenkins
  3. Jenkins agent
  4. LocalStack (cloud service emulator that runs in a single container)
  5. Prod - contains Docker in Docker and Lighttpd service
  6. CTFd (Capture The Flag framework)
  7. GitLab
  8. GitLab runner
  9. Docker in Docker

The images are configured to interconnect in a way that creates fully functional pipelines.

cicd-goat

Download & Run

There's no need to clone the repository.

Linux & Mac

curl -o cicd-goat/docker-compose.yaml --create-dirs https://raw.githubusercontent.com/cider-security-research/cicd-goat/main/docker-compose.yaml
cd cicd-goat && docker-compose up -d

Windows (Powershell)

mkdir cicd-goat; cd cicd-goat
curl -o docker-compose.yaml https://raw.githubusercontent.com/cider-security-research/cicd-goat/main/docker-compose.yaml
get-content docker-compose.yaml | %{$_ -replace "bridge","nat"}
docker-compose up -d

Usage

Instructions

  • Spoiler alert! Avoid browsing the repository files as they contain spoilers.
  • To configure your git client for accessing private repositories we suggest cloning using the http url.
  • In each challenge, find the flag - in the format of flag# (e.g flag2), or another format if mentioned specifically.
  • Each challenge stands on its own. Do not use access gained in one challenge to solve another challenge.
  • If needed, use the hints on CTFd.
  • There is no need to exploit CVEs.
  • No need to hijack admin accounts of Gitea or Jenkins (named "admin" or "red-queen").

Take the challenge

  1. After starting the containers, it might take up to 5 minutes until the containers configuration process is complete.

  2. Login to CTFd at http://localhost:8000 to view the challenges:

    • Username: alice
    • Password: alice
  3. Hack:

  4. Insert the flags on CTFd and find out if you got it right.

Troubleshooting

  • If Gitea shows a blank page, refresh the page.
  • When forking a repository, don't change the name of the forked repository.
  • If any of the services doesn't start or is not configured correctly try adding more cpu and memory to the docker engine and update it to the lateset version.

Solutions

Warning: Spoilers! 🙈

See Solutions.

Contributing

Development

  1. Clone the repository.

  2. Rename .git folders to make them usable:

    ./rename.py git
  3. Install testing dependencies:

    pip3 install pipenv==2022.8.30
    pipenv install --deploy
  4. Run the development environment to experiment with new changes:

    rm -rf tmp tmp-ctfd/
    cp -R ctfd/data/ tmp-ctfd/
    docker-compose -f docker-compose-dev.yaml up -d
  5. Make the desired changes:

    • All services except CTFd are completely configured as code so desired changes should be made to the files in the appropriate folders.
    • To make changes in CTFd, use the admin credentials.
  6. Shutdown the environment, move changes made in CTFd and rebuild it:

    docker-compose -f docker-compose-dev.yaml down
    ./apply.sh # save CTFd changes
    docker-compose -f docker-compose-dev.yaml up -d --build
  7. Run tests:

    pytest tests/
  8. Rename .git folders to allow push:

    ./rename.py notgit
  9. Commit and push!

Checklist

Follow the checklist below to add a challenge:

  1. CTFd:
    1. Write challenge description.
    2. Choose category according to difficulty level.
    3. Make sure the challenge is visible and has value according to difficulty.
    4. Write hints in order of usage.
    5. Add a flag. Make sure to select if it's case-insensitive.
  2. Gitea:
    1. Configure a new repository in gitea.yaml.
    2. Create the repository under gitea/repositories. Use an open-source repository that use the MIT license as a template for the challenge repository.
  3. Jenkins:
    1. Configure Jenkins and add new jobdsl files in the casc.yaml file.
    2. Make sure jobs don't run periodically. Jobs should be triggered by events / polling.
    3. Validate that the new challenge doesn't interfere with other challenges.
  4. GitLab:
    1. Configure Gitlab by changing the gitlab.tf file and run terraform init to update lock file.
    2. To upload new repositories add the releqvant line in repositories.sh.
    3. If any additional files are needed place them inside the resources' folder.
  5. Make sure the flag is not accessible when solving other challenges.
  6. Write tests.
  7. Write the solution.
  8. Update README.md if needed.
  9. In order to run the CI, make sure you have a CircleCI account and that you’ve clicked “Set Up Project” on your fork of the project.

cicd-goat_fork_experiment's People

Contributors

asi-cider avatar omer-cider avatar malikashish8 avatar nlahmi avatar dibsy avatar sdussault avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.