- Shlok Kanani (B23CS1068)
- Prakhar Goyal (B23CS1106)
- Raditya Saraf (B23CS1107)
- Danie George John (B23ES1012)
- Bhawani Shankar Prajapat (B23CS1104)
This is a complete, real-world demonstration of an Insecure Direct Object Reference (IDOR) vulnerability in a multi-tier web application. The project showcases:
- β Vulnerable Backend API with sequential document IDs and missing authorization checks
- β Automated Python Attack Script that exploits the IDOR vulnerability
- β React Frontend UI for user authentication and document management
- β Local MySQL Database with persistent data storage (UPDATE mode)
- β JWT Authentication system with proper token generation
- β Attack Simulation demonstrating unauthorized access to 150+ documents across multiple users
| Phase | Goal | Status |
|---|---|---|
| Phase 1 | Environment Setup & Vulnerable Implementation | β COMPLETE |
| Phase 2 | Attack Execution & Vulnerability Demonstration | β COMPLETE |
| Phase 3 | Defense Implementation & Mitigation | β COMPLETE |
Cybersec Project/
βββ backend/ # Spring Boot REST API
β βββ src/main/java/com/idor/project/
β β βββ controller/
β β β βββ AuthController.java # User registration & login
β β β βββ DocumentController.java # Document CRUD endpoints
β β βββ service/
β β β βββ AuthService.java
β β β βββ DocumentService.java
β β βββ security/
β β β βββ JwtTokenProvider.java # JWT token generation & validation
β β βββ entity/
β β β βββ User.java
β β β βββ Document.java
β β βββ repository/
β β βββ UserRepository.java
β β βββ DocumentRepository.java
β βββ src/main/resources/
β β βββ application.properties # Local MySQL configuration
β β βββ application-prod.properties # Production Azure configuration
β β βββ data.sql # Initial database setup
β βββ pom.xml # Maven dependencies
β βββ startup.sh # Azure deployment script
βββ frontend/ # React.js UI
β βββ src/
β β βββ components/
β β β βββ Navbar.jsx
β β β βββ DocumentModal.jsx
β β β βββ LoginForm.jsx
β β βββ pages/
β β β βββ LoginPage.jsx
β β β βββ DocumentsPage.jsx
β β β βββ AttackPage.jsx
β β β βββ OverviewPage.jsx
β β β βββ MitigationsPage.jsx
β β βββ App.jsx
β β βββ AuthContext.jsx
β β βββ api.js
β β βββ index.css
β βββ package.json
β βββ vite.config.js
β βββ eslint.config.js
βββ data_populator.py # Test data generation script
βββ attack_script.py # IDOR exploitation script
βββ ATTACK_GUIDE.md # Detailed attack instructions
βββ README.md # This file
- Java 17 or higher
- Maven 3.8.9 or higher
- MySQL 8.0 (local or remote)
- Node.js 18+ or higher
- npm 9+ or higher
- Python 3.8+
- requests library (
pip install requests)
# Connect to MySQL (use your root credentials)
mysql -u root -p
# Create database
CREATE DATABASE idor_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# Create user
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON idor_db.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;
# Exit MySQL
EXIT;MySQL Workbench Connection Details:
- Hostname: localhost
- Port: 3307
- Username: myuser
- Password: secret
- Database: idor_db
# Navigate to backend directory
cd /Users/daniegeorgejohn/Desktop/Cybersec\ Project/backend
# Build the project
./mvnw clean package -DskipTests
# Run the application
./mvnw spring-boot:runBackend will be available at:
http://localhost:8080
API Endpoints:
POST /api/auth/register- Register new userPOST /api/auth/login- Login and get JWT tokenPOST /api/documents/create- Create a new documentGET /api/documents/{id}- Get document by ID (VULNERABLE)GET /api/documents/user/{userId}- Get user's documents
# Navigate to frontend directory
cd /Users/daniegeorgejohn/Desktop/Cybersec\ Project/frontend
# Install dependencies
npm install
# Start development server
npm run devFrontend will be available at:
http://localhost:5173
# Navigate to project root
cd /Users/daniegeorgejohn/Desktop/Cybersec\ Project/
# Install Python dependencies
pip3 install requests
# Run data populator (creates 10 users with 15 documents each = 150 total)
python3 data_populator.py -u http://localhost:8080 --users 10 --docs 15# Run attack script with comprehensive reporting
python3 attack_script.py \
-u http://localhost:8080 \
--register-email attacker@example.com \
--register-pass AttackerPass123! \
--start-id 1 \
--end-id 200 \
--output-log attack_results.txt \
--export-json discovered_documents.jsonExpected Results:
- β 140+ documents successfully accessed
- β Documents from all 10 users compromised
- β Unauthorized access confirmed
- β Detailed attack report generated
curl -X POST http://localhost:8080/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "Password123!",
"firstName": "John",
"lastName": "Doe"
}'Response:
{
"userId": 2,
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe"
}curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "Password123!"
}'Response:
{
"token": "eyJhbGciOiJIUzM4NCJ9...",
"userId": 2,
"email": "user@example.com",
"type": "Bearer"
}curl -X POST http://localhost:8080/api/documents/create \
-H "Authorization: Bearer {JWT_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"title": "My Document",
"content": "Sensitive information here"
}'curl -X GET http://localhost:8080/api/documents/1 \
-H "Authorization: Bearer {JWT_TOKEN}"curl -X GET http://localhost:8080/api/documents/user/2 \
-H "Authorization: Bearer {JWT_TOKEN}"Insecure Direct Object Reference (IDOR)
DocumentController.getDocument() - GET /api/documents/{id}
The API endpoint returns any document matching the requested ID without verifying if the authenticated user owns that document.
- Unauthorized access to sensitive documents
- Data breach across all users
- Privacy violation
- User A authenticates and gets JWT token
- User A calls
GET /api/documents/50(a document belonging to User B) - API blindly returns User B's document without ownership check
- User A can enumerate all documents (IDs 1-1000+) and extract complete database
- Documents Tested: 200
- Documents Accessed: 140+
- Success Rate: 70%
- Users Compromised: 10
- Execution Time: ~2 minutes
The DocumentController now includes ownership verification:
@GetMapping("/{id}")
public ResponseEntity<Document> getDocument(@PathVariable Long id,
@RequestHeader("Authorization") String authHeader) {
String token = authHeader.substring(7);
Long userId = jwtTokenProvider.getUserIdFromToken(token);
Optional<Document> document = documentService.getDocumentById(id);
if (document.isPresent() && document.get().getUserId().equals(userId)) {
return ResponseEntity.ok(document.get());
}
return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
}- DDL Mode:
update- Preserves data across restarts - Dialect: MySQLDialect - Compatible with MySQL 8.0
- Character Set: utf8mb4 - Unicode support
- Open http://localhost:5173
- Register two test users
- Log in as User 1
- Create some documents
- Log in as User 2
- Try accessing User 1's documents
- Observe authorization checks working
- Run
data_populator.pyto create test data - Run
attack_script.pyto demonstrate IDOR - Review
attack_results.txtfor detailed log - Check
discovered_documents.jsonfor extracted data
spring.datasource.url=jdbc:mysql://localhost:3307/idor_db
spring.datasource.username=myuser
spring.datasource.password=secret
spring.jpa.hibernate.ddl-auto=updatespring.datasource.url=${SPRING_DATASOURCE_URL}
spring.datasource.username=${SPRING_DATASOURCE_USERNAME}
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD}
spring.jpa.hibernate.ddl-auto=update- ATTACK_GUIDE.md - Comprehensive attack execution guide
- PHASE_1_COMPLETION_REPORT.md - Phase 1 detailed report
- JWT_IMPLEMENTATION_SUMMARY.md - JWT authentication details
- DATABASE_DEPLOYMENT_GUIDE.md - Database setup instructions
- Spring Boot 4.1.0-M3
- Java 17
- MySQL 8.0
- Hibernate 7.2.7
- JJWT 0.12.3 (JWT Library)
- Spring Security with BCrypt
- React.js 18
- Vite (Build tool)
- CSS3
- Axios (HTTP client)
- Python 3.12
- Maven 3.8.9
- Node.js 18+
- MySQL Workbench
This project demonstrates:
- How IDOR vulnerabilities occur in real applications
- Why sequential IDs are dangerous in APIs
- How proper authorization checks prevent exploitation
- End-to-end vulnerability testing methodology
- Full-stack web application security
- This is an educational project for learning purposes only
- Never use this for unauthorized access to real systems
- Always obtain proper authorization before security testing
- This vulnerability is CRITICAL and must be fixed immediately in production
For production deployment to Azure App Service, see startup.sh and deployment guides in the documentation folder.
For issues or questions, refer to the detailed documentation files or consult the project team.