fix(security): Phase 1 P0 hardening from cross-project audit
Close open uploads, image-proxy SSRF, fail-open AI quotas in production, auth gaps on app routes, and MCP tenant isolation issues. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { semanticSearchService, SearchResult } from '@/lib/ai/services/semantic-search.service'
|
||||
import { auth } from '@/auth'
|
||||
import { reserveUsageOrThrow, QuotaExceededError } from '@/lib/entitlements'
|
||||
import { reserveUsageOrThrow, QuotaExceededError, QuotaServiceUnavailableError } from '@/lib/entitlements'
|
||||
|
||||
export interface SemanticSearchResponse {
|
||||
results: SearchResult[]
|
||||
@@ -28,6 +28,11 @@ export async function semanticSearch(
|
||||
await reserveUsageOrThrow(session.user.id, 'semantic_search');
|
||||
} catch (err) {
|
||||
if (err instanceof QuotaExceededError) throw err;
|
||||
if (err instanceof QuotaServiceUnavailableError || process.env.NODE_ENV === 'production') {
|
||||
throw err instanceof QuotaServiceUnavailableError
|
||||
? err
|
||||
: new QuotaServiceUnavailableError();
|
||||
}
|
||||
console.error('[semantic-search] Quota check error (fail-open):', err);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user