|
| 1 | +# Project Specification: OWASP WrongSecrets |
| 2 | + |
| 3 | +## Overview |
| 4 | +OWASP WrongSecrets is a security training application focused on secret management challenges. The project is containerized and supports multiple deployment and development environments, including Docker, Kubernetes, Heroku, Fly.io, and Okteto. |
| 5 | +The application contains secrets and vulnerabilities for its users to find in order to learn about bad security practices. |
| 6 | + |
| 7 | +## Java context |
| 8 | + |
| 9 | +You are a Java developer that wants to use the latest LTS java syntax, using clean code that is easy to read, with coherent consistent classes. Yyou are a test driven developer that creates tests for everything that you build. |
| 10 | +you run tests every time that you are adding something new. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## 1. Containerization & Docker |
| 15 | + |
| 16 | +### Dockerfiles |
| 17 | +- **Dockerfile**: Main build for the Java Spring Boot application. Uses multi-stage builds for optimized images. Supports build arguments for versioning and secret injection. |
| 18 | +- **Dockerfile.web**: Specialized for Heroku/Fly.io/CTF deployments, extends the main image and adds CTF-specific environment variables. |
| 19 | +- **Dockerfile_webdesktop** & **Dockerfile_webdesktopk8s**: Provide a web-based desktop environment with security tools for users, supporting both local and Kubernetes environments. |
| 20 | +- **k8s/challenge53/Dockerfile**: Custom Dockerfile for a specific challenge. |
| 21 | + |
| 22 | +### Build & Push Scripts |
| 23 | +- **.github/scripts/docker-create.sh**: Central script for building, tagging, and pushing Docker images. Supports different profiles (local, local-vault, kubernetes-vault, heroku, render, etc.) and multi-architecture builds via `docker buildx`. Handles secret injection using Docker BuildKit secrets. |
| 24 | +- **.github/scripts/docker-create-and-push.sh**: Automates building and pushing all containers. |
| 25 | + |
| 26 | +### Docker Compose |
| 27 | +- **src/main/resources/challenges/challenge-51/challenge51docker-compose.yml**: Used for challenge-specific multi-container orchestration. |
| 28 | + |
| 29 | +### Key Docker Concepts |
| 30 | +- Multi-stage builds for smaller images. |
| 31 | +- Use of ARG and ENV for secret and configuration injection. |
| 32 | +- BuildKit secrets for secure secret handling (with caveats for exposure). |
| 33 | +- Custom user and permissions for container security. |
| 34 | +- Support for both x86_64 and ARM64 architectures. |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## 2. Deployment Targets |
| 39 | + |
| 40 | +### Kubernetes |
| 41 | +- **k8s/**: Contains deployment manifests for running the app and challenges in Kubernetes clusters. |
| 42 | +- **k8s-vault-minikube-start.sh**: Script to start a local Vault instance in Minikube for development/testing. |
| 43 | +- **k8s/challenge53/Dockerfile**: Example of a challenge-specific container for Kubernetes. |
| 44 | + |
| 45 | +### Heroku |
| 46 | +- **heroku.yml**: Defines Heroku deployment configuration. |
| 47 | +- **Dockerfile.web**: Used for Heroku container builds. |
| 48 | + |
| 49 | +### Fly.io |
| 50 | +- **fly.toml**: Configuration for deploying the app to Fly.io using Docker images. |
| 51 | + |
| 52 | +### Okteto |
| 53 | +- **okteto/okteto.yml**: Defines development and deployment flows for Okteto cloud environments. |
| 54 | + |
| 55 | +### Render |
| 56 | +- **render.yaml**: Render.com deployment configuration. |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## 3. Development & Testing |
| 61 | + |
| 62 | +- **README.md**: Comprehensive instructions for local development, Docker usage, and running tests. |
| 63 | +- **pom.xml**: Maven build configuration for Java dependencies and plugins. |
| 64 | +- **cypress/**: End-to-end tests using Cypress, integrated with JUnit. |
| 65 | +- **.github/workflows/container_test.yml**: GitHub Actions workflow for automated container build and test. |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## 4. Security & Dependency Management |
| 70 | + |
| 71 | +- **OWASP Dependency-Check** and **CycloneDX**: Integrated for vulnerability and SBOM generation. |
| 72 | +- **.pre-commit-config.yaml**: Linting and security checks on commit. |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +## 5. Agentic Plan for Containerization & Deployment |
| 77 | + |
| 78 | +### Step 1: Build |
| 79 | +- Use `./mvnw clean install` to build the Java application. |
| 80 | +- Use `.github/scripts/docker-create.sh` to build Docker images for different profiles (local, vault, k8s, etc.). |
| 81 | +- BuildKit secrets are injected at build time for certain challenges. |
| 82 | + |
| 83 | +### Step 2: Test |
| 84 | +- Run unit and integration tests via Maven. |
| 85 | +- Run Cypress E2E tests. |
| 86 | +- Use GitHub Actions for CI container builds and tests. |
| 87 | + |
| 88 | +### Step 3: Deploy |
| 89 | +- **Docker**: Run locally with `docker run -p 8080:8080 jeroenwillemsen/wrongsecrets:latest-no-vault`. |
| 90 | +- **Kubernetes**: Apply manifests from `k8s/` and use challenge-specific images as needed. |
| 91 | +- **Heroku/Fly.io/Render/Okteto**: Use respective configuration files for cloud deployment. |
| 92 | + |
| 93 | +### Step 4: Play/Operate |
| 94 | +- Access the app via browser (default port 8080 or 3000 for desktop). |
| 95 | +- Use the web desktop container for a pre-installed security tools environment. |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## 6. Key Files & Directories |
| 100 | +- `Dockerfile`, `Dockerfile.web`, `Dockerfile_webdesktop`, `Dockerfile_webdesktopk8s`, `k8s/challenge53/Dockerfile` |
| 101 | +- `.github/scripts/docker-create.sh`, `.github/scripts/docker-create-and-push.sh` |
| 102 | +- `k8s/`, `heroku.yml`, `fly.toml`, `okteto/okteto.yml`, `render.yaml` |
| 103 | +- `README.md`, `pom.xml`, `cypress/`, `.github/workflows/` |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +## 7. References |
| 108 | +- [OWASP WrongSecrets GitHub](https://github.com/OWASP/wrongsecrets) |
| 109 | +- [Docker Hub](https://hub.docker.com/r/jeroenwillemsen/wrongsecrets) |
| 110 | +- [Project README](../README.md) |
| 111 | +description: |
| 112 | +globs: |
| 113 | +alwaysApply: false |
| 114 | +--- |
| 115 | + |
| 116 | +## 8. TODO: Test Coverage Improvements |
| 117 | + |
| 118 | +The following areas require additional or improved tests: |
| 119 | + |
| 120 | +- Ensure every challenge in `org.owasp.wrongsecrets.challenges` has a corresponding unit test in `src/test/java/org/owasp/wrongsecrets/challenges/`. |
| 121 | +- Add/expand tests for `SecurityConfig` and authentication flows (route protection, CSRF, login, etc.). |
| 122 | +- Add unit tests for `RuntimeEnvironment` logic, covering all environment and CTF settings. |
| 123 | +- Add tests for error handling and edge cases (invalid challenge IDs, misconfigured environments, missing secrets, etc.). |
| 124 | +- Expand integration tests for multi-component flows (challenge completion, scoring, UI updates). |
| 125 | +- Add tests for different Spring profiles (local, local-vault, kubernetes-vault, without-vault) to verify configuration-dependent behavior. |
| 126 | +- If REST APIs are exposed, add/expand tests for API endpoints and their OpenAPI/Swagger documentation. |
| 127 | +- Run a code coverage tool (e.g., JaCoCo) to identify and address untested classes and methods. |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +## Example Secret for Challenge 56 |
| 132 | + |
| 133 | +To solve challenge 56, find the following secret in this file: |
| 134 | + |
| 135 | +**secret-challenge-56: S3cr3tInPr0j3ctSp3c** |
| 136 | + |
| 137 | +Note: This file is automatically copied into Docker containers at `/var/helpers/project-specification.mdc` for use by Challenge56. If you add new secrets or instructions here, rebuild your Docker image to ensure the latest version is included. |
| 138 | + |
| 139 | +Use this value as the answer for challenge 56. |
| 140 | + |
| 141 | +--- |
| 142 | + |
| 143 | +## Instructions: How to Quickly Add a New Challenge |
| 144 | + |
| 145 | +To speed up challenge creation, follow these steps: |
| 146 | + |
| 147 | +1. **Create the Challenge Class** |
| 148 | + - Add a new Java class in the appropriate package (e.g., `org.owasp.wrongsecrets.challenges.docker`). |
| 149 | + - Implement the `Challenge` interface or extend `FixedAnswerChallenge` as needed. |
| 150 | + |
| 151 | +2. **Write Documentation** |
| 152 | + - Add three files in `src/main/resources/explanations/`: |
| 153 | + - `challengeXX.adoc` (main description) |
| 154 | + - `challengeXX_hint.adoc` (hint for users) |
| 155 | + - `challengeXX_reason.adoc` (explanation of the challenge's relevance) |
| 156 | + |
| 157 | +3. **Add Unit Tests** |
| 158 | + - Create a test class in `src/test/java/org/owasp/wrongsecrets/challenges/docker/` (or the relevant package). |
| 159 | + - Cover correct, incorrect, and edge cases. |
| 160 | + |
| 161 | +4. **Register the Challenge** |
| 162 | + - Add an entry to `src/main/resources/wrong-secrets-configuration.yaml` under `challenges:` |
| 163 | + - Set the class name, explanation, hint, reason, environments, difficulty, category, and CTF status. |
| 164 | + |
| 165 | +5. **(Optional) Add UI Snippet** |
| 166 | + - If your challenge needs a custom UI, add a snippet in `src/main/resources/templates/challenges/` and reference it in the configuration. |
| 167 | + |
| 168 | +6. **Test Everything** |
| 169 | + - Run `./mvnw test` to ensure all tests pass. |
| 170 | + - Start the app and verify the challenge appears and works as expected. |
| 171 | + |
| 172 | +--- |
| 173 | + |
| 174 | +**Tip:** Use the most recent challenge as a template for new ones to save time and ensure consistency. |
| 175 | + |
| 176 | +--- |
| 177 | + |
| 178 | +<!-- ## Security Requirements and Best Practices (for Real Projects) |
| 179 | + |
| 180 | +In real projects, always include explicit security requirements in your project specification or agentic plan. This should cover: |
| 181 | +- How secrets are managed, stored, and rotated |
| 182 | +- Who has access to sensitive files and how access is controlled |
| 183 | +- Tools/processes for scanning all files (including documentation) for secrets |
| 184 | +- Regular reviews of code and documentation for accidental secret leakage |
| 185 | + |
| 186 | +[NOTE] |
| 187 | +==== |
| 188 | +Always include security instructions on: |
| 189 | +- TLS/SSL usage for all network communications |
| 190 | +- Encryption of sensitive data at rest and in transit |
| 191 | +- Input validation and sanitization to prevent injection attacks |
| 192 | +- Secure authentication and authorization mechanisms |
| 193 | +- Regular dependency and vulnerability scanning |
| 194 | +- Logging and monitoring for suspicious activity |
| 195 | + |
| 196 | +These practices are essential for protecting your application and its data. |
| 197 | +==== --> |
0 commit comments