一个已损坏的应用程序 - 非常易受攻击!
Broken Crystals is a benchmark application that uses modern technologies and implements a set of common security vulnerabilities.
The application contains:
Note The GraphQL API does not yet support all the endpoints the REST API does.
Build and start local development environment with Postgres DB, MailCatcher and the app:
docker compose --file=compose.local.yml up -dTo rebuild the app and restart the containers:
docker compose --file=compose.local.yml up -d --build --force-recreateIn 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:3000Finally, you can start tests with SecTester against these endpoints as follows:
npm run test:e2eFull configuration & usage examples can be found in our demo project;
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.
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:
$ 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:
curl https://brokencrystals.com/.htaccessResponse:
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 200Cookie 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:
Landing Page Dummy Query Parameter:
- 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:
Submit the following curl request to store the XSS payload:
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":"
"}'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:
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:
curl https://brokencrystals.com/vendor/Example Response:
Index of /vendor/Index of /vendor/
../
bootstrap-4.1
4/7/2025, 8:33:43 AM
...
- **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 200Successfully fetching the file shows that the server stored the file:
…暂无开放 Issues,或尚未同步最近议题。