Prompt EngineeringFREEClaudeCursorAntigravityJul 27, 2026

Detailed Security Audit + Hardening (Web Project)

Comprehensive security hardening and SEO audit system instructions covering auth bypass, SQL injection prevention, rate limiting, and security headers.

Primary Use Case & Objectives

Complete security audit aur fix — auth bypass, SQL injection, rate limiting, HttpOnly cookies, security headers, aur SEO metadata sab cover karta hai.

Rendered Blueprint Specification

Perform a comprehensive security hardening and SEO improvement pass
on this codebase. Work through the sections below IN ORDER. After
EACH numbered section, run npm run build and npm run lint before
moving to the next section — if either fails, STOP and fix it before
continuing. If any change in a later section would conflict with or
require modifying logic from an earlier section, STOP and explain
the conflict before proceeding.

=== SECTION 1: READ-ONLY AUDIT FIRST ===
Before changing anything, scan and report (with file/line references):
- Hardcoded secrets/passwords/fallback keys (JWT, admin password,
any revalidation/webhook secrets)
- Any auth bypass tied to NODE_ENV === 'development' (backend AND
frontend)
- Any public API endpoint (uploads, forms, admin-adjacent routes)
missing authentication
- Any middleware/proxy reading cookies/tokens without verifying
cryptographic signature
- Any raw/dynamic SQL query built from unsanitized user input
- Any OTP/token/secret written to plaintext local files
- Current rate limiting status on login and OTP endpoints (or
confirm "none")
- Outdated dependencies with known CVEs (npm audit)
- Current CSP/security headers status
- Whether session tokens are HttpOnly or JS-readable
- CORS configuration on sensitive endpoints
Show me this report before proceeding to Section 2.

=== SECTION 2: FIX CRITICAL/HIGH VULNERABILITIES ===
Based on Section 1 findings, fix:
- Require authentication on any unauthenticated sensitive endpoint
- Remove ALL development-mode auth bypasses (backend + frontend),
completely — no conditional shortcuts
- Fix any middleware that skips signature verification — use proper
JWT verify
- Fix SQL injection by whitelisting/parameterizing any dynamic query
inputs
- Remove plaintext file writes of OTPs/secrets; delete any existing
plaintext files
- Make JWT_SECRET, ADMIN_PASSWORD, and any other sensitive env vars
REQUIRED in production — throw a clear error if missing, no silent
guessable fallback

=== SECTION 3: LOGIN BRUTE-FORCE PROTECTION ===
- Create a failed_login_attempts table (ip_address, timestamp,
result), auto-cleaning entries older than 15 minutes
- 0-2 failed attempts: normal login
- 3-4 failed attempts: require Cloudflare Turnstile captcha before
checking password (use TURNSTILE_SECRET_KEY env var — tell me if
this isn't set yet so I can create it at dash.cloudflare.com first)
- 5+ failed attempts: full 15-minute lockout for that IP regardless
of correct credentials/captcha
- Apply the same attempt-limit pattern to OTP verification if OTP
login exists
- On lockout, send a security alert email via the existing email
service, with a 30-minute cooldown so repeated lockouts don't spam
the inbox
- Wrap all new logic in try/catch so failures never break the
existing login flow

=== SECTION 4: SECURITY LOG DASHBOARD ===
Create an admin-only page showing login attempt history: timestamp,
IP, device/browser (user-agent), stage (password/OTP), result. Add
filtering by result and search by IP. Auto-delete entries older than
30 days. Must sit behind existing admin authentication, in the
existing admin navigation.

=== SECTION 5: SECURITY HEADERS + CORS ===
Add CSP, X-Frame-Options: SAMEORIGIN, X-Content-Type-Options: nosniff,
Strict-Transport-Security, Referrer-Policy in next.config.ts. Before
finalizing the CSP whitelist, scan the codebase for every external
script/embed ACTUALLY used (analytics, payment gateways, Turnstile,
storage/CDN, fonts) and whitelist only those — do not include unused
services, and do not break any existing functionality.

=== SECTION 6: HTTPONLY COOKIES (HIGHEST RISK — BE CAREFUL) ===
Migrate the session/auth token from client-readable storage
(sessionStorage / non-HttpOnly cookies) to HttpOnly + Secure +
SameSite=Lax cookies set server-side on login. Update session-check
and logout logic to match. Any other API route currently expecting
an Authorization header must continue working unchanged — inject the
header from the cookie in middleware rather than rewriting those
routes. Do not remove or weaken any existing authorization check
while doing this.

=== SECTION 7: SEO — PER-PAGE METADATA ===
- Remove any hardcoded canonical: '/' in the root layout that forces
every page to canonicalize to the homepage
- Give every static page (about, privacy, terms, contact, etc.) and
every dynamic content page (blog/article) its own unique title,
meta description, and self-referencing canonical URL
- For blog/article posts: confirm SEO title/description/keyword
fields exist in the ACTUALLY-USED editor UI (not a disconnected/
orphaned component) — if they only exist in unused code, add them
to the real editor
- Make these SEO fields auto-populate from the post's title and
summary/excerpt in real time, but stop auto-syncing a field the
moment the user manually edits it (so their manual changes are
never overwritten)

=== SECTION 8: BLOG EDITOR — TABLE PASTE SUPPORT ===
If the blog editor uses a custom plain-text-to-HTML parser, check
whether it detects markdown tables. It likely only detects lines
strictly starting/ending with "|". Add detection for tab-separated
table content too (common when pasting rendered tables copied from
AI chat interfaces like Claude/ChatGPT, which use tabs, not pipes,
between cells). This must be purely additive — do not change any
existing logic for headings (#), lists (-, , 1.), bold (),
italic (
), links ([]()), or existing pipe-table parsing. Place the
new check after those, so it never misfires on non-table content.

=== FINAL STEP ===
After all sections, give me:
1. A full list of every file changed, grouped by section
2. Confirmation that npm run build and npm run lint both pass
3. A manual test checklist covering: login (normal), login (3+ fails
→ captcha), login (5+ fails → lockout + email), logout, session
persistence, security log page, homepage/page-source header check,
a static page's title/canonical in page source, blog post SEO
auto-fill, and pasting a table into the blog editor.

Direct AI System Instructions120 lines • 6133 chars
1Perform a comprehensive security hardening and SEO improvement pass
2on this codebase. Work through the sections below IN ORDER. After
3EACH numbered section, run npm run build and npm run lint before
4moving to the next section — if either fails, STOP and fix it before
5continuing. If any change in a later section would conflict with or
6require modifying logic from an earlier section, STOP and explain
7the conflict before proceeding.
8
9=== SECTION 1: READ-ONLY AUDIT FIRST ===
10Before changing anything, scan and report (with file/line references):
11- Hardcoded secrets/passwords/fallback keys (JWT, admin password,
12 any revalidation/webhook secrets)
13- Any auth bypass tied to NODE_ENV === 'development' (backend AND
14 frontend)
15- Any public API endpoint (uploads, forms, admin-adjacent routes)
16 missing authentication
17- Any middleware/proxy reading cookies/tokens without verifying
18 cryptographic signature
19- Any raw/dynamic SQL query built from unsanitized user input
20- Any OTP/token/secret written to plaintext local files
21- Current rate limiting status on login and OTP endpoints (or
22 confirm "none")
23- Outdated dependencies with known CVEs (npm audit)
24- Current CSP/security headers status
25- Whether session tokens are HttpOnly or JS-readable
26- CORS configuration on sensitive endpoints
27Show me this report before proceeding to Section 2.
28
29=== SECTION 2: FIX CRITICAL/HIGH VULNERABILITIES ===
30Based on Section 1 findings, fix:
31- Require authentication on any unauthenticated sensitive endpoint
32- Remove ALL development-mode auth bypasses (backend + frontend),
33 completely — no conditional shortcuts
34- Fix any middleware that skips signature verification — use proper
35 JWT verify
36- Fix SQL injection by whitelisting/parameterizing any dynamic query
37 inputs
38- Remove plaintext file writes of OTPs/secrets; delete any existing
39 plaintext files
40- Make JWT_SECRET, ADMIN_PASSWORD, and any other sensitive env vars
41 REQUIRED in production — throw a clear error if missing, no silent
42 guessable fallback
43
44=== SECTION 3: LOGIN BRUTE-FORCE PROTECTION ===
45- Create a failed_login_attempts table (ip_address, timestamp,
46 result), auto-cleaning entries older than 15 minutes
47- 0-2 failed attempts: normal login
48- 3-4 failed attempts: require Cloudflare Turnstile captcha before
49 checking password (use TURNSTILE_SECRET_KEY env var — tell me if
50 this isn't set yet so I can create it at dash.cloudflare.com first)
51- 5+ failed attempts: full 15-minute lockout for that IP regardless
52 of correct credentials/captcha
53- Apply the same attempt-limit pattern to OTP verification if OTP
54 login exists
55- On lockout, send a security alert email via the existing email
56 service, with a 30-minute cooldown so repeated lockouts don't spam
57 the inbox
58- Wrap all new logic in try/catch so failures never break the
59 existing login flow
60
61=== SECTION 4: SECURITY LOG DASHBOARD ===
62Create an admin-only page showing login attempt history: timestamp,
63IP, device/browser (user-agent), stage (password/OTP), result. Add
64filtering by result and search by IP. Auto-delete entries older than
6530 days. Must sit behind existing admin authentication, in the
66existing admin navigation.
67
68=== SECTION 5: SECURITY HEADERS + CORS ===
69Add CSP, X-Frame-Options: SAMEORIGIN, X-Content-Type-Options: nosniff,
70Strict-Transport-Security, Referrer-Policy in next.config.ts. Before
71finalizing the CSP whitelist, scan the codebase for every external
72script/embed ACTUALLY used (analytics, payment gateways, Turnstile,
73storage/CDN, fonts) and whitelist only those — do not include unused
74services, and do not break any existing functionality.
75
76=== SECTION 6: HTTPONLY COOKIES (HIGHEST RISK — BE CAREFUL) ===
77Migrate the session/auth token from client-readable storage
78(sessionStorage / non-HttpOnly cookies) to HttpOnly + Secure +
79SameSite=Lax cookies set server-side on login. Update session-check
80and logout logic to match. Any other API route currently expecting
81an Authorization header must continue working unchanged — inject the
82header from the cookie in middleware rather than rewriting those
83routes. Do not remove or weaken any existing authorization check
84while doing this.
85
86=== SECTION 7: SEO — PER-PAGE METADATA ===
87- Remove any hardcoded canonical: '/' in the root layout that forces
88 every page to canonicalize to the homepage
89- Give every static page (about, privacy, terms, contact, etc.) and
90 every dynamic content page (blog/article) its own unique title,
91 meta description, and self-referencing canonical URL
92- For blog/article posts: confirm SEO title/description/keyword
93 fields exist in the ACTUALLY-USED editor UI (not a disconnected/
94 orphaned component) — if they only exist in unused code, add them
95 to the real editor
96- Make these SEO fields auto-populate from the post's title and
97 summary/excerpt in real time, but stop auto-syncing a field the
98 moment the user manually edits it (so their manual changes are
99 never overwritten)
100
101=== SECTION 8: BLOG EDITOR — TABLE PASTE SUPPORT ===
102If the blog editor uses a custom plain-text-to-HTML parser, check
103whether it detects markdown tables. It likely only detects lines
104strictly starting/ending with "|". Add detection for tab-separated
105table content too (common when pasting rendered tables copied from
106AI chat interfaces like Claude/ChatGPT, which use tabs, not pipes,
107between cells). This must be purely additive — do not change any
108existing logic for headings (#), lists (-, *, 1.), bold (**),
109italic (*), links ([]()), or existing pipe-table parsing. Place the
110new check after those, so it never misfires on non-table content.
111
112=== FINAL STEP ===
113After all sections, give me:
1141. A full list of every file changed, grouped by section
1152. Confirmation that npm run build and npm run lint both pass
1163. A manual test checklist covering: login (normal), login (3+ fails
117 → captcha), login (5+ fails → lockout + email), logout, session
118 persistence, security log page, homepage/page-source header check,
119 a static page's title/canonical in page source, blog post SEO
120 auto-fill, and pasting a table into the blog editor.
Companion AI Blueprints

More Prompt Engineering Prompts

View All Prompts Library
Prompt EngineeringFREEClaudeChatGPTGemini

GET PERFECT BLOG FORMAT

Senior editor system prompt to transform raw technical notes into professional, high-clarity publication articles with structured formatting.

Best Used For

BLOG FORMAT ONE2TECH STYLE

Subscribe to One2Tech

Get direct notifications on new macOS automation workflows.