Landing a Senior Security Engineering role requires mastering the architectural patterns that prevent breaches. Here is the engineering blueprint for high-stakes JavaScript security.
As an Engineering Manager, I've interviewed 50+ full-stack and backend candidates. Security questions are part of almost every technical interview—even for roles that aren't explicitly "security." Here are the 15 concepts that separate the prepared from the panicked.
// ❌ Vulnerable
db.query(`SELECT * FROM users WHERE id = ${userId}`);
// ✅ Safe
db.query("SELECT * FROM users WHERE id = $1", [userId]);
Key phrase: "Parameterized queries separate data from code."
- Stored XSS: Malicious script saved to database
- Reflected XSS: Script in URL reflected back
- DOM XSS: Script manipulates DOM directly
// ❌ DOM XSS
element.innerHTML = userInput;
// ✅ Safe
element.textContent = userInput;
// ❌ Never
const hash = crypto.createHash("md5").update(password);
// ✅ Always
const hash = await bcrypt.hash(password, 12);
Key phrases: "bcrypt", "argon2", "salt", "work factor"
Cross-Site Request Forgery: Attacker tricks authenticated user into performing actions.
Prevention: Synchronizer tokens, SameSite cookies, origin validation.
Browsers block requests to different origins (scheme + host + port).
Bypass mechanisms: CORS headers, JSONP (deprecated), postMessage.
// ❌ Vulnerable (leaks information via timing)
if (userToken === secretToken) {
}
// ✅ Safe (constant-time comparison)
crypto.timingSafeEqual(Buffer.from(userToken), Buffer.from(secretToken));
- Always verify signature
- Check expiration (
exp) - Don't use
algorithm: 'none' - Store in httpOnly cookies, not localStorage
// ❌ Vulnerable
obj[key] = value; // If key = "__proto__", pollutes Object.prototype
// ✅ Safe
if (key !== "__proto__" && key !== "constructor") {
obj[key] = value;
}
HTTP header that restricts what resources can load:
Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-abc123'
Regular Expression Denial of Service:
// ❌ Evil regex (catastrophic backtracking)
const regex = /^(a+)+$/;
regex.test("aaaaaaaaaaaaaaaaaaaaaaaaaaaa!"); // Hangs
- Password hashing (bcrypt/argon2)- Rate limiting on login- Account lockout after failures
- MFA option
- Secure session management
- Password reset via email (time-limited tokens)
- Environment variables (minimum)
- Secrets managers (AWS Secrets Manager, Vault)
- No secrets in code or git history
- Rotation policies
- Authentication (JWT, OAuth2)
- Authorization (RBAC, ABAC)
- Input validation
- Rate limiting
- HTTPS only
- CORS configuration
Good answers:
- "I follow OWASP updates"
- "I use automated security linting"
- "I read CVE disclosures"
- "I contribute to security tools"
Great answer: "I enforce security automatically. My ESLint config includes security rules that catch 80% of common vulnerabilities before code review."
| Vulnerability | Prevention | CWE |
|---|---|---|
| SQL Injection | Parameterized queries | CWE-89 |
| XSS | Output encoding | CWE-79 |
| CSRF | Tokens + SameSite | CWE-352 |
| Broken Auth | MFA + secure sessions | CWE-287 |
| Sensitive Data | Encryption | CWE-311 |
| Injection | Input validation | CWE-20 |
Each vulnerability category has a dedicated ESLint plugin:
| Category | Plugin | Rules |
|---|---|---|
| SQL Injection | eslint-plugin-pg | 15 |
| XSS/Browser | eslint-plugin-browser-security | 52 |
| Crypto/Timing | eslint-plugin-node-security | 31 |
| JWT Security | eslint-plugin-jwt | 13 |
| Auth/Secrets | eslint-plugin-secure-coding | 26 |
# Install the full security suite
npm install --save-dev eslint-plugin-secure-coding
npm install --save-dev eslint-plugin-node-security
npm install --save-dev eslint-plugin-jwt
npm install --save-dev eslint-plugin-pg
npm install --save-dev eslint-plugin-browser-security
⭐ Star the Interlace ESLint Ecosystem
The Interlace ESLint Ecosystem Interlace is a high-fidelity suite of static code analyzers designed to automate security, performance, and reliability for the modern Node.js stack. With over 330 rules across 18 specialized plugins, it provides 100% coverage for OWASP Top 10, LLM Security, and Database Hardening.
Explore the full Documentation
© 2026 Ofri Peretz. All rights reserved.
Build Securely. I'm Ofri Peretz, a Security Engineering Leader and the architect of the Interlace Ecosystem. I build static analysis standards that automate security and performance for Node.js fleets at scale.
