Skip to content

Security Auditing & Hardening

Gasoline turns your AI assistant into a security auditor. Six check categories scan live browser traffic for vulnerabilities, two generators produce security artifacts, and recording comparison catches regressions before they ship.

Run all checks at once:

analyze({what: "security_audit"})

Or target specific categories:

analyze({what: "security_audit", checks: ["credentials", "pii"]})
analyze({what: "security_audit", checks: ["headers", "cookies", "transport"]})
analyze({what: "security_audit", checks: ["auth"]})

Filter by minimum severity to focus on critical issues:

analyze({what: "security_audit", severity_min: "high"})

Severity levels: critical > high > medium > low > info


Scans network requests, responses, console output, and URL parameters for:

PatternExampleDetection Method
AWS Access KeysAKIA1234567890ABCDEFRegex + prefix validation
GitHub PATsghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxRegex + length check
Stripe Keyssk_live_xxxx...xxxxRegex + prefix validation
JWT TokenseyJhbGciOi...Structure validation (3-part base64)
Bearer TokensBearer eyJ...Regex + minimum length
Private Keys-----BEGIN RSA PRIVATE KEY-----Header detection
API Keys in URLs?api_key=abc123...Query parameter scanning

Common findings:

  • API responses that include server-side tokens the frontend doesn’t need
  • Debug endpoints that expose configuration with secrets
  • Console.log statements that dump auth state
  • JWTs in URL query parameters (visible in browser history and server logs)
Data TypeDetectionValidation
Social Security NumbersXXX-XX-XXXX patternFormat check
Credit Card Numbers13-19 digit sequencesLuhn algorithm (eliminates false positives)
Email AddressesStandard email regexDomain validation
Phone NumbersUS format patterns10+ digit validation

The Luhn validation is important — it means a random 16-digit number in a timestamp or ID won’t trigger a false positive. Only numbers that pass the credit card checksum are flagged.

Why this matters: If your /api/users endpoint returns full SSNs when the UI only displays the last four digits, that’s a data minimization violation (GDPR Article 5, CCPA).

Checks every HTTP response for six critical security headers:

HeaderPurposeMissing =
Strict-Transport-SecurityForces HTTPS, prevents downgrade attacksBrowsers may connect via HTTP
X-Content-Type-Options: nosniffPrevents MIME-type sniffingScripts disguised as images can execute
X-Frame-OptionsBlocks clickjacking via iframesYour pages can be embedded in attacker sites
Content-Security-PolicyWhitelist for script/style sourcesXSS attacks can inject arbitrary scripts
Referrer-PolicyControls referrer header leakageFull URLs (with tokens) sent to third parties
Permissions-PolicyRestricts browser API accessThird-party scripts can access camera, location

Findings are per-origin — if your API server has headers but your CDN doesn’t, both are reported separately.

For every cookie, especially session cookies (session, token, auth, jwt, sid patterns):

FlagWhat It PreventsSeverity If Missing
HttpOnlyJavaScript access (XSS can steal cookies)Warning (high for session cookies)
SecureTransmission over HTTP (interception)Warning on HTTPS sites
SameSiteCross-site request forgery (CSRF)Warning

A session cookie missing all three flags gets escalated severity.

FindingSeverityDescription
HTTP usageHighUnencrypted traffic (non-localhost)
Mixed contentMediumHTTPS page loading HTTP resource
HTTPS downgradeCriticalResource previously loaded via HTTPS now via HTTP

Localhost is excluded — http://localhost:3000 is fine for development.

Identifies API endpoints that:

  1. Return response bodies containing PII patterns
  2. Were called without an Authorization header

This catches the classic “forgot to add the auth middleware” bug on new endpoints.


Separate from security_audit, the third-party audit analyzes all external origins your page communicates with:

analyze({what: "third_party_audit"})

Every third-party origin gets a risk rating:

Risk LevelCriteriaExamples
CriticalScripts from suspicious domains, data exfiltration patternsUnknown domain executing JS + receiving POST data
HighScripts from unknown origins, high-entropy domain names (DGA)xk4m2.example.xyz serving JavaScript
MediumSuspicious TLDs, non-essential servicesAnalytics from .click domains
LowKnown CDNs, passive resources (fonts, images)Google Fonts, jsDelivr, Cloudflare CDN
RiskTLDs
High (phishing/malware).loan, .download
Medium (abuse-prone).xyz, .top, .click, .stream, .review, .country

Domain Generation Algorithm (DGA) Detection

Section titled “Domain Generation Algorithm (DGA) Detection”

