11#! /bin/bash
22# Quick SSRF Protection Test (works without auth since we check rejection)
33
4- set -e
5-
64API_URL=" http://localhost:3333"
75GREEN=' \033[0;32m'
86RED=' \033[0;31m'
@@ -25,8 +23,8 @@ test_result() {
2523 fi
2624}
2725
28- # Note: Image proxy now requires authentication
29- # So all these should return 401 Unauthorized (which is good - not vulnerable to SSRF from unauthenticated users)
26+ # Note: Image proxy intentionally skips JWT auth (browsers can't send Authorization on <img> src).
27+ # Security is enforced via domain allowlist + HTTPS-only + private IP/scheme blocking.
3028
3129echo " [1/9] Testing localhost access (should be blocked)..."
3230RESULT=$( curl -s -w " \n%{http_code}" " $API_URL /api/v1/images/proxy?url=http://localhost:6379" )
@@ -108,14 +106,14 @@ else
108106 test_result " FAIL" " Should block HTTP (got HTTP $HTTP_CODE )"
109107fi
110108
111- echo " [9/9] Authentication required check ..."
112- RESULT=$( curl -s -w " \n%{http_code}" " $API_URL /api/v1/images/proxy?url=https ://upload.wikimedia.org/test.png " )
109+ echo " [9/9] Testing file:// scheme (local file read) ..."
110+ RESULT=$( curl -s -w " \n%{http_code}" " $API_URL /api/v1/images/proxy?url=file :///etc/passwd " )
113111HTTP_CODE=$( echo " $RESULT " | tail -n1)
114112
115- if [ " $HTTP_CODE " = " 401 " ]; then
116- test_result " PASS" " Endpoint requires authentication (HTTP 401 )"
113+ if [ " $HTTP_CODE " = " 400 " ] || [ " $HTTP_CODE " = " 403 " ]; then
114+ test_result " PASS" " Blocks file:// scheme (HTTP $HTTP_CODE )"
117115else
118- test_result " FAIL" " Endpoint should require authentication (got HTTP $HTTP_CODE )"
116+ test_result " FAIL" " Should block file:// scheme (got HTTP $HTTP_CODE )"
119117fi
120118
121119echo " "
@@ -127,7 +125,7 @@ echo -e "${GREEN}Passed: $PASSED${NC}"
127125echo -e " ${RED} Failed: $FAILED ${NC} "
128126echo " "
129127
130- if [ $PASSED -ge 8 ]; then
128+ if [ $FAILED -eq 0 ]; then
131129 echo -e " ${GREEN} ✓ SSRF protection is SECURE${NC} "
132130 echo " "
133131 echo " Notes:"
@@ -136,6 +134,6 @@ if [ $PASSED -ge 8 ]; then
136134 echo " - Private IPs, localhost, and metadata endpoints protected"
137135 exit 0
138136else
139- echo -e " ${RED} ✗ SSRF vulnerabilities detected!${NC} "
137+ echo -e " ${RED} ✗ SSRF vulnerabilities detected ( $FAILED failure(s)) !${NC} "
140138 exit 1
141139fi
0 commit comments