Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/CycodeLabs/raven
CI/CD Security Analyzer
https://github.com/CycodeLabs/raven
cicd cycode security security-automation security-tools
Last synced: about 1 month ago
JSON representation
CI/CD Security Analyzer
- Host: GitHub
- URL: https://github.com/CycodeLabs/raven
- Owner: CycodeLabs
- License: apache-2.0
- Created: 2023-09-12T11:07:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-29T09:37:58.000Z (4 months ago)
- Last Synced: 2024-10-13T15:57:03.831Z (about 2 months ago)
- Topics: cicd, cycode, security, security-automation, security-tools
- Language: Python
- Homepage:
- Size: 510 KB
- Stars: 612
- Watchers: 10
- Forks: 33
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-github-repos - CycodeLabs/raven - CI/CD Security Analyzer (Python)
- awesome-cicd-security - Raven - A powerful security tool designed to perform massive scans for GitHub Actions CI workflows and digest the discovered data into a Neo4j database (Tools / ArgoCD)
README
[![License](https://img.shields.io/badge/license-Apache%202.0-orange.svg)](https://opensource.org/licenses/MIT)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/CycodeLabs/raven?color=red)
[](https://cimon.build/)
![Black Hat Arsenal 2023](https://img.shields.io/badge/Black_Hat_Arsenal-EU_2023-blue?style=square)# Raven - CI/CD Security Analyzer
**RAVEN (Risk Analysis and Vulnerability Enumeration for CI/CD)** is a powerful security tool designed to perform massive scans for GitHub Actions CI workflows and digest the discovered data into a Neo4j database. Developed and maintained by the [Cycode](https://cycode.com/?utm_source=github_website&utm_medium=referral&utm_campaign=raven_page) research team.
With Raven, we were able to identify and report security vulnerabilities in some of the most popular repositories hosted on GitHub, including:
- [FreeCodeCamp](https://github.com/freeCodeCamp/freeCodeCamp) (the most popular project on GitHub)
- [Storybook](https://github.com/storybookjs/storybook) (One of the most popular frontend frameworks)
- [Fluent UI](https://github.com/microsoft/fluentui) by Microsoft
- and much moreWe listed all vulnerabilities discovered using Raven in the tool [Hall of Fame](#hall-of-fame---vulnerabilities-found-and-disclosed-using-raven).
## What is Raven
The tool provides the following capabilities to scan and analyze potential CI/CD vulnerabilities:
- ⏬ **Downloader:** You can download workflows and actions necessary for analysis. Workflows can be downloaded either for multiple accounts (user/organization) simultaneously or for public GitHub repositories, sorted by star count. Performing this step is a prerequisite for analyzing the workflows.
- 📊 **Indexer:** Digesting the downloaded data into a graph-based Neo4j database. This process involves establishing relationships between workflows, actions, jobs, steps, etc.
- 📚 **Query Library:** We created a library of pre-defined queries based on research conducted by the community.
- ❗ **Reporter:** Raven has a simple way of reporting suspicious findings. As an example, it can be incorporated into the CI process for pull requests and run there.Possible usages for Raven:
- Scanner for your own organization's security
- Scanning specified organizations for bug bounty purposes
- Scan everything and report issues found to save the internet
- Research and learning purposesThis tool provides a reliable and scalable solution for CI/CD security analysis, enabling users to query bad configurations and gain valuable insights into their codebase's security posture.
## Why Raven
In the past year, Cycode Labs conducted extensive research on fundamental security issues of CI/CD systems. We examined the depths of many systems, thousands of projects, and several configurations. The conclusion is clear – the model in which security is delegated to developers has failed. This has been proven several times in our previous content:
- A simple injection scenario exposed dozens of public repositories, including popular open-source projects.
- We found that one of the most popular frontend frameworks was vulnerable to the innovative method of branch injection attack.
- We detailed a completely different attack vector, 3rd party integration risks, the most popular project on GitHub, and thousands more.
- Finally, the Microsoft 365 UI framework, with more than 300 million users, is vulnerable to an additional new threat – an artifact poisoning attack.
- Additionally, we found, reported, and disclosed hundreds of other vulnerabilities privately.Each of the vulnerabilities above has unique characteristics, making it nearly impossible for developers to stay up to date with the latest security trends. Unfortunately, each vulnerability shares a commonality – each exploitation can impact millions of victims.
It was for these reasons that Raven was created, a framework for CI/CD security analysis workflows (and GitHub Actions as the first use case). In our focus, we examined complex scenarios where each issue isn't a threat on its own, but when combined, they pose a severe threat.
## Setup && Run
To get started with Raven, follow these installation instructions:
**Step 1**: Install the Raven package
```bash
pip3 install raven-cycode
```**Step 2**: Setup a local Redis server and Neo4j database
```bash
docker run -d --name raven-neo4j -p7474:7474 -p7687:7687 --env NEO4J_AUTH=neo4j/123456789 --volume raven-neo4j:/data neo4j:5.12
docker run -d --name raven-redis -p6379:6379 --volume raven-redis:/data redis:7.2.1
```Another way to setup the environment is by running our provided docker compose file:
```bash
git clone https://github.com/CycodeLabs/raven.git
cd raven
make setup
```**Step 3**: Run Raven Downloader
Account mode:
```bash
raven download account --token $GITHUB_TOKEN --account-name RavenDemo
```Crawl mode:
```bash
raven download crawl --token $GITHUB_TOKEN --min-stars 1000
```**Step 4**: Run Raven Indexer
```bash
raven index
```**Step 5**: Inspect the results through the reporter
```bash
raven report --format raw
```At this point, it is possible to inspect the data in the Neo4j database, by connecting http://localhost:7474/browser/.
### Prerequisites
- Python 3.9+
- Docker Compose v2.1.0+
- Docker Engine v1.13.0+## Infrastructure
Raven is using two primary docker containers: Redis and Neo4j.
`make setup` will run a `docker compose` command to prepare that environment.![Infrastructure](https://raw.githubusercontent.com/CycodeLabs/raven/main/assets/images/infrastructure.png)
## Usage
The tool contains three main functionalities, `download` and `index` and `report`.
### Download
#### Download Account Repositories
```bash
usage: raven download account [-h] --token TOKEN [--debug] [--redis-host REDIS_HOST] [--redis-port REDIS_PORT] [--clean-redis] (--account-name ACCOUNT_NAME | --personal)options:
-h, --help show this help message and exit
--token TOKEN GITHUB_TOKEN to download data from Github API (Needed for effective rate-limiting)
--debug Whether to print debug statements, default: False
--redis-host REDIS_HOST
Redis host, default: localhost
--redis-port REDIS_PORT
Redis port, default: 6379
--clean-redis, -cr Whether to clean cache in the redis, default: False
--account-name ACCOUNT_NAME
Account name for downloading the workflows, can be used multiple times
--personal Download repositories owned by the authenticated user
```#### Download Public Repositories
```bash
usage: raven download crawl [-h] --token TOKEN [--debug] [--redis-host REDIS_HOST] [--redis-port REDIS_PORT] [--clean-redis] [--max-stars MAX_STARS] [--min-stars MIN_STARS]options:
-h, --help show this help message and exit
--token TOKEN GITHUB_TOKEN to download data from Github API (Needed for effective rate-limiting)
--debug Whether to print debug statements, default: False
--redis-host REDIS_HOST
Redis host, default: localhost
--redis-port REDIS_PORT
Redis port, default: 6379
--clean-redis, -cr Whether to clean cache in the redis, default: False
--max-stars MAX_STARS
Maximum number of stars for a repository
--min-stars MIN_STARS
Minimum number of stars for a repository, default: 1000
```### Index
```bash
usage: raven index [-h] [--redis-host REDIS_HOST] [--redis-port REDIS_PORT] [--clean-redis] [--neo4j-uri NEO4J_URI] [--neo4j-user NEO4J_USER] [--neo4j-pass NEO4J_PASS]
[--clean-neo4j] [--debug]options:
-h, --help show this help message and exit
--redis-host REDIS_HOST
Redis host, default: localhost
--redis-port REDIS_PORT
Redis port, default: 6379
--clean-redis, -cr Whether to clean cache in the redis, default: False
--neo4j-uri NEO4J_URI
Neo4j URI endpoint, default: neo4j://localhost:7687
--neo4j-user NEO4J_USER
Neo4j username, default: neo4j
--neo4j-pass NEO4J_PASS
Neo4j password, default: 123456789
--clean-neo4j, -cn Whether to clean cache, and index from scratch, default: False
--debug Whether to print debug statements, default: False
```### Report
```bash
usage: raven report [-h] [--redis-host REDIS_HOST] [--redis-port REDIS_PORT] [--clean-redis] [--neo4j-uri NEO4J_URI] [--neo4j-user NEO4J_USER]
[--neo4j-pass NEO4J_PASS] [--clean-neo4j]
[--tag {injection,unauthenticated,fixed,priv-esc,supply-chain,best-practice,endoflife,reconnaissance}]
[--severity {info,low,medium,high,critical}] [--query_ids RQ-1,..,RQ-16] [--queries-path QUERIES_PATH] [--format {raw,json}]
{slack} ...positional arguments:
{slack}
slack Send report to slack channeloptions:
-h, --help show this help message and exit
--redis-host REDIS_HOST
Redis host, default: localhost
--redis-port REDIS_PORT
Redis port, default: 6379
--clean-redis, -cr Whether to clean cache in the redis, default: False
--neo4j-uri NEO4J_URI
Neo4j URI endpoint, default: neo4j://localhost:7687
--neo4j-user NEO4J_USER
Neo4j username, default: neo4j
--neo4j-pass NEO4J_PASS
Neo4j password, default: 123456789
--clean-neo4j, -cn Whether to clean cache, and index from scratch, default: False
--tag {injection,unauthenticated,fixed,priv-esc,supply-chain,best-practice,endoflife,reconnaissance}, -t {injection,unauthenticated,fixed,priv-esc,supply-chain,best-practice,endoflife,reconnaissance}
Filter queries with specific tag
--severity {info,low,medium,high,critical}, -s {info,low,medium,high,critical}
Filter queries by severity level (default: info)
--query_ids RQ-1,..,RQ-16, -id RQ-1,..,RQ-16
Filter queries by query ids (example: RQ-2,RQ-8)
--queries-path QUERIES_PATH, -dp QUERIES_PATH
Queries folder (default: library)
--format {raw,json}, -f {raw,json}
Report format (default: raw)
```## Examples
Retrieve all workflows and actions associated with any account (user/organization).
```bash
raven download account --token $GITHUB_TOKEN --account-name microsoft --account-name google --debug
```Scrape all publicly accessible GitHub repositories.
```bash
raven download crawl --token $GITHUB_TOKEN --min-stars 100 --max-stars 1000 --debug
```After finishing the download process or if interrupted using Ctrl+C, proceed to index all workflows and actions into the Neo4j database.
```bash
raven index --debug
```Now, we can generate a report using our query library.
```bash
raven report --severity high --tag injection --tag unauthenticated
```## Rate Limiting
For effective rate limiting, you should supply a Github token.
For authenticated users, the next rate limiting applies:- Code search - 30 queries per minute
- Any other API - 5000 per hour## Research Knowledge Base
- [Issue Injections](https://github.com/CycodeLabs/raven/blob/main/docs/Issue%20Injections/README.md)
- [Pull Request Injections](https://github.com/CycodeLabs/raven/blob/main/docs/Pull%20Request%20Injections/README.md)
- [Workflow Run Injections](https://github.com/CycodeLabs/raven/blob/main/docs/Multi%20Prerequisite%20Exploits/README.md)
- [CodeSee Injections](https://github.com/CycodeLabs/raven/blob/main/docs/Codesee%20Injections/README.md)## Current Limitations
- It is possible to run external action by referencing a folder with a `Dockerfile` (without `action.yml`). Currently, this behavior isn't supported.
- It is possible to run external action by referencing a docker container through the `docker://...` URL. Currently, this behavior isn't supported.
- It is possible to run an action by referencing it locally. This creates complex behavior, as it may come from a different repository that was checked out previously. The current behavior is trying to find it in the existing repository.
- We aren't modeling the entire workflow structure. If additional fields are needed, please submit a pull request according to the [contribution](https://github.com/CycodeLabs/raven/blob/main/CONTRIBUTING.md) guidelines.## Future Research Work
- Implementation of taint analysis. Example use case - a user can pass a pull request title (which is controllable parameter) to an action parameter that is named `data`. That action parameter may be used in a run command: `- run: echo ${{ inputs.data }}`, which creates a path for a code execution.
- Expand the research for findings of harmful misuse of `GITHUB_ENV`. This may utilize the previous taint analysis as well.
- Research whether `actions/github-script` has an interesting threat landscape. If it is, it can be modeled in the graph.## License
[Apache License 2.0](https://github.com/CycodeLabs/raven/blob/main/LICENSE.md)
## Hall of Fame - Vulnerabilities Found and Disclosed Using Raven
| Name | Stars | Fix | Additional Sources |
| ------ | -------- | ---- | -------------------- |
| [freeCodeCamp/freeCodeCamp](https://github.com/freeCodeCamp/freeCodeCamp) | ![](https://img.shields.io/github/stars/freeCodeCamp/freeCodeCamp) | CodeSee package update, [0871341](https://github.com/freeCodeCamp/freeCodeCamp/commit/0871341c9cbf96ab455bc3e0bce636e2ef2a2be2) | [Blog](https://cycode.com/blog/cycode-secures-thousands-of-open-source-projects/) |
| [Significant-Gravitas/AutoGPT](https://github.com/Significant-Gravitas/AutoGPT) | ![](https://img.shields.io/github/stars/Significant-Gravitas/AutoGPT) | [cdae7f8](https://github.com/Significant-Gravitas/AutoGPT/pull/6313/commits/cdae7f84ce0b2879fdcc1fa04956cdaa42a07bfb) | | [storybookjs/storybook](https://github.com/storybookjs/storybook) | ![](https://img.shields.io/github/stars/storybookjs/storybook) | [ffb8558](https://github.com/storybookjs/storybook/commit/ffb8558b7e5df4644299e5ec7009ade6ca1a721c) | [Blog](https://cycode.com/ci-story-how-we-found-critical-vulnerabilities-in-storybook-project/) |
| [tiangolo/fastapi](https://github.com/tiangolo/fastapi) | ![](https://img.shields.io/github/stars/tiangolo/fastapi) | [9efab1b](https://github.com/tiangolo/fastapi/commit/9efab1bd96ef061edf1753626573a0a2be1eef09) | [LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:7011753940283203584/) |
| [withastro/astro](https://github.com/withastro/astro) | ![](https://img.shields.io/github/stars/withastro/astro) | [650fb1a](https://github.com/withastro/astro/commit/650fb1aa51a1c843c10bc89a11732b45a6345b00) | [Blog](https://cycode.com/github-actions-vulnerabilities/) |
| [statelyai/xstate](https://github.com/statelyai/xstate) | ![](https://img.shields.io/github/stars/statelyai/xstate) | CodeSee package update | [Blog](https://cycode.com/blog/cycode-secures-thousands-of-open-source-projects/) |
| [bazelbuild/bazel](https://github.com/bazelbuild/bazel) | ![](https://img.shields.io/github/stars/bazelbuild/bazel) | [3561f07](https://github.com/bazelbuild/continuous-integration/commit/3561f079e0414d31ebba923815695e1e714937cb) | [Blog](https://cycode.com/blog/cycode-discovers-a-supply-chain-vulnerability-in-bazel/) |
| [docker-slim/docker-slim](https://github.com/docker-slim/docker-slim) | ![](https://img.shields.io/github/stars/docker-slim/docker-slim) | CodeSee package update | [Blog](https://cycode.com/blog/cycode-secures-thousands-of-open-source-projects/) |
| [microsoft/fluentui](https://github.com/microsoft/fluentui) | ![](https://img.shields.io/github/stars/microsoft/fluentui) | [2ea6195](https://github.com/microsoft/fluentui/commit/2ea6195152131766641311ee5604e746b578d8e7) | [Blog](https://cycode.com/blog/analyzing-the-vulnerability-that-could-have-compromised-microsoft-365-users/) |
| [tiangolo/sqlmodel](https://github.com/tiangolo/sqlmodel) | ![](https://img.shields.io/github/stars/tiangolo/sqlmodel) | [cf36b2d](https://github.com/tiangolo/sqlmodel/commit/cf36b2d9baccf527bc61071850f102e2cd8bf6bf) | [LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:7011753940283203584/) |
| [tiangolo/typer](https://github.com/tiangolo/typer) | ![](https://img.shields.io/github/stars/tiangolo/typer) | [0c106a1](https://github.com/tiangolo/typer/commit/0c106a169e5e3c7df6f98e32a6d8405c985b695a) | [LinkedIn](https://www.linkedin.com/feed/update/urn:li:activity:7011753940283203584/) |
| [juspay/hyperswitch](https://github.com/juspay/hyperswitch) | ![](https://img.shields.io/github/stars/juspay/hyperswitch) | [a052f9a](https://github.com/juspay/hyperswitch/pull/2797/commits/a052f9a9c921ec0ff8c526097841be5777faf835) | |
| [autogluon/autogluon](https://github.com/autogluon/autogluon) | ![](https://img.shields.io/github/stars/autogluon/autogluon) | [ca18fa9](https://github.com/autogluon/autogluon/commit/ca18fa9fa2071f670125fd19700cf3570a6b5119) | |
| [apache/camel](https://github.com/apache/camel) | ![](https://img.shields.io/github/stars/apache/camel) | [02e512a](https://github.com/apache/camel/pull/11879/commits/02e512ae1ab0a471e80d86096ea79b45789aa105) | | [liquibase/liquibase](https://github.com/liquibase/liquibase) | ![](https://img.shields.io/github/stars/liquibase/liquibase) | [3278525](https://github.com/liquibase/liquibase/commit/3278525eaf974daea20808926f9a6816aecd01a7) | [Blog](https://cycode.com/github-actions-vulnerabilities/) |
| [ossf/scorecard](https://github.com/ossf/scorecard) | ![](https://img.shields.io/github/stars/ossf/scorecard) | [c9f582b](https://github.com/ossf/scorecard/commit/c9f582b620a57a1a476f4e3add505ff50c51a774) | |
| [Ombi-app/Ombi](https://github.com/Ombi-app/Ombi) | ![](https://img.shields.io/github/stars/Ombi-app/Ombi) | [5cc0d77](https://github.com/Ombi-app/Ombi/commit/5cc0d7727d72fe1fee8a3f6c3874d44a5b785de4) | [Blog](https://cycode.com/github-actions-vulnerabilities/) |
| [wireapp/wire-ios](https://github.com/wireapp/wire-ios) | ![](https://img.shields.io/github/stars/wireapp/wire-ios) | [9d39d6c](https://github.com/wireapp/wire-ios/commit/9d39d6c93b5a58a0bc8c1aba10e0d67756359630) | [Blog](https://cycode.com/github-actions-vulnerabilities/) |
| [cloudscape-design/components](https://github.com/cloudscape-design/components) | ![](https://img.shields.io/github/stars/cloudscape-design/components) | [2921d2d](https://github.com/cloudscape-design/.github/commit/2921d2d1420fef5b849d5aecbcfb9138ac6b9dcc) | |
| [DynamoDS/Dynamo](https://github.com/DynamoDS/Dynamo) | ![](https://img.shields.io/github/stars/DynamoDS/Dynamo) | Disabled workflow | [Blog](https://cycode.com/github-actions-vulnerabilities/) |
| [fauna/faunadb-js](https://github.com/fauna/faunadb-js) | ![](https://img.shields.io/github/stars/fauna/faunadb-js) | [ee6f53f](https://github.com/fauna/faunadb-js/commit/ee6f53f9c985bde41976743530e3846dee058587) | [Blog](https://cycode.com/github-actions-vulnerabilities/) |
| [apache/incubator-kie-kogito-runtimes](https://github.com/apache/incubator-kie-kogito-runtimes) | ![](https://img.shields.io/github/stars/apache/incubator-kie-kogito-runtimes) | [53c18e5](https://github.com/apache/incubator-kie-kogito-runtimes/commit/53c18e5372e5306e0aa580f201f820b80359ad11) | [Blog](https://cycode.com/github-actions-vulnerabilities/) |## Want more of CI/CD Security, AppSec, and ASPM? Check out Cycode
If you liked Raven, you would probably love our [Cycode](https://cycode.com/?utm_source=github_website&utm_medium=referral&utm_campaign=raven_page) platform that offers even more enhanced capabilities for visibility, prioritization, and remediation of vulnerabilities across the software delivery.
If you are interested in a robust, research-driven Pipeline Security, Application Security, or ASPM solution, don't hesitate to get in touch with us or request a demo using the form [https://cycode.com/book-a-demo/](https://cycode.com/book-a-demo/?utm_source=github_website&utm_medium=referral&utm_campaign=raven_page).