惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
博客园_首页
博客园 - 【当耐特】
量子位
S
SegmentFault 最新的问题
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
T
Tailwind CSS Blog
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
Y
Y Combinator Blog
博客园 - 聂微东
The Cloudflare Blog
小众软件
小众软件
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
H
Help Net Security
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
The Security Bug Every Node.js Developer Ships to Production
Lolo · 2026-06-25 · via DEV Community

Lolo

Last year I was doing a code review for a startup. Everything looked fine on the surface, clean code, good structure, tests passing.

Then I noticed this:

const query = `SELECT * FROM users WHERE email = '${req.body.email}'`

That's it. That's the bug. SQL injection, sitting right there in a startup that had been in production for 8 months.

Nobody caught it. Not the developer, not the reviewer, not the CTO.

Here's the thing, it's not that developers are careless. It's that this kind of bug is invisible until it isn't. The code works perfectly. Tests pass. Users are happy. Until someone types ' OR '1'='1 in the email field and walks straight into your database.

The bugs I see most often

1. Raw SQL with user input

// 🚨 This is everywhere
const query = `SELECT * FROM users WHERE email = '${email}'`

// ✅ Use parameterized queries
const query = 'SELECT * FROM users WHERE email = $1'
db.query(query, [email])

2. Secrets in environment variables... committed to git

# .env
DATABASE_URL=postgres://user:actualpassword@prod-db.company.com/mydb
STRIPE_SECRET=sk_live_...

Then .env ends up in the repo because someone forgot to add it to .gitignore. I've seen this more times than I want to admit. GitHub's secret scanning catches some of these, but not always before someone has already cloned the repo.

3. JWT tokens that are never actually verified

// 🚨 Decoding is not the same as verifying
const user = jwt.decode(token)

// ✅ Always verify
const user = jwt.verify(token, process.env.JWT_SECRET)

jwt.decode just reads the token. Anyone can forge it. jwt.verify actually checks the signature. The names are confusingly similar and the wrong one silently works in development.

4. No rate limiting on auth endpoints

// 🚨 Anyone can try a million passwords
app.post('/login', async (req, res) => {
  const user = await db.findUser(req.body.email)
  // ...
})

// ✅ Add rate limiting
const authLimiter = rateLimit({
  windowMs: 15 * 60 * 1000,
  max: 10
})
app.post('/login', authLimiter, async (req, res) => {
  // ...
})

Without rate limiting, a brute force attack costs nothing. With it, 10 failed attempts and you're blocked for 15 minutes.

5. Error messages that reveal too much

// 🚨 Tells attackers exactly what's wrong
catch (error) {
  res.status(500).json({ error: error.message })
  // "relation 'users' does not exist"
  // "invalid input syntax for type uuid"
}

// ✅ Log internally, send generic message
catch (error) {
  console.error(error)
  res.status(500).json({ error: 'Something went wrong' })
}

Stack traces and database error messages are gold for anyone trying to map your system.

The one question that catches most of these

Before shipping any endpoint that touches user input, ask:

"What happens if someone sends me something I'm not expecting?"

Empty string. Null. A 10,000 character string. SQL characters. A valid email that belongs to a different user.

Most security bugs aren't sophisticated. They're just cases nobody thought about.

What's the most embarrassing security bug you've found in production, yours or someone else's?