The paradigm shift toward AI-First web development frameworks—such as Next.js with integrated AI SDKs, Vercel AI SDK, and LangChain.js—introduces novel security vulnerabilities that transcend traditional Open Web Application Security Project (OWASP) Top 10 concerns. These frameworks natively embed large language models (LLMs), vector databases, and complex artificial intelligence (AI) workflows into the web application fabric, creating unique attack surfaces, including prompt injection, training data extraction, model manipulation, and exfiltration via AI-generated content. This paper presents a comprehensive threat model for AI-First architectures, categorizing vulnerabilities into three core layers: the AI/Model Layer, the Integration/Orchestration Layer, and the Traditional Web Layer. We propose a novel static and dynamic analysis toolkit, AI-SecScanner, designed to detect framework-specific vulnerabilities by parsing AI-specific constructs and tracing data flow between user inputs and model inference endpoints. Furthermore, we introduce a Context-Aware Input Sanitization and Validation Gateway (CA-ISVG) that operates as middleware to neutralize complex prompt injection attacks by enforcing semantic and syntactic constraints on LLM-bound payloads. A quantitative evaluation of three representative AI-First applications built with Next.js AI SDK demonstrates that our methodologies reduce the success rate of adversarial prompt injection by 92.7% and identify 34% more framework-specific vulnerabilities than conventional Static Application Security Testing (SAST) and Dynamic Application Security Testing (DAST) tools. The findings underscore an urgent need for a new security ontology tailored to the AI-First ecosystem, moving beyond treating AI as a mere backend service to recognizing it as a pervasive, high-risk architectural component.
Suryavanshi et al. (Thu,) studied this question.