Most website breaches are not the work of movie-style geniuses. They exploit a small family of well-understood mistakes that have been documented for over twenty years. The same handful of flaws, injection, cross-site scripting, broken access control and a few others, appear again and again in security audits and incident reports. The encouraging side of this is that each has a reliable defence. This guide explains the main vulnerabilities in plain language and describes the practices that prevent them, so business owners can ask the right questions and developers can build securely.

SQL injection
What it is. Applications build database queries using data supplied by users, such as a search term or a login name. If the code simply pastes that text into the query string, an attacker can include database commands in their input. The database cannot tell the difference between the developer's intent and the attacker's additions, so it executes both. The result can be reading every customer record, bypassing login, modifying data or, in serious cases, taking over the database server.
How to prevent it. Use parameterised queries, also called prepared statements, everywhere. The query structure is sent separately from the values, so user input is always treated as data, never as commands. Object-relational mappers help when used correctly, but be careful with any raw query features and dynamic ordering or filtering fields. Apply least privilege: the application's database account should not be able to drop tables or read unrelated schemas. Validate input types and lengths as a secondary defence, and avoid exposing database error messages to users. Monitor for unusual queries and use web application firewall rules as an additional layer, not a substitute.

Cross-site scripting (XSS)
What it is. If a site displays user-provided content, such as a comment, profile name or search term, without proper handling, an attacker can submit a script instead. When another user views the page, the script runs in their browser with the site's privileges, stealing session information, performing actions as the victim, redirecting to fake login pages or defacing content. Stored XSS persists in your database; reflected XSS arrives in a link; DOM-based XSS occurs entirely in client-side code.
How to prevent it. Encode output according to the context in which it is placed: HTML body, attribute, JavaScript, CSS or URL each needs different escaping. Modern frameworks encode by default; the danger comes from bypassing them with functions that insert raw HTML. If you must allow rich text, sanitise it with a well-maintained library using an allow-list of tags and attributes. Add a Content Security Policy header restricting where scripts can load from and disabling inline scripts, which limits the damage even if a flaw exists. Set cookies as HttpOnly so scripts cannot read session tokens. Avoid passing untrusted data to dangerous browser functions.
Cross-site request forgery (CSRF)
What it is. A malicious site causes a logged-in user's browser to send a request to your site, such as changing an email address or transferring funds, and the browser helpfully attaches the user's cookies. The request looks legitimate.
How to prevent it. Use anti-CSRF tokens for state-changing requests, and set session cookies with the SameSite attribute so browsers do not send them on cross-site requests. Require re-authentication for sensitive actions. Do not use GET requests for actions that change data.
Broken access control
What it is. Users can access data or functions beyond their rights. The classic case is changing an ID in a URL or API request and seeing someone else's invoice. It also includes reaching admin pages by guessing the address and performing actions the interface simply does not show.
How to prevent it. Enforce authorisation on the server for every request and every object, using the authenticated user's identity, never trusting identifiers or roles sent by the client. Deny by default. Centralise authorisation logic, write tests that try to cross boundaries, and log denied attempts. We cover design in depth in our RBAC and multi-tenant article. This category consistently tops lists of real-world web application risks.
Authentication and session weaknesses
Weak password policies, missing rate limiting, predictable session tokens, sessions that never expire and poor password reset flows lead to account takeover. Protect with strong password hashing algorithms designed for the job, breached-password checks, multi-factor authentication, rate limiting and lockout on repeated failures, secure random session identifiers, session regeneration on login, sensible expiry and secure cookie flags. Make password reset tokens single-use, short-lived and unguessable, and avoid revealing whether an account exists.

Insecure file uploads and server-side request forgery
Allowing uploads without validation can let attackers store executable scripts or huge files, and features that fetch URLs on the user's behalf, such as image imports or webhooks, can be tricked into requesting internal services or cloud metadata. Validate and scan uploads, store them outside the web root or in isolated storage, and serve them safely; see our file upload guide. For server-side fetching, allow-list destinations, block internal address ranges, disable unnecessary redirects and restrict outbound network access.

Security misconfiguration and outdated components
Default passwords, verbose error pages, exposed admin consoles, open cloud storage buckets, unnecessary services, missing security headers and outdated software are extremely common causes of breaches. Harden configurations, remove what you do not need, set headers such as Content-Security-Policy, Strict-Transport-Security, X-Content-Type-Options and frame protections, and keep everything patched. Automate dependency scanning and updates so vulnerable libraries are flagged quickly, and retire unsupported software. We discuss patch management and infrastructure in our infrastructure as code article.
Sensitive data exposure
Storing or transmitting sensitive data insecurely, such as personal information in logs, unencrypted backups, secrets in source code or sensitive fields in API responses, magnifies the impact of any other flaw. Encrypt data in transit with modern TLS and at rest, minimise what you collect and store, hash passwords, keep secrets out of code, return only necessary fields from APIs and take care with logs. Privacy laws attach obligations to this data; see our privacy guide.
Build security into the process
- Threat model new features by asking what could go wrong and who might try.
- Use secure defaults and vetted libraries rather than inventing your own cryptography or authentication.
- Review code with security in mind, especially anything that handles input, authentication or money.
- Run automated scanning in your pipeline: static analysis, dependency checks and dynamic scans.
- Test authorisation explicitly with automated tests for each role and object type.
- Train developers in the common vulnerabilities and how to avoid them.
- Commission periodic penetration tests to find what automation misses. See our security audit guide.
Prepare for the day something slips through
No defence is perfect, so plan for detection and response: centralised logs, alerts on suspicious patterns, an incident response plan, tested backups and a way to patch and deploy quickly. Practise the response. Quick detection and containment are what turn a potential catastrophe into a manageable incident.
If you would like your application checked for these classic flaws, or built to avoid them from the start, our software team offers code reviews and secure development, and a maintenance plan keeps your dependencies patched and monitored.
Put this into practice with CodeLuma
CodeLuma builds with secure defaults, using parameterised queries, output encoding, strict authorisation and automated security testing, and can review your existing code for these classic vulnerabilities.
- Custom software development - tailored systems, integrations and internal tools.
- Website and web application development - fast, accessible, search-friendly builds.
- Maintenance and support plans - updates, monitoring and ongoing improvement.
Start a conversation. Tell us about your project and we will reply with practical next steps, or browse all CodeLuma services. CodeLuma Development Inc. is a Canadian company that works with teams in Windsor, Essex, London, Toronto, Mississauga and across Ontario, throughout Canada and remotely.