High-entropy hostnames (>3.5 bits per character) are flagged as potential malware C&C communication. Legitimate domains like cdn.jsdelivr.net have low entropy. Domains like xk4m2q8f.example.com have high entropy.

Specify what’s first-party and what’s allowed or blocked:

analyze({what: "third_party_audit",
first_party_origins: ["https://api.myapp.com", "https://cdn.myapp.com"],
include_static: true,
custom_lists: {
allowed: ["https://trusted-vendor.com"],
blocked: ["https://known-bad-tracker.com"],
internal: ["https://internal-tools.mycompany.com"]
}})
  • Domain and origin URL
  • Resource types loaded (scripts, styles, fonts, images, XHR)
  • Whether scripts are loaded (highest risk)
  • Whether data is sent via POST/PUT (outbound data flow)
  • Whether PII fields appear in requests
  • Whether cookies are set
  • Transfer size (total bytes)
  • Domain reputation classification
  • Risk level with explanation

Use recordings to capture before/after security state and compare error logs:

configure({action: "recording_start"})
// Browse the application to capture security-relevant traffic
configure({action: "recording_stop", recording_id: "rec-baseline"})
configure({action: "recording_start"})
// Browse the same flows after the refactor/deploy
configure({action: "recording_stop", recording_id: "rec-after"})
configure({action: "log_diff", original_id: "rec-baseline", replay_id: "rec-after"})

The comparison reports new errors, resolved errors, and changes between the two sessions. Run analyze({what: "security_audit"}) on each recording to compare security posture directly.


Generate a CSP header from observed traffic:

generate({format: "csp"})
generate({format: "csp", mode: "strict"})
generate({format: "csp", mode: "report_only"})
ModeBehavior
strictOnly high-confidence origins (3+ observations, 2+ pages)
moderateBalanced — includes medium-confidence origins
report_onlyGenerates Content-Security-Policy-Report-Only (no enforcement)

Smart filtering:

  • Browser extension origins auto-excluded (chrome-extension://, moz-extension://)
  • Dev server origins filtered (different-port localhost)
  • Low-confidence origins excluded (single observation = possible ad injection)
  • Your app’s own localhost preserved

Output includes:

  • Ready-to-use CSP header string
  • HTML <meta> tag equivalent
  • Per-origin confidence details
  • Filtered origins with explanations
  • Coverage warnings (e.g., “visit more pages for broader coverage”)

Generate SRI hashes for all third-party scripts and stylesheets:

generate({format: "sri"})
generate({format: "sri", resource_types: ["script"], origins: ["https://cdn.example.com"]})

Output per resource:

  • SHA-384 hash in browser-standard format
  • Ready-to-paste <script> or <link> tag with integrity and crossorigin attributes
  • File size
  • Whether the resource already has SRI protection

Here’s how to use these tools together for a thorough security review:

"Run a full security audit of this page — all check categories."
analyze({what: "security_audit"})
"Show me all third-party scripts and classify their risk."
analyze({what: "third_party_audit"})

Address findings by severity: critical first, then high, medium, low.

"Generate a strict CSP from what you've observed, and SRI hashes for all external scripts."
generate({format: "csp", mode: "strict"})
generate({format: "sri"})
"Start a recording to capture our secured state."
configure({action: "recording_start"})
// Browse the application
configure({action: "recording_stop", recording_id: "rec-secured"})
"Record a new session and compare it to the secured baseline."
configure({action: "recording_start"})
// Browse the same flows
configure({action: "recording_stop", recording_id: "rec-post-change"})
configure({action: "log_diff", original_id: "rec-secured", replay_id: "rec-post-change"})

Independent of auditing, Gasoline automatically protects against accidental data exposure:

Extension layer (before data leaves the browser):

  • Strips Authorization, Cookie, Set-Cookie headers
  • Strips any header containing token, secret, key, or password
  • Replaces password input values with [redacted]

Server layer (before data reaches the AI):

  • Regex-based redaction of AWS keys, JWTs, credit cards, SSNs
  • Luhn validation to avoid false positives on numbers
  • Format: [REDACTED:pattern-name]

Two layers, always active, zero configuration.


Export accessibility and security findings in SARIF format for GitHub Code Scanning:

generate({format: "sarif", save_to: "/path/to/report.sarif"})

SARIF files integrate with:

  • GitHub Code Scanning (upload via github/codeql-action/upload-sarif)
  • VS Code SARIF Viewer extension
  • Azure DevOps
  • Any SARIF-compatible CI/CD pipeline