百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

brokencrystals

> 前端框架
开源

一个已损坏的应用程序 - 非常易受攻击!

198 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

一个已损坏的应用程序 - 非常易受攻击!

Description

Broken Crystals is a benchmark application that uses modern technologies and implements a set of common security vulnerabilities.

The application contains:

  • React based web client & API: http://localhost:3000
  • Node.js server that serves the React client and provides both OpenAPI and GraphQL endpoints. The full API documentation is available via swagger or GraphQL:
    • Swagger UI - http://localhost:3000/swagger
    • Swagger JSON file - http://localhost:3000/swagger-json
    • GraphiQL UI - http://localhost:3000/graphiql

Note The GraphQL API does not yet support all the endpoints the REST API does.

Building and Running the Application

Build and start local development environment with Postgres DB, MailCatcher and the app:

bash
docker compose --file=compose.local.yml up -d

To rebuild the app and restart the containers:

bash
docker compose --file=compose.local.yml up -d --build --force-recreate

Running tests by SecTester

In the path ./test you can find tests to run with Jest.

First, you have to get a Bright API key, navigate to your .env file, and paste your Bright API key as the value of the BRIGHT_TOKEN variable:

BRIGHT_TOKEN=

Then, you can modify a URL to your instance of the application by setting the SEC_TESTER_TARGET environment variable in your .env file:

SEC_TESTER_TARGET=http://localhost:3000

Finally, you can start tests with SecTester against these endpoints as follows:

bash
npm run test:e2e

Full configuration & usage examples can be found in our demo project;

Vulnerabilities Overview

  • Broken JWT Authentication - The application includes multiple endpoints that generate and validate several types of JWT tokens. The main login API, used by the UI, is utilizing one of the endpoints while others are available via direct call and described in Swagger.

    • No Algorithm bypass - Bypasses the JWT authentication by using the “None” algorithm (implemented in main login and API authorization code).
    • RSA to HMAC - Changes the algorithm to use a “HMAC” variation and signs with the public key of the application to bypass the authentication (implemented in main login and API authorization code).
    • Invalid Signature - Changes the signature of the JWT to something different and bypasses the authentication (implemented in main login and API authorization code).
    • KID Manipulation - Changes the value of the KID field in the Header of JWT to use either: (1) a static file that the application uses or (2) OS Command that echoes the key that will be signed or (3) SQL code that will return a key that will be used to sign the JWT (implemented in designated endpoint as described in Swagger).
    • Brute Forcing Weak Secret Key - Checks if common secret keys are used (implemented in designated endpoint as described in Swagger). The secret token is configurable via .env file and, by default, is 123.
    • X5U Rogue Key - Uses the uploaded certificate to sign the JWT and sets the X5U Header in JWT to point to the uploaded certificate (implemented in designated endpoint as described in Swagger).
    • X5C Rogue Key - The application doesn't properly check which X5C key is used for signing. When we set the X5C headers to our values and sign with our private key, authentication is bypassed (implemented in designated endpoint as described in Swagger).
    • JKU Rogue Key - Uses our publicly available JSON to check if JWT is properly signed after we set the Header in JWT to point to our JSON and sign the JWT with our private key (implemented in designated endpoint as described in Swagger).
    • JWK Rogue Key - We make a new JSON with empty values, hash it, and set it directly in the Header, and we then use our private key to sign the JWT (implemented in designated endpoint as described in Swagger).
  • Brute Force Login - Checks if the application user is using a weak password. The default setup contains user = admin with password = admin

    Example Exploitation

    To demonstrate brute force login, you can use the following curl command:

    bash
    $ curl https://brokencrystals.com/api/auth/login \
    >   -H 'Content-Type: application/json' \
    >   -d '{"user":"admin","password":"admin","op":"basic"}'
    {"email":"admin","ldapProfileLink":"(&(objectClass=person)(objectClass=user)(email=admin))"}
  • Common Files - Tries to find common files that shouldn’t be publicly exposed (such as “phpinfo”, “.htaccess”, “ssh-key.priv”, etc…). The application contains .htaccess and nginx.conf files under the client's root directory and additional files can be added by placing them under the public/public directory and running a build of the client.

    Example Exploitation of Common Files

    To demonstrate accessing a common file, you can use the following curl command:

    bash
    curl https://brokencrystals.com/.htaccess

    Response:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php
    
    ErrorDocument 400 /error_pages/400.php
    ErrorDocument 401 /error_pages/401.php
    ErrorDocument 403 /error_pages/403.php
    ErrorDocument 404 /error_pages/404.php
    ErrorDocument 410 /error_pages/410.php
    ErrorDocument 500 /error_pages/500.php
    
    #Serve .htc files correctly, for IE fixes
    AddType text/x-component .htc
    
    php_value upload_max_filesize 10M
    php_value post_max_size 10M
    php_value max_execution_time 200
    php_value max_input_time 200
  • Cookie Security - Checks if the cookie has the “secure” and HTTP only flags. The application returns two cookies (session and bc-calls-counter cookie), both without secure and HttpOnly flags.

  • Cross-Site Request Forgery (CSRF)

    • Checks if a form holds anti-CSRF tokens, misconfigured “CORS” and misconfigured “Origin” header - the application returns "Access-Control-Allow-Origin: *" header for all requests. The behavior can be configured in the /main.ts file.

    • The same form with both authenticated and unauthenticated user - the Email subscription UI forms can be used for testing this vulnerability.

      Example of Misconfigured CORS

    • Different form for an authenticated and unauthenticated user - the Add testimonial form can be used for testing. The forms are only available to authenticated users.

  • Cross-Site Scripting (XSS) -

    • Reflective XSS There are couple of endpoints that are vulnerable to reflective XSS:

      • Landing page with the dummy query param that contains DOM content (including script), add the provided DOM will be injected into the page and script executed.

      • Landing page maptitle param that contains DOM content (including script), add the provided DOM will be injected into the page and script executed.

      • /api/testimonials/count page count param is vulnerable to reflective XSS.

      • POST to https://brokencrystals.com/api/metadata with body XML body vulnarable for reflective XSS.

      • POST to https://brokencrystals.com/api/metadata with body SVG body vulnarable for reflective XSS.

        Reflective XSS Example Exploitation

      To demonstrate reflective XSS, you can use the following payloads:

      1. Landing Page Dummy Query Parameter:

        • URL: `https://brokencrystals.com/?__dummy=__

- Thedummy` query parameter is directly injected into the DOM without sanitization, causing the script to execute.

