T05 · Unauthorized Access and Privilege Escalation
- Location
src/index.js:43- Finding
Unauthenticated Access to Sensitive User Data and Safety-Critical Operations
- Content
View full analysis
{ res.header('Access-Control-Allow-Origin', '*'); next(); }); this.app.use((req, res, next) => { console.log(`[${new Date().toISOString()}] ${req.method} ${req.path}`); next(); }); } ``` The following sensitive routes are registered without authentication or authorization middleware: ```javascript // Register user this.app.post('/register', async (req, res) => { try { const { userId, name, phone, emergencyContacts } = req.body; if (!userId || !name) { return res.status(400).json({ error: 'Missing required fields' }); } const user = this.userManager.registerUser(userId, { name, phone, emergencyContacts }); res.json({ success: true, message: 'Registration successful', user }); } catch (error) { console.error('Registration failed:', error); res.status(500).json({ error: error.message }); } }); // User check-in this.app.post('/checkin', async (req, res) => { try { const { userId, message, mood, location } = req.body; if (!userId) { return res.status(400).json({ error: 'Missing userId' }); } const result = this.userManager.checkin(userId, { message, mood, location }); res.json({ success: true, message: 'Check-in successful', data: result }); } catch (error) { console.error('Check-in failed:', error); res.status(500).json({ error: error.message }); } }); // Query status this.app.get('/status/:userId', (req, res) => { try { const { userId } = req.params; const status = this.userManager.getUserStatus(userId); if (!status) { ...[truncated 3870 chars]- Remediation
View remediation
