Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2024-05-16 - Prevent Exposure of Internal Configuration and Service Errors
**Vulnerability:** The application had an unauthenticated debug endpoint (`src/app/debug/route.ts`) that leaked environment variables, including parts of `MONGODB_URI` and the status of `NEXTAUTH_SECRET`. Additionally, the `/api/upload` endpoint exposed internal configuration states (whether Cloudinary environment variables were set) and detailed Cloudinary service errors (`cloudinaryError`) in its JSON responses.
**Learning:** Returning detailed error messages and configuration states in API responses directly to clients can provide attackers with valuable intelligence about the application's infrastructure, dependencies, and internal setup, facilitating further attacks.
**Prevention:** Ensure that all API responses return generic, sanitized error messages (e.g., "Internal server error") to clients. Keep detailed error information, stack traces, and configuration states restricted to secure, internal server logs. Regularly review and remove debug endpoints before deploying to production.
6 changes: 3 additions & 3 deletions src/app/api/upload/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function POST(request: NextRequest) {
api_secret: !!process.env.CLOUDINARY_API_SECRET
});
return NextResponse.json(
{ error: 'Cloudinary is not configured. Please set environment variables.' },
{ error: 'Internal server error' },
{ status: 500 }
);
}
Expand Down Expand Up @@ -60,7 +60,7 @@ export async function POST(request: NextRequest) {
} catch (error: any) {
console.error('Upload error:', error);

// Return detailed error message
// Return generic error message to client, log details to server
const errorMessage = error?.message || error?.error?.message || 'Failed to upload image';
const errorDetails = {
error: errorMessage,
Expand All @@ -71,7 +71,7 @@ export async function POST(request: NextRequest) {
console.error('Full error details:', errorDetails);

return NextResponse.json(
errorDetails,
{ error: 'Internal server error' },
{ status: 500 }
);
}
Expand Down
100 changes: 0 additions & 100 deletions src/app/debug/route.ts

This file was deleted.