2. **Landing Page Map Title Parameter**:

   - URL: `https://brokencrystals.com/?maptitle=

- Themaptitle` parameter is used in the DOM and allows script execution.

3. **Testimonials Page Count Parameter**:
   - URL: `https://brokencrystals.com/api/testimonials/count?query=

- Thequeryparameter is reflected in the response without sanitization, allowing script execution. 4. **POST to /api/metadata with XML Body**: - URL:https://brokencrystals.com/api/metadata` - Body: prompt("bright986352") - The XML body is processed and the script is executed in the response. 5. **POST to /api/metadata with SVG Body**: - URL: https://brokencrystals.com/api/metadata - Body: `prompt("bright443188")

  • Persistent XSS can be demonstrated using add testimonial form on the landing page (for authenticated users only).

    Persistent XSS Example Exploitation

    To demonstrate persistent XSS, you can use the following steps:

    1. Submit the following curl request to store the XSS payload:

      bash
      curl 'https://brokencrystals.com/api/testimonials' -X POST \
      -H 'authorization: AUTH_TOKEN' \
      -H 'Content-Type: application/json' \
      --data-raw '{"name":"Test User","title":"Test Title","message":"
      "}'
    2. Visit the testimonials page at https://brokencrystals.com/marketplace to observe the execution of the XSS payload.

  • DOM Cross-Site Scripting - can be demonstrated by using the mailing list subscription form on the landing page. The form sends a POST request to /api/subscriptions?email=VALUE, and the server's response is embedded into the page without any validation on either the server or client side. This allows an attacker to inject malicious scripts into the page.

    Example Exploitation

    To demonstrate this vulnerability, you can submit the following payload in the email field of the subscription form:

    xml
    
    

    Brobser perform a POST request to /api/subscriptions?email= ' with the payload in the email field. The server's response will include the injected script, which will be embedded into the page and executed by the browser. This can be used to execute arbitrary JavaScript code in the context of the user's session.

    Example:

  • Default Login Location - The login endpoint is available under /api/auth/login.

  • Directory Listing - The Nginx config file under the nginx-conf directory is configured to allow directory listing.

    Example Exploitation of Directory Listing

    To demonstrate directory traversal, you can use the following curl command:

    bash
    curl https://brokencrystals.com/vendor/

    Example Response:

    xml
    
      Index of /vendor/

Index of /vendor/

        ../
      
      
      
    

    

      
        bootstrap-4.1
      
      4/7/2025, 8:33:43 AM
    

    ...
bash

  

- **File Upload** - The application allows uploading an avatar photo of the authenticated user. The server doesn't perform any sort of validation on the uploaded file.

  Example of No Anti-Virus Protection

Uploading an EICAR test file with the file extension changed to "exe":

```bash
curl -i 'https://qa.brokencrystals.com/api/users/one/admin/photo' \
  -X PUT \
  -H 'authorization: AUTH_TOKEN' \
  -H 'Content-Type: multipart/form-data; boundary=--------------------------296987379026085658617195' \
  --data-binary $'----------------------------296987379026085658617195\r\nContent-Disposition: form-data; name="admin"; filename="sample-img2ee0.exe"\r\nContent-Type: image/png\r\n\r\nX5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*\r\n----------------------------296987379026085658617195--\r\n'

The response indicates successful upload:

HTTP/2 200

Successfully fetching the file shows that the server stored the file:

…
  • Full Path Disclosure - An error returned by the server includes the full path of the file where the error has

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptbenchmarkcyber-securitydevopsnestjs

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架