Labs · Cyber Security
Lab: Run OWASP Juice Shop on 127.0.0.1, Review Its Headers, Cookies and Error Pages, and Write a Fix for Each Finding
Course: Cyber Security · Chapter 21: Web Application Testing Tools
Chapter 21 introduces web application testing tools; this lab practises safe, review-style testing on a training app bound to your own laptop.
Chala mitrano! A web security review is mostly careful looking: what headers does the site send, what does it store in cookies, what does it show when something breaks. Today we practise on OWASP Juice Shop, a shop that is insecure on purpose, running only on our own laptop. And for every finding we write the fix. Chala!
चला मित्रांनो! Web security review म्हणजे बहुतेक काळजीपूर्वक बघणं: site कोणते headers पाठवते, cookies मध्ये काय ठेवते, काहीतरी बिघडल्यावर काय दाखवते. आज आपण OWASP Juice Shop वर practice करणार, मुद्दाम insecure बनवलेलं shop, जे फक्त आपल्या laptop वर चालतं. आणि प्रत्येक finding साठी आपण fix लिहिणार. चला!
चलो दोस्तों! Web security review ज़्यादातर ध्यान से देखना है: site कौन से headers भेजती है, cookies में क्या रखती है, कुछ टूटने पर क्या दिखाती है। आज हम OWASP Juice Shop पर practice करेंगे, जानबूझकर insecure बनाई गई shop, जो सिर्फ हमारे laptop पर चलती है। और हर finding के लिए हम fix लिखेंगे। चलो!
Suppose we are…
Suppose we are an application security trainee at Flipkart. Before any new web feature goes live, the AppSec team does a quick review: security headers, cookie flags and error handling. We practise that review on OWASP Juice Shop, a free training web shop made insecure on purpose by the OWASP community, running at http://127.0.0.1:3000 so nobody else can reach it.
Goal of this lab
By the end you will have:
- Juice Shop running on
127.0.0.1only. - Three findings written up: missing headers, a login token cookie readable by JavaScript, and an error page that leaks a stack trace.
- A developer-friendly fix for each finding.
What you need (all free)
- Your own laptop with Docker Desktop (Windows/Mac) or Docker Engine (Linux) installed. 4 GB free RAM.
- A browser (Chrome, Edge or Firefox) and
curl(built into Windows 10+, macOS and Linux; on Windows usecurl.exe). - 40–45 minutes.
Safety and ethics
Review only your own copy of Juice Shop on 127.0.0.1. Never try these checks against a real shop or app without written permission. This lab is about finding and fixing weaknesses, so it uses no attack payloads.
Steps
-
Start Juice Shop, bound to your own laptop only (
127.0.0.1:in front of the port is the important part):docker run --rm -p 127.0.0.1:3000:3000 bkimminich/juice-shopWhat you should see: after a minute, a log line like
info: Server listening on port 3000. -
Open
http://127.0.0.1:3000in your browser. Close the welcome banner and the cookie notice. -
Finding 1, headers. In a second terminal run:
curl -I http://127.0.0.1:3000What you should see: headers such as
X-Content-Type-Options: nosniff,X-Frame-Options: SAMEORIGINandAccess-Control-Allow-Origin: *, but noContent-Security-Policyand noReferrer-Policy. -
Note in your findings sheet: which of the five headers from Lab 8 are present or missing, and why
Access-Control-Allow-Origin: *(any website may read responses) is risky for an app with logins. - Finding 2, cookies. Click Account → Login → Not yet a customer? and register a practice account with a fake email such as
student@juice-sh.opand a practice password. Log in. -
Press F12 → Application tab (Firefox: Storage) → Cookies →
http://127.0.0.1:3000. Click the cookie namedtoken.What you should see: a long value (a JWT login token) with HttpOnly unticked, Secure unticked and SameSite empty.
-
Go to the Console tab and type
document.cookie. The token is printed. This means any injected script could read it. -
Finding 3, error handling. Visit an address that does not exist under the API:
http://127.0.0.1:3000/rest/does-not-existWhat you should see: an error page with
Error: Unexpected path: /rest/does-not-existand a stack trace showing internal file paths. Real users should never see this. -
Open
http://127.0.0.1:3000/#/score-board. Juice Shop tracks training challenges here; you may see challenges such as Error Handling marked as solved by your review. -
Write a fix for each finding in a simple table, Finding → Risk → Fix → How to verify:
- Headers: add
Content-Security-PolicyandReferrer-Policy: strict-origin-when-cross-origin; replace*with the exact allowed origin. Verify withcurl -I. - Cookie: set the session cookie server-side with
HttpOnly; Secure; SameSite=Lax. Verify in DevTools thatdocument.cookieno longer shows it. - Errors: use a generic error page ("Something went wrong, reference 1234") and log the details on the server only. Verify by revisiting the bad URL.
- Headers: add
-
Stop Juice Shop with Ctrl + C in the first terminal.
Ravindra Bagale's Tip
A finding without a fix is just a complaint. Developers love a report that says exactly what to change and how to check it. And always write "how to verify", because a fix that cannot be tested will quietly come back. Fix ani proof, donhi!
Ravindra Bagale's Tip – मराठी
Fix शिवाय finding म्हणजे फक्त तक्रार. नेमकं काय बदलायचं आणि कसं check करायचं हे सांगणारा report developers ना आवडतो. आणि नेहमी "how to verify" लिहा, कारण test न होणारा fix हळूच परत येतो. Fix आणि proof, दोन्ही!
Ravindra Bagale's Tip – हिंदी
Fix के बिना finding सिर्फ शिकायत है। Developers को वो report पसंद है जो बताए कि क्या बदलना है और कैसे check करना है। और हमेशा "how to verify" लिखो, क्योंकि जो fix test न हो सके वो चुपचाप वापस आ जाता है। Fix और proof, दोनों!
Common mistakes
| Mistake | What happens | Fix |
|---|---|---|
Running -p 3000:3000 without 127.0.0.1: |
The vulnerable app may be reachable from your Wi-Fi network | Always -p 127.0.0.1:3000:3000 |
| Registering with your real email and password | A real secret ends up in a training app | Use fake practice details |
| Checking cookies before logging in | The token cookie does not exist yet |
Log in first, then open Application → Cookies |
| Writing "XSS possible" without a fix | Developers cannot act on it | Write the exact fix and how to verify it |
| Leaving the container running | It keeps using RAM | Ctrl + C; docker ps should be empty |
Self-check checklist
0 of 6 done
Try-at-home challenge
From another device on your home Wi-Fi (your phone), try to open http://<your-laptop-IP>:3000. What happens, and why is that the result you want?
Check your answer
It does not load. Because you published the port as 127.0.0.1:3000:3000, Docker listens only on your laptop's loopback address, so nothing on the network can reach the deliberately vulnerable app. That is exactly the isolation you want for a training app.
Samjla ka? Look carefully, write the finding, write the fix, write how to verify. Aata pudhe jaauya: Chapter 22 is all about passwords.