Skip to main content
Back to blogSecurity

Web Security: The 10 Most Common Threats and How to Protect Your Site

Juan Sebastián OrtizJun 10, 202611 min read

Web security is not a feature you add later. It is a foundational requirement that affects every line of code you write, every service you integrate, and every deployment you ship. In 2025, 43% of cyberattacks targeted small and medium businesses, and the average cost of a data breach for SMEs exceeded $120,000 USD.

This guide covers the 10 most common web security threats in 2026, with practical, implementable solutions for each. This is not theoretical security advice. These are the vulnerabilities we find most often in codebases we audit, and the fixes we implement for our clients.

1. SQL Injection

SQL injection remains the most dangerous web vulnerability, despite being well-understood for over two decades. It occurs when user input is concatenated directly into SQL queries, allowing an attacker to execute arbitrary database commands.

Real-world impact: An attacker can read all data from your database, modify or delete data, and in some cases execute operating system commands on the database server.

The fix: Use parameterized queries or an ORM like Prisma, Drizzle, or Sequelize. Never concatenate user input into SQL strings. If you are using raw SQL, always use parameterized queries:

```javascript // Wrong const query = `SELECT * FROM users WHERE email = '${email}'`;

// Right const query = 'SELECT * FROM users WHERE email = $1'; const result = await db.query(query, [email]); ```

Implementation: Configure your ORM to use parameterized queries by default. Add a linting rule that flags string concatenation in SQL contexts. Review all database queries during code review.

2. Cross-Site Scripting (XSS)

XSS vulnerabilities allow attackers to inject malicious scripts into pages viewed by other users. There are three types: stored XSS (malicious script saved in database), reflected XSS (malicious script in URL), and DOM-based XSS (malicious script executed in the browser).

Real-world impact: Session hijacking, credential theft, defacement, and redirecting users to malicious sites.

The fix: Sanitize all user input on the server side. Use Content Security Policy (CSP) headers to restrict which scripts can execute. React and Next.js auto-escape JSX by default, but dangerouslySetInnerHTML bypasses this protection.

```javascript // Wrong - XSS vulnerability <div dangerouslySetInnerHTML={{ __html: userContent }} />

// Right - sanitize first import DOMPurify from 'dompurify'; <div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(userContent) }} /> ```

CSP headers: Configure Content-Security-Policy to only allow scripts from your domain. This blocks injected scripts even if an XSS vulnerability exists.

3. Cross-Site Request Forgery (CSRF)

CSRF attacks trick authenticated users into performing actions they did not intend. An attacker creates a malicious page that makes requests to your application using the victim's session.

The fix: Use CSRF tokens for all state-changing operations. Configure SameSite cookies to `Strict` or `Lax`. Verify the Origin and Referer headers on sensitive endpoints.

```javascript // Set SameSite cookie Set-Cookie: session=abc123; SameSite=Strict; Secure; HttpOnly ```

4. Broken Authentication

Weak authentication is the most common entry point for attacks. This includes weak passwords, missing multi-factor authentication, session tokens that do not expire, and login endpoints without rate limiting.

The fix: - Enforce strong passwords (minimum 12 characters, no common patterns) - Implement MFA for all admin and sensitive accounts - Use short-lived JWTs (15 minutes) with refresh tokens - Rate limit login attempts (5 attempts per 15 minutes per IP) - Lock accounts after 10 failed attempts - Use bcrypt or Argon2 for password hashing (never MD5 or SHA1)

5. Vulnerable Dependencies

The average JavaScript project has 150+ direct dependencies and 1,000+ transitive dependencies. Each one is a potential attack vector. In 2025, there were over 28,000 reported vulnerabilities in npm packages.

The fix: - Run `npm audit` or `pnpm audit` weekly - Enable Dependabot or Renovate for automated dependency updates - Use lockfiles (package-lock.json, pnpm-lock.yaml) and never modify them manually - Review dependencies before adding them. Check download counts, maintenance activity, and known vulnerabilities - Remove unused dependencies regularly

6. Insecure Configuration

Hardcoded secrets, exposed environment variables, and misconfigured servers are responsible for a significant percentage of breaches. The most common mistakes:

  • API keys committed to Git repositories
  • Database credentials in source code
  • Debug mode enabled in production
  • Default admin credentials unchanged
  • CORS configured too permissively

The fix: - Use environment variables for all secrets - Add .env to .gitignore and verify it before every commit - Use a secrets manager (Vercel Environment Variables, AWS Secrets Manager) - Never log sensitive data - Review CORS configuration: only allow your actual domains - Disable debug mode in production builds

7. Denial of Service (DDoS)

DDoS attacks flood your server with traffic, making your application unavailable. While large-scale DDoS attacks target big companies, small applications are vulnerable to application-layer attacks that exhaust server resources.

The fix: - Use a CDN with DDoS protection (Cloudflare, Vercel Edge) - Implement rate limiting on all public endpoints - Set request body size limits - Use queue-based processing for expensive operations - Configure auto-scaling if using cloud infrastructure

8. Session Hijacking

Session hijacking occurs when an attacker steals a user's session token and impersonates them. Methods include XSS attacks, network sniffing, and session fixation.

The fix: - Use short-lived access tokens (15 minutes) with secure refresh tokens - Store tokens in httpOnly, Secure, SameSite=Strict cookies - Regenerate session tokens after login and privilege changes - Implement session invalidation on logout - Monitor for concurrent sessions from different locations

9. Insecure File Uploads

File upload vulnerabilities allow attackers to upload malicious files that can be executed on your server, consuming resources, or serving as a vector for further attacks.

The fix: - Validate file type on both client and server side (MIME type + extension + magic bytes) - Rename uploaded files to prevent path traversal - Store uploads outside the web root - Set file size limits - Scan uploaded files for malware - Use a dedicated file storage service (S3, Cloudflare R2) instead of local filesystem

10. Supply Chain Attacks

Supply chain attacks target your development tools, dependencies, or deployment pipeline rather than your application directly. The SolarWinds and Log4j incidents demonstrated the devastating potential of these attacks.

The fix: - Use lockfiles and verify their integrity - Pin dependency versions (do not use `*` or `latest`) - Review dependency updates before merging - Use a private registry for internal packages - Monitor for typosquatting (packages with names similar to popular packages) - Implement CI/CD security scanning

Security checklist for new projects

Before launching any web application, verify:

  • [ ] All database queries use parameterized queries or ORM
  • [ ] CSP headers are configured and enforced
  • [ ] CSRF tokens protect all state-changing operations
  • [ ] MFA is available for admin accounts
  • [ ] Rate limiting is configured on auth endpoints
  • [ ] Dependencies are audited and up to date
  • [ ] No secrets in source code or Git history
  • [ ] File uploads are validated and stored securely
  • [ ] Error messages do not leak sensitive information
  • [ ] Logging captures security events without exposing secrets

Conclusion

Security is not a feature you add at the end of a project. It is a practice you implement from the first line of code. The threats in this guide are not theoretical. They are actively exploited every day against businesses of all sizes.

The most effective security strategy is defense in depth: multiple layers of protection so that if one fails, others catch the attack. Start with the basics, automate what you can, and review regularly.

Need a security audit? Contact RHYNODE.

Written by

Juan Sebastián Ortiz

CTO of RHYNODE

CTO of RHYNODE. Technical architect behind every line of code: clean systems, AI integrations, and automations that run themselves.

LinkedIn