Skip to content

Conversation

amanmogal
Copy link
Member

Implement comprehensive security fixes to address identified vulnerabilities and enhance application robustness.

This PR addresses critical security issues and introduces several enhancements based on a recent security audit. Key improvements include:

  • Environment Variable Validation: Ensures critical configurations are present and secure.
  • Secure CORS & Rate Limiting: Prevents cross-origin attacks and DoS.
  • Input Validation & File Upload Security: Protects against injection, XSS, and malicious file uploads.
  • Enhanced Authentication & Error Handling: Improves JWT security and prevents information disclosure.
  • Dependency Updates: Resolves known vulnerabilities from npm audit.

Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
npm/compression 1.8.1 🟢 8
Details
CheckScoreReason
Code-Review🟢 10all changesets reviewed
Binary-Artifacts🟢 10no binaries found in the repo
Dependency-Update-Tool🟢 10update tool detected
Packaging⚠️ -1packaging workflow not detected
Maintained🟢 98 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 9
Token-Permissions🟢 10GitHub workflow tokens follow principle of least privilege
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Pinned-Dependencies🟢 5dependency not pinned by hash detected -- score normalized to 5
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Vulnerabilities🟢 100 existing vulnerabilities detected
Fuzzing⚠️ 0project is not fuzzed
SAST🟢 9SAST tool detected but not run on all commits
License🟢 10license file detected
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
Signed-Releases⚠️ -1no releases found
Security-Policy🟢 10security policy file detected
CI-Tests🟢 1029 out of 29 merged PRs checked by a CI test -- score normalized to 10
Contributors🟢 10project has 19 contributing companies or organizations
npm/morgan 1.10.1 🟢 7.4
Details
CheckScoreReason
Binary-Artifacts🟢 10no binaries found in the repo
Branch-Protection🟢 4branch protection is not maximal on development and all release branches
CI-Tests🟢 46 out of 14 merged PRs checked by a CI test -- score normalized to 4
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Code-Review🟢 4found 15 unreviewed changesets out of 29 -- score normalized to 4
Contributors🟢 106 different organizations found -- score normalized to 10
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Dependency-Update-Tool🟢 10update tool detected
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Maintained🟢 66 commit(s) out of 30 and 2 issue activity out of 30 found in the last 90 days -- score normalized to 6
Packaging⚠️ -1no published package detected
Pinned-Dependencies🟢 6dependency not pinned by hash detected -- score normalized to 6
SAST🟢 7SAST tool detected but not run on all commits
Security-Policy🟢 10security policy file detected
Signed-Releases⚠️ -1no releases found
Token-Permissions🟢 10GitHub workflow tokens follow principle of least privilege
Vulnerabilities🟢 10no vulnerabilities detected
npm/multer 2.0.2 🟢 7.1
Details
CheckScoreReason
Binary-Artifacts🟢 10no binaries found in the repo
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
CI-Tests🟢 612 out of 18 merged PRs checked by a CI test -- score normalized to 6
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Code-Review🟢 6Found 17/27 approved changesets -- score normalized to 6
Contributors🟢 10project has 54 contributing companies or organizations
Dangerous-Workflow⚠️ -1internal error: internal error: invalid GitHub workflow: :18:0: could not parse as YAML: yaml: line 18: did not find expected ',' or ']' [syntax-check]
Dependency-Update-Tool🟢 10update tool detected
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Maintained🟢 1023 commit(s) and 18 issue activity found in the last 90 days -- score normalized to 10
Packaging⚠️ -1internal error: internal error: invalid GitHub workflow: :18:0: could not parse as YAML: yaml: line 18: did not find expected ',' or ']' [syntax-check]
Pinned-Dependencies⚠️ -1internal error: internal error: invalid GitHub workflow: :18:0: could not parse as YAML: yaml: line 18: did not find expected ',' or ']' [syntax-check]
SAST⚠️ -1internal error: internal error: invalid GitHub workflow: :18:0: could not parse as YAML: yaml: line 18: did not find expected ',' or ']' [syntax-check]
Security-Policy🟢 10security policy file detected
Signed-Releases⚠️ -1no releases found
Token-Permissions⚠️ -1internal error: internal error: invalid GitHub workflow: :18:0: could not parse as YAML: yaml: line 18: did not find expected ',' or ']' [syntax-check]
Vulnerabilities🟢 100 existing vulnerabilities detected
npm/on-headers 1.1.0 🟢 6.6
Details
CheckScoreReason
Binary-Artifacts🟢 10no binaries found in the repo
Maintained🟢 1011 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10
Packaging⚠️ -1packaging workflow not detected
Code-Review⚠️ 2Found 8/30 approved changesets -- score normalized to 2
Pinned-Dependencies⚠️ 1dependency not pinned by hash detected -- score normalized to 1
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Token-Permissions🟢 10GitHub workflow tokens follow principle of least privilege
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Vulnerabilities🟢 100 existing vulnerabilities detected
Fuzzing⚠️ 0project is not fuzzed
Signed-Releases⚠️ -1no releases found
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
Security-Policy🟢 9security policy file detected
SAST🟢 8SAST tool detected but not run on all commits
npm/validator 13.15.15 🟢 6.9
Details
CheckScoreReason
Code-Review🟢 9Found 28/30 approved changesets -- score normalized to 9
Maintained🟢 86 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 8
Packaging⚠️ -1packaging workflow not detected
Security-Policy🟢 10security policy file detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Binary-Artifacts🟢 10no binaries found in the repo
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Vulnerabilities🟢 100 existing vulnerabilities detected
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
Signed-Releases⚠️ -1no releases found
SAST🟢 9SAST tool detected but not run on all commits
npm/validator ^13.15.15 🟢 6.9
Details
CheckScoreReason
Code-Review🟢 9Found 28/30 approved changesets -- score normalized to 9
Maintained🟢 86 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 8
Packaging⚠️ -1packaging workflow not detected
Security-Policy🟢 10security policy file detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Binary-Artifacts🟢 10no binaries found in the repo
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Vulnerabilities🟢 100 existing vulnerabilities detected
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
Signed-Releases⚠️ -1no releases found
SAST🟢 9SAST tool detected but not run on all commits

Scanned Files

  • package-lock.json
  • package.json

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Route Registration Glitches Impact API Functionality

Duplicate route registrations for /api/alerts, /api/disasters, and /api/emergency endpoints. The routes for /api/alerts and /api/disasters are registered twice; the initial registration is matched first, preventing the emergencyLimiter from being applied. Furthermore, the emergency endpoint has a path mismatch, being registered as /api/emergency in one instance and /api/emergencies in another, leading to inconsistent routing and misapplied rate limiting.

server.js#L256-L275

app.use('/api/ai', aiRoutes);
app.use('/api/alerts', alertRoutes);
app.use('/api/disasters', disasterRoutes);
app.use('/api/emergency', emergencyRoutes);
app.use('/api/evacuation', evacuationRoutes);
app.use('/api/gemini', geminiRoutes);
app.use('/api/maps', mapRoutes);
app.use('/api/predictions', predictionRoutes);
app.use('/api/notifications', pushNotificationRoutes);
app.use('/api/routes', routeRoutes);
app.use('/api/safe-zones', safeZoneRoutes);
app.use('/api/users', userRoutes);
app.use('/api/voice', voiceLimiter, voiceRoutes);
app.use('/api/diagnostic', diagnosticRoutes);
// Emergency endpoints with less restrictive rate limiting
app.use('/api/alerts', emergencyLimiter, alertRoutes);
app.use('/api/disasters', emergencyLimiter, disasterRoutes);
app.use('/api/emergencies', emergencyLimiter, emergencyRoutes);

Fix in CursorFix in Web


Bug: Firebase UID Validation Fails

The validateUserId function's validation logic is too restrictive for Firebase UIDs. The condition !validator.isUUID(userId) && !validator.isAlphanumeric(userId) incorrectly rejects valid Firebase UIDs that can contain characters like dashes and underscores.

middleware/security/inputValidator.js#L64-L67

// Check if it's a valid UUID or Firebase UID format
if (!validator.isUUID(userId) && !validator.isAlphanumeric(userId)) {
throw new Error('Invalid user ID format');
}

Fix in CursorFix in Web


BugBot free trial expires on July 22, 2025
Learn more in the Cursor dashboard.

Was this report helpful? Give feedback by reacting with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants