Skip to main content

Security & Validation Auditing

One call returns a structured client-side security report — no manual DOM crawling or header parsing. auditSecurity() rolls up forms, headers, XSS-risk patterns, external resources, framework quality, and prototype-pollution checks into a single graded result.

auditSecurity

Run the comprehensive security audit. Returns structured findings across every client-visible security surface.

window.__devtool.auditSecurity()

What it covers:

AreaFindings
Security headersCSP, frame protection, HTTPS, mixed content, referrer policy
DOM securityinline scripts, inline event handlers, javascript: URLs, dangerous attributes
Form securityCSRF tokens, insecure form actions, autocomplete on sensitive fields
Framework qualitydev builds in production, vulnerable library versions, v-html/ng-bind-html usage
External resourcesmissing Subresource Integrity (SRI), unsandboxed iframes
Prototype pollutionbest-practice checks for prototype hardening

Returns:

{
headers: {
csp: {
present: true,
value: "default-src 'self'; script-src 'self' 'unsafe-inline'",
source: "meta-tag"
},
frameProtection: { present: true },
https: { present: true, protocol: "https:" },
mixedContent: {
present: false,
count: 0,
details: { scripts: [], stylesheets: [], images: [], iframes: [] }
},
referrerPolicy: { present: true, value: "strict-origin-when-cross-origin" }
},
domSecurity: {
dangerousElements: {
inlineScripts: [
{ selector: "script:nth-of-type(3)", length: 1250, preview: "var config = {...}" }
],
inlineEventHandlers: [
{ selector: "button.submit", attribute: "onclick", value: "submitForm()" }
],
javascriptURLs: [
{ selector: "a.legacy-link", attribute: "href", value: "javascript:void(0)" }
],
dangerousAttributes: [
{ selector: "div.content", attribute: "srcdoc", length: 500 }
]
},
summary: { inlineScripts: 5, inlineEventHandlers: 12, javascriptURLs: 2, dangerousAttributes: 1, total: 20 }
},
framework: {
primary: "React",
frameworks: [
{ name: "React", detected: true, version: "18.2.0", devToolsInstalled: true }
],
issues: [
{
type: "react-dev-build",
severity: "error",
message: "React development build detected in production",
fix: "Use production build for better performance and security"
}
]
},
forms: {
forms: [
{
selector: "form#login",
action: "https://example.com/auth",
method: "post",
hasValidation: true,
hasCSRF: true,
fields: [
{ type: "email", name: "email", hasValidation: true },
{ type: "password", name: "password", hasValidation: true, isPassword: true }
]
}
],
summary: { total: 3, withValidation: 2, withCSRF: 2, passwordFields: 1, sensitiveFields: 1 }
},
resources: {
summary: { totalScripts: 8, externalScripts: 3, withIntegrity: 2, iframes: 2, sandboxedIframes: 1 }
},
prototype: {
vulnerable: false,
recommendations: [
"Use Object.create(null) for dictionary objects",
"Validate and sanitize all user input before using as object keys"
]
},
summary: {
frameworkDetected: "React",
totalIssues: 12,
criticalIssues: 2,
httpsEnabled: true,
cspEnabled: true
},
issues: [ /* all issues from all areas */ ],
criticalIssues: [ /* only error severity issues */ ],
overallScore: 75,
grade: "C", // A (90+), B (80-89), C (70-79), D (60-69), F (<60)
timestamp: 1699999999999
}

Score Weights:

AreaWeight
Security Headers25%
DOM Security25%
Form Security20%
Framework Quality15%
External Resources15%

Issues Detected (across all areas):

TypeSeverityDescription
missing-cspwarningNo Content-Security-Policy meta tag
missing-frame-protectioninfoNo frame-ancestors in CSP
no-httpserrorPage served over HTTP (non-localhost)
mixed-content-activeerrorScripts/stylesheets loaded over HTTP
mixed-content-passivewarningImages/iframes loaded over HTTP
inline-scriptswarningInline <script> tags (XSS vectors)
inline-event-handlerswarningonclick, onload, etc. attributes
javascript-urlserrorjavascript: URLs in href/src/action
dangerous-attributesinfosrcdoc, data-html attributes
missing-csrfwarningPOST form without CSRF token
insecure-form-actionerrorForm submits to HTTP URL
sensitive-autocompletewarningSensitive field without autocomplete=off
react-dev-builderrorReact development build in production
vue-v-htmlwarningUsing v-html (potential XSS)
jquery-vulnerablewarningjQuery < 3.5.0 vulnerabilities
missing-sriwarningExternal script without integrity hash
unsandboxed-iframewarningExternal iframe without sandbox
prototype-not-frozeninfoObject.prototype is not frozen

Common Patterns

Pre-Deploy Security Check

function securityCheck() {
const audit = window.__devtool.auditSecurity()

const blockers = []

// Critical issues block deployment
if (audit.criticalIssues.length > 0) {
blockers.push(`${audit.criticalIssues.length} critical security issues`)
}

// No HTTPS in production
if (!audit.headers.https.present) {
blockers.push('HTTPS not enabled')
}

// Dev build in production
if (audit.framework.issues.some(i => i.type === 'react-dev-build')) {
blockers.push('React development build detected')
}

return {
pass: blockers.length === 0,
grade: audit.grade,
score: audit.overallScore,
blockers: blockers
}
}

Triage by Severity

const audit = window.__devtool.auditSecurity()

console.log(`Security grade: ${audit.grade} (${audit.overallScore}/100)`)
console.log(`Primary framework: ${audit.summary.frameworkDetected}`)

// Critical issues first
audit.criticalIssues.forEach(i => {
console.error(`[${i.severity}] ${i.type}: ${i.message}`)
if (i.fix) console.log(` Fix: ${i.fix}`)
})

Performance Notes

  • auditSecurity runs all checks in one pass; the DOM-security and external-resource scans walk every element/script/iframe, so it may be slow on large DOMs.
  • Run it after page load completes for stable results.

Security Considerations

  • This audit detects client-side patterns only.
  • Server-side headers (HSTS, X-Frame-Options) aren't visible to client JS.
  • Some issues can only be detected through HTTP response headers — use the browser DevTools Network tab for complete header inspection.
  • Consider server-side security scanning for comprehensive coverage.

See Also