The vulnerability lies in the /api/settings/database endpoint, which allows for unauthenticated export and import of the entire application database. The analysis of the provided security advisory and code snippets reveals four key functions involved in this vulnerability. The GET and POST functions in src/app/api/settings/database/route.js are the entry points for the attack. The GET handler calls exportDb from src/lib/db/index.js, which leaks sensitive information, including plaintext API keys, by selecting all data from the database. The POST handler calls importDb, also from src/lib/db/index.js, which allows an attacker to wipe and overwrite the entire database with arbitrary data. The root cause is the lack of proper authentication and authorization checks for these sensitive operations, relying only on a basic JWT or CLI token validation which any authenticated user possesses.