security: fix trace ownership bypass and externalize secrets to .env

- Add userId guard in trace upsert to prevent cross-user overwrites
- Move AUTH_SECRET, STRIPE_WEBHOOK_SECRET, POSTGRES_PASSWORD to .env
- docker-compose.yml now references env vars instead of hardcoded secrets
- Add .env.example with placeholder values for documentation
This commit is contained in:
Vectry
2026-02-10 16:53:57 +00:00
parent 539d35b649
commit e9cd11735c
3 changed files with 31 additions and 10 deletions

View File

@@ -241,9 +241,14 @@ export async function POST(request: NextRequest) {
for (const trace of body.traces) {
const existing = await tx.trace.findUnique({
where: { id: trace.id },
select: { id: true },
select: { id: true, userId: true },
});
// Security: prevent cross-user trace overwrite
if (existing && existing.userId !== userId) {
continue; // skip traces owned by other users
}
const traceData = {
name: trace.name,
sessionId: trace.sessionId,