π A cutting-edge Capture the Flag platform disguised as a robotics company website
Built with Next.js 15.5.2, React 19.1.1, TypeScript 5.9, and Tailwind CSS 4, this platform serves as both a fully functional corporate website and a comprehensive cybersecurity training environment with 16+ integrated challenges spanning web security, cryptography, steganography, and AI safety.
π― Complete Challenge Guide & Solutions β
- Progressive Difficulty: 50-1000 points across 5 categories (Web, Crypto, Forensics, Reverse, Misc)
- Real-World Scenarios: Supply chain attacks, AI jailbreaking, social engineering
- Educational Focus: Each challenge teaches specific security concepts
- Hidden Discovery: Challenges found through recon, source analysis, and interaction
- Role-Based Access Control: Dev, Admin, and User roles with proper permission boundaries
- Multi-Layer Protection: CSP, HSTS, XSS prevention, input validation
- Rate Limiting: Progressive lockout system with monitoring dashboard
- Row Level Security: Database-level access control with Supabase RLS
- Neural Reconstruction System: Progress-based challenge unlocking (50%+ unlocks advanced challenges)
- AI Activation Feature: Admin-only functionality with frontend bypass challenge
- Team Management: Multi-member project collaboration (max 3 per team)
- Real-Time Notifications: Dev-only monitoring system for AI activations and promotions
- Next.js 15.5.2 with App Router and React 19.1.1
- TypeScript 5.9 for type safety
- Tailwind CSS 4 for responsive design
- Supabase for authentication and database
- Jest 30.1.2 with comprehensive test coverage (220+ tests)
- Responsive Design: Mobile-first approach with dark/light mode support
- Corporate Website Facade: Convincing robotics company front-end
- Cyberpunk Aesthetics: CTF-themed styling with terminal interfaces
- Accessibility: ARIA support and keyboard navigation
.
βββ app/ # Next.js App Router directory
β βββ api/ # API routes
β β βββ auth/ # Authentication endpoints
β β β βββ [...nextauth]/ # NextAuth.js configuration
β β βββ hello/ # Secure API endpoint example
β β βββ route.ts # GET/POST handlers with validation
β βββ about/ # About page
β β βββ page.tsx # Company information and contact
β βββ assembly-line/ # Assembly line demo page
β β βββ page.tsx # Interactive robotics demo
β βββ components/ # Reusable React components
β β βββ Navigation.tsx # Main navigation component
β βββ contexts/ # React context providers
β β βββ AuthContext.tsx # Authentication context
β βββ login/ # Authentication page
β β βββ page.tsx # Login form and authentication
β βββ projects/ # Projects showcase page
β β βββ page.tsx # User projects and demos
β βββ layout.tsx # Root layout with security headers
β βββ page.tsx # Homepage component
β βββ globals.css # Global styles with Tailwind
βββ __tests__/ # Jest test directory
β βββ api.test.ts # API security tests
β βββ setup.ts # Test configuration
βββ middleware.ts # Global middleware for security
βββ next.config.mjs # Next.js configuration
βββ tailwind.config.ts # Tailwind CSS configuration
βββ jest.config.ts # Jest testing configuration
βββ jest.setup.ts # Jest setup configuration
βββ package.json # Dependencies and scripts
- Homepage (
/) - Main landing page with company overview - About (
/about) - Company information and contact details - Projects (
/projects) - User projects and interactive demos - Assembly Line (
/assembly-line) - Interactive robotics demonstration with advanced challenges - Team (
/team) - Internal team directory with CTF role hierarchies - Login (
/login) - Authentication and user management - Privacy Policy (
/privacy) - GDPR-compliant privacy information and cookie details
Current Status: β No cookie banner needed (essential cookies only)
| Topic | Location | Description |
|---|---|---|
| Cookie Inventory | docs/privacy/cookie-inventory.md |
Complete GDPR compliance documentation |
| Enable Cookie Banner | Set NEXT_PUBLIC_ENABLE_COOKIE_CONSENT=true |
For testing or if localStorage is added |
| Feature Flags | lib/featureFlags.ts |
Central toggle for cookie consent system |
| Privacy Policy | /privacy route |
User-facing privacy information |
| Tests | __tests__/lib/consentedStorage.test.ts |
Consent system test coverage |
- Server-side authentication with Supabase
- HTTP-only cookies for secure session management
- Row Level Security (RLS) policies in database
- Role-based access control (user, admin, dev)
- JWT token handling with automatic refresh
- Password reset flow with secure email-based recovery
- Email enumeration protection for security
- Content Security Policy (CSP): Prevents XSS attacks
- Strict Transport Security (HSTS): Enforces HTTPS
- X-Content-Type-Options: Prevents MIME type sniffing
- X-Frame-Options: Prevents clickjacking attacks
- Middleware Protection: Global request logging and security headers
- Zod schema validation for all API inputs
- Email format validation with proper regex
- Password strength requirements (minimum 8 characters)
- UUID validation for challenge IDs
- Length limits on all text inputs
- XSS payload sanitization
- Authentication required for sensitive operations
- Prepared statements to prevent SQL injection
- Error handling without information leakage
- Rate limiting considerations (timing attack prevention)
- Request logging for monitoring
The platform includes a secure password reset system with the following features:
- Email enumeration protection: Always returns the same message regardless of email validity
- Rate limiting: Prevents abuse of the password reset endpoint
- Server-side validation: Comprehensive input validation and sanitization
- Secure redirect URLs: Uses environment variables for redirect configuration
- Audit logging: All password reset requests are logged for monitoring
- Forgot Password: Users can access
/forgot-passwordto request a password reset - Email Verification: System sends a secure reset link to the provided email address
- Token Validation: Reset tokens are validated both client-side and server-side
- Password Update: Users set a new password that meets security requirements
- Automatic Redirect: After successful reset, users are redirected to login
- POST
/api/auth/reset-password: Request password reset email - AuthContext Methods:
requestPasswordReset()andupdatePassword()for client integration
Password reset emails use the following redirect URL hierarchy:
NEXTAUTH_URLenvironment variable (primary)VERCEL_URLenvironment variable (deployment)http://localhost:3000(fallback for development)
To enable password reset functionality:
- Configure Supabase Email Auth settings in your dashboard
- Set redirect URL to:
{your-domain}/reset-password - Customize email templates as needed
- Node.js 20.19.4 (locked for Next.js 15 compatibility)
- npm 10.0.0 (locked for consistent package resolution)
- Supabase account (sign up at https://supabase.com)
-
Clone the repository
git clone <your-repo-url> cd robotics-ctf
-
Install dependencies
npm install
-
Set up Supabase Database
- Go to your Supabase project dashboard
- Navigate to SQL Editor
- Execute the schema in
supabase/schema.sql(if not already done) - The
user_projectstable already exists with proper RLS policies - Users can only access their own projects via RLS
-
Set up environment variables Create
.env.localwith:# Public (client-side) NEXT_PUBLIC_SUPABASE_URL=your_supabase_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key # Private (server-side only) SUPABASE_SERVICE_ROLE_KEY=your_service_role_key NEXTAUTH_SECRET=your_random_secret NEXTAUTH_URL=http://localhost:3000 # For production (optional) # NEXT_PUBLIC_SITE_URL=https://your-production-domain.com
-
Run the development server
npm run dev
-
Open your browser Navigate to http://localhost:3000
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm test -- --coverageThe project includes comprehensive tests for:
- API endpoint security
- Input validation
- XSS protection
- Error handling
- Response formatting
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLint 9.34.0npm test- Run Jest 30.1.2 testsnpm run test:watch- Run tests in watch mode
To test the cookie consent system during development:
# Enable cookie banner for testing
echo "NEXT_PUBLIC_ENABLE_COOKIE_CONSENT=true" >> .env.local
npm run dev
# Test specific consent functionality
npm test __tests__/lib/consentedStorage.test.ts
# Disable when done testing
# Remove the line from .env.local or set to falseWhat you'll see when enabled:
- π€ Robotics-themed cookie banner with terminal animations
- βοΈ Persistent "Cookie Settings" button in bottom-right corner
- π Privacy policy page with detailed cookie information
- Route Parameters: All
paramsare now Promises and must be awaited - Cookies API:
cookies()now returns a Promise requiring async handling - TailwindCSS v4: Major version upgrade with new PostCSS plugin structure
- Node.js Version: Locked to v20.19.4 for compatibility
- Test Types: 89 TypeScript errors in test files due to Request vs NextRequest changes
- Components: React components in
app/directory - API Routes: Server-side API handlers in
app/api/ - Styling: Tailwind CSS with custom component classes
- Testing: Jest tests in
__tests__/directory
This application currently only uses essential authentication cookies from Supabase and does not require cookie consent under GDPR because:
- No functional localStorage: All user data (projects) is stored in the database
- No analytics/tracking cookies: No third-party analytics or advertising
- Only essential cookies: Supabase auth cookies necessary for login functionality
- No user preferences storage: No UI customizations or settings stored in browser
| Cookie Name | Purpose | Duration | Legal Basis |
|---|---|---|---|
sb-access-token |
Authentication token | Session | Legitimate interest (essential) |
sb-refresh-token |
Token refresh | 7 days | Legitimate interest (essential) |
sb-provider-token |
OAuth provider tokens | Session | Legitimate interest (essential) |
sb-user |
User session metadata | Session | Legitimate interest (essential) |
If you add localStorage usage or other functional cookies in the future, you can re-enable the cookie consent system:
-
Set feature flag:
// In lib/featureFlags.ts cookieConsentEnabled: true
-
Or use environment variable:
NEXT_PUBLIC_ENABLE_COOKIE_CONSENT=true
-
Or enable for testing/development:
# Add to .env.local NEXT_PUBLIC_ENABLE_COOKIE_CONSENT=true npm run dev -
The system includes:
- π¨ Robotics-themed cookie consent banner with terminal animations
- βοΈ Cookie preferences modal with granular controls
- π Consent-aware localStorage wrapper that blocks writes without consent
- π Privacy policy page at
/privacywith detailed cookie information - β
Complete test suite for consent logic in
__tests__/lib/consentedStorage.test.ts
-
Documentation:
- Cookie Inventory:
docs/privacy/cookie-inventory.md- Complete GDPR compliance documentation - Privacy Policy: Available at
/privacyroute for users - Feature Flags:
lib/featureFlags.ts- Central feature toggle system
- Cookie Inventory:
- Always validate input on the server side
- Use TypeScript for type safety
- Sanitize user input to prevent XSS
- Implement proper error handling
- Use secure session management
- Implement proper JWT handling
- Add rate limiting for API endpoints
- Log security events
- Use HTTPS in production
- Implement proper CORS policies
- Sanitize database queries
- Use environment variables for secrets
Challenges are stored in the Supabase database and accessed through secure APIs:
- GET
/api/challenges- Fetch available challenges (requires authentication) - POST
/api/challenges/submit- Submit flags with automatic scoring - GET
/api/profile- View user statistics and progress - GET
/api/leaderboard- Public rankings
The platform comes with pre-loaded challenges:
-
Welcome to CTF (misc, easy, 50 points)
- Flag:
RBT{welcome_to_robotics_ctf}
- Flag:
-
Admin Terminal Breach (web, hard, 250 points)
- Flag:
RBT{4dm1n_t3rm1n4l_pwn3d_6d8e4b} - Location:
/admin-terminal?access=alex_was_here - Method: XSS exploitation to access admin flag variable
- Flag:
-
Contact Protocol (crypto, medium, 250 points)
- Flag:
RBT{security_through_obscurity_fails} - Location:
/security.txt(ROT13 decoding required)
- Flag:
-
Intern Account Access (misc, hard, 300 points)
- Flag:
RBT{sleepy_intern_logged_in} - Credentials: alex@robo.tech / P@ssw0rd
- Flag:
-
Frontend Admin Bypass (web, medium, 250 points)
- Flag:
RBT{frontend_admin_checks_are_useless} - Location: Assembly Line page AI activation feature
- Method: Bypass client-side admin checks to trigger rickroll countermeasure and receive flag
- Flag:
-
Ultimate Admin Access (misc, hard, 500 points)
- Flag:
RBT{admin_access_granted_by_organizer} - Method: Social Engineering - participants must convince the CTF organizer to give them the flag
- Reward: Automatic promotion to admin role with full system privileges
- Description: The ultimate challenge that can't be solved through traditional hacking - requires human interaction
- Flag:
Users who complete the Ultimate Admin Access challenge receive the following benefits:
- Their
profiles.roleis automatically changed from'user'to'admin' - This happens instantly upon successful flag submission via database trigger
- The promotion is permanent (cannot be undone through the UI)
- AI System Control: Can permanently activate AI systems in the Assembly Line
- Enhanced Features: Access to admin-only UI components and functionality
- System Insights: View enhanced system information and diagnostic data
- Challenge Management: Potential access to challenge management features
- Special Status: Admin badges and indicators throughout the platform
- Uses PostgreSQL triggers for automatic role elevation
- Secured with
SECURITY DEFINERfunctions - Protected by Row Level Security (RLS) policies
- Cannot be achieved through frontend manipulation alone
Hidden Challenge Discovery
Challenges are discoverable through:
- Source Code Inspection: Hidden fragments and comments
- Directory Enumeration:
/robots.txt,/sitemap.xml,/security.txt - Interactive Elements: Konami code activation, debug modals
- Steganography: Hidden data in images and text
The Assembly Line page features an innovative challenge discovery system:
- Neural Threshold Trigger: When AI restoration reaches β₯50% completion, advanced challenges automatically unlock
- Intelligent Filtering: Displays only medium/hard difficulty challenges worth 200+ points
- Robotics Theme: Challenges are presented as "Advanced Challenge Protocols" with cyberpunk styling
- AI Activation Feature: Admin-only functionality that triggers Frontend Admin Bypass challenge when attempted by non-admins
- Attention-Grabbing Alerts:
- π Alarm Sound System: Robotic beep sequence using Web Audio API
- π Screen Flash Effect: Full-screen red overlay with pulsing animation
- π Auto-Scroll: Automatically scrolls to show the panel when unlocked
- π’ Header Notification: Live notification badge showing available challenges
- Interactive Elements:
- Animated warning headers with pulsing effects
- Category-based icons (π Web, π Crypto, βοΈ Reverse, etc.)
- Hover animations with scaling and glow effects
- Enhanced visual borders and shadow effects
- Direct links to individual challenge pages
- Frontend Admin Bypass: AI activation button that detects client-side admin bypass attempts
- Component:
AdvancedChallengesPanel.tsx - Trigger:
codeCompletion >= 50 - API Integration: Fetches from
/api/challengesendpoint - Responsive Design: Adapts from 1-3 columns based on screen size
- Error Handling: Gracefully handles authentication failures
// Modify challenge filtering criteria
const filtered = challenges?.filter((challenge: any) =>
(challenge.difficulty === 'medium' || challenge.difficulty === 'hard') &&
challenge.points >= 200 // Adjust point threshold
) || [];
// Change activation threshold
if (codeCompletion >= 75 && !showAdvanced) { // Change from 50 to 75
setShowAdvanced(true);
loadAdvancedChallenges();
}The /team page features a prominent role badge system that clearly distinguishes between different team groups:
- π CTF Challenge Architect - Alexandre De Groodt (CTF Lead)
- π Chief Exploitation Officer - Achraf (HackBox Expert)
- π₯· Shadow Ops Commander - LΓ©andre (Mr. Robot Type)
- πΌ North Star Agi β Business Operations - CΓ©dric Sounard
- π§ North Star Agi β AI Strategy Lead - Filip
- π€ North Star Agi β People & AI Ethics - Oleksandr
- π€ North Star Agi β Robotics Engineer - Laksiya
- β North Star Agi β Security Consultant - Patrick Star
- π― CTF Participant - Default role for all other registered users
- Location:
app/components/CTFRoleBadge.tsx - Features:
- Group-based gradient styling with shadow effects
- Hover animations (scale transform)
- Responsive text sizing (
text-sm md:text-base) - Full accessibility support (aria-labels, titles)
- Icon + text display with proper spacing
- Column:
profiles.ctf_role TEXT DEFAULT 'π― CTF Participant' - Migration:
supabase/migrations/20250910095623_add_ctf_role_column.sql - API Support: Team API route includes
ctfRolefield for database users
type CTFGroup = 'core' | 'northstar' | 'participant';
// Group determination logic
function getCtfGroup(role: string): CTFGroup {
const lowerRole = role.toLowerCase();
if (lowerRole.includes('ctf challenge architect') ||
lowerRole.includes('chief exploitation officer') ||
lowerRole.includes('shadow ops commander')) {
return 'core';
}
if (lowerRole.includes('north star agi')) {
return 'northstar';
}
return 'participant';
}- Core Team:
bg-gradient-to-r from-yellow-400 via-yellow-500 to-amber-500 - North Star:
bg-gradient-to-r from-indigo-500 via-purple-500 to-blue-600 - Participants:
bg-gradient-to-r from-emerald-400 via-teal-500 to-cyan-500
- Unit Tests:
__tests__/CTFRoleBadge.test.tsx - Group Classification: Validates correct role-to-group mapping
- Styling Verification: Ensures proper CSS class application
- Accessibility: Tests aria-labels and keyboard navigation
- Responsive Design: Validates mobile/desktop scaling
- OWASP Security Guidelines
- Cookie Inventory Documentation - GDPR compliance guide
- GDPR Guide for Developers
- Supabase Row Level Security
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
This platform is designed for educational purposes and CTF competitions. The security features are implemented to demonstrate best practices, but the platform may contain intentionally vulnerable endpoints for learning purposes. Do not deploy this in production without proper security review.
If you encounter any issues or have questions:
- Check the documentation
- Review the test files for examples
- Open an issue on GitHub
- Contact the development team
Happy Hacking! π―π