GitHub Security Alert: Next.js App Exposed to Clickjacking, XSS Due to Missing Security Headers
A critical security gap has been identified in a Next.js application's configuration, leaving it vulnerable to clickjacking attacks and amplifying the risk of cross-site scripting (XSS). The vulnerability, flagged as a MEDIUM severity finding (SEC-010), stems from the complete absence of essential security headers in the `next.config.ts` file. The configuration currently only manages image remote patterns and server action origins, with no `headers()` function implemented to enforce basic web security controls.
The missing headers create multiple attack vectors. Without a `Content-Security-Policy`, there are no restrictions on script sources or inline scripts, allowing any XSS flaw to load external malicious code. The lack of `X-Frame-Options` means the application can be embedded in malicious iframes for clickjacking. Other absent defenses include `X-Content-Type-Options: nosniff` (preventing MIME sniffing), `Referrer-Policy` (risking information leakage), `Permissions-Policy` (no feature restrictions), and `Strict-Transport-Security` (no HSTS enforcement for HTTPS).
This configuration oversight significantly lowers the barrier for exploitation. An attacker could leverage these weaknesses to trick users into unintended actions via clickjacking or dramatically escalate the impact of any other discovered XSS vulnerability. The finding underscores a common but dangerous oversight in modern web application deployment, where framework defaults are relied upon without implementing foundational security headers that are critical for mitigating common client-side attacks.