Skip to content

Security: 3 automated fixes (3 HIGH) - #5

Open
usualdork wants to merge 1 commit into
mainfrom
angelone-security/fixes-f667dec6ee-20260621150427
Open

Security: 3 automated fixes (3 HIGH)#5
usualdork wants to merge 1 commit into
mainfrom
angelone-security/fixes-f667dec6ee-20260621150427

Conversation

@usualdork

@usualdork usualdork commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Summary

This pull request was opened automatically based on findings from a security scan. Please review the diff carefully before merging — automated fixes are best-effort and may require adjustments.

Findings addressed

Severity Count
CRITICAL 0
HIGH 3
MEDIUM 0
LOW 0

Per-finding detail

  • HIGH Build-time security gates disabled (ignoreBuildErrors / ignoreDuringBuilds) [CWE-1127] — next.config.ts:4
  • HIGH IDOR — message and conversation access by arbitrary chatId without ownership checks [CWE-639] — src/app/api/inbox/messages/[chatId]/route.ts:1
  • HIGH QR code (WhatsApp linking secret) exposed via unauthenticated status endpoint [CWE-200] — src/app/api/whatsapp/status/route.ts:1

Files changed

  • next.config.ts (1 finding)
  • src/app/api/inbox/messages/[chatId]/route.ts (1 finding)
  • src/app/api/whatsapp/status/route.ts (1 finding)

What changed and why

next.config.ts

Re-enabled build-time TypeScript type checking and ESLint linting by setting ignoreBuildErrors and ignoreDuringBuilds to false. This ensures type-confusion bugs and security-relevant lint findings block production builds instead of shipping silently.

src/app/api/inbox/messages/[chatId]/route.ts

Added an authentication check at the start of the GET handler so that message history can only be fetched by an authenticated operator session, preventing unauthenticated users from enumerating and reading arbitrary conversations by chatId (IDOR).

src/app/api/whatsapp/status/route.ts

The status endpoint returned the WhatsApp client state—including the linking QR code—to any unauthenticated caller. The fix requires a valid authenticated session before returning the state, preventing attackers from capturing the QR and hijacking the WhatsApp account.

Scan metadata

  • Scan ID: f667dec6-ee1b-4c43-9470-c46e8239a6d9
  • Model: claude-opus-4-7
  • Cost: $0.00

Do not auto-merge; every patch must be reviewed by a human.

scan_id: f667dec6-ee1b-4c43-9470-c46e8239a6d9
files_changed: 3

@usualdork usualdork left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Each inline comment below explains what changed on that line and why. The high-level summary per file:

next.config.ts

Re-enabled build-time TypeScript type checking and ESLint linting by setting ignoreBuildErrors and ignoreDuringBuilds to false. This ensures type-confusion bugs and security-relevant lint findings block production builds instead of shipping silently.

src/app/api/inbox/messages/[chatId]/route.ts

Added an authentication check at the start of the GET handler so that message history can only be fetched by an authenticated operator session, preventing unauthenticated users from enumerating and reading arbitrary conversations by chatId (IDOR).

src/app/api/whatsapp/status/route.ts

The status endpoint returned the WhatsApp client state—including the linking QR code—to any unauthenticated caller. The fix requires a valid authenticated session before returning the state, preventing attackers from capturing the QR and hijacking the WhatsApp account.

Comment thread next.config.ts
/* config options here */
typescript: {
ignoreBuildErrors: true,
ignoreBuildErrors: false,

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

✏️ Setting ignoreBuildErrors to false restores TypeScript type checking during production builds, so type-confusion and unsafe data-shape errors are caught before deployment.

Comment thread next.config.ts
},
eslint: {
ignoreDuringBuilds: true,
ignoreDuringBuilds: false,

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

✏️ Setting ignoreDuringBuilds to false restores ESLint enforcement during builds, so security-relevant lint findings (e.g., dangerous patterns) block the build.


import { NextResponse } from 'next/server';
import { getMessages } from '@/lib/db';
import { requireSession } from '@/lib/auth';

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

➕ Imports the session-enforcement helper used to authenticate the request before any data is accessed.

{ params }: { params: { chatId: string } }
) {
try {
await requireSession(request);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

➕ Enforces an authenticated operator session before reading messages. If the session is missing/invalid, this throws and the request is rejected, blocking unauthenticated access to arbitrary chatId conversations.

@@ -1,9 +1,15 @@
import { NextResponse } from 'next/server';
import { getClientState } from '@/lib/whatsapp-client';
import { auth } from '@/lib/auth';

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

➕ Imports the authentication helper used to verify the caller has a valid session before exposing sensitive state.

export const dynamic = 'force-dynamic';

export async function GET() {
export async function GET(req: Request) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

➕ New handler signature accepts the request so the session can be validated from request context.


export async function GET() {
export async function GET(req: Request) {
const session = await auth(req);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

➕ Resolves the current session to determine whether the caller is authenticated.

export async function GET() {
export async function GET(req: Request) {
const session = await auth(req);
if (!session) {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

➕ Rejects requests that lack a valid session, blocking anonymous access to the QR.

export async function GET(req: Request) {
const session = await auth(req);
if (!session) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

➕ Returns a 401 instead of leaking the WhatsApp linking secret to unauthenticated callers.


export const dynamic = 'force-dynamic';

export async function GET() {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

➖ Removed the unauthenticated handler that returned the QR/client state to anyone.

@usualdork usualdork changed the title Security: 3 automated fixes from AngelOne Security Scanner (3 HIGH) Security: 3 automated fixes (3 HIGH) Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant