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 @@
## 2026-05-14 - Information Leakage in File Upload
**Vulnerability:** The API endpoint `src/app/api/upload/route.ts` previously exposed internal configuration status (missing environment variables) and full underlying Cloudinary error objects (including message, `http_code`, and raw `error`) to the client when a file upload failed.
**Learning:** Returning full error details to the client on generic Catch blocks is a common anti-pattern that can expose underlying third-party dependencies, API structure, or stack traces which an attacker can use for reconnaissance.
**Prevention:** Always implement an error handling boundary in API endpoints where server-side logs capture full raw errors/trace, while the HTTP responses mask these details with a generic user-facing message such as `Internal server error` or `Failed to upload image`.
125 changes: 0 additions & 125 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 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
// Log detailed error message internally
const errorMessage = error?.message || error?.error?.message || 'Failed to upload image';
const errorDetails = {
error: errorMessage,
Expand All @@ -70,8 +70,9 @@ export async function POST(request: NextRequest) {

console.error('Full error details:', errorDetails);

// Return generic error to the client to avoid leaking internal service details
return NextResponse.json(
errorDetails,
{ error: 'Failed to upload image' },
{ status: 500 }
);
}
Expand Down