Skip to main content
CodingMarble

Web development

Website Security Basics for Small Businesses

Most small business sites are compromised through outdated plugins, weak or reused passwords and missing basic server settings, not through clever attacks. Cover HTTPS, updates, authentication, security headers, form handling and tested backups, and you remove the common routes in.

By CodingMarble · Published · 5 min read

A monitor showing a design system interface beside desk plants
Photo: Balázs Kétyi on Unsplash

What you are actually defending against

Small sites are rarely targeted by name. They are found by automated scanners that probe thousands of addresses looking for a known vulnerable plugin, an exposed admin login or a guessable password. That changes the priorities: you do not need an elaborate defence, you need to not be the easy one. The usual outcomes are defaced pages, spam links injected into your content, a hijacked contact form that sends mail on your behalf, or malware that redirects visitors.

This guide covers the controls that remove the most common routes in. It does not replace a professional review if you handle payments, health records or other regulated data, where you may have legal obligations beyond what is described here.

HTTPS everywhere, then HSTS

HTTPS encrypts traffic between the visitor and your server and proves the visitor reached the right site. Most hosts issue certificates automatically through Let's Encrypt or similar services; check that yours renews on its own, since an expired certificate shows visitors a full-page warning. Redirect every HTTP request to HTTPS with a permanent redirect, and make sure internal links, images and scripts use HTTPS too, because a single insecure script triggers mixed-content blocking.

HSTS goes one step further. The Strict-Transport-Security response header tells browsers to use HTTPS only for your domain for a stated period, so even a typed http address is upgraded before any request leaves the machine. Introduce it carefully. Start with a short max-age, confirm every subdomain works over HTTPS, then raise it. Be wary of the includeSubDomains and preload options until you are certain, since preloading is difficult to reverse.

To verify, open your site in a private window, request the http version and confirm it lands on https. Then look at the response headers in the DevTools Network panel for strict-transport-security, and test the domain with an SSL checker such as the SSL Labs server test.

Keep the CMS, themes and plugins updated

The single most effective habit is updating. Vulnerabilities in popular WordPress plugins and themes are published openly, and scanners start looking for them quickly. Run updates on a schedule, weekly for most sites, and sooner for security releases. Test them on a staging copy if the site earns money or uses many plugins, because updates occasionally break layouts or checkout.

  • Delete plugins and themes you do not use; deactivated code can still be exploitable.
  • Install only from the official directory or a vendor you can name, and avoid pirated premium themes, which commonly carry hidden backdoors.
  • Check that each plugin is still maintained; an abandoned plugin is a risk even if it works.
  • The same applies to frameworks: run npm audit or your platform's equivalent on Node.js, Laravel or PHP projects and update dependencies deliberately.

Turn on automatic minor and security updates where your platform offers them, and keep a short list of everything installed so nothing is forgotten when the person who set it up leaves.

Strong authentication for every admin account

Stolen and reused passwords are a leading cause of account takeover. Require unique, long passwords for every admin, stored in a password manager rather than a shared spreadsheet, and enable two-factor authentication using an authenticator app or hardware key where possible. Do not leave the default username as admin, give each person their own account so access can be removed individually, and give people only the role they need: an editor does not need administrator rights.

Limit login attempts and consider moving or protecting the admin URL, which cuts the noise from automated guessing. Remove accounts of former staff and contractors the day they leave. Check your hosting, domain registrar and email accounts too, because taking over the domain account is often worse than defacing the site.

Security headers worth setting

Response headers let the server instruct the browser to enable protections. Three are safe starting points for most sites. X-Content-Type-Options set to nosniff stops browsers from guessing a file's type and executing something that was uploaded as an image. Frame protection, through the frame-ancestors directive of Content-Security-Policy or the older X-Frame-Options header, stops other sites from embedding yours in a hidden frame to trick visitors into clicking. Content-Security-Policy restricts where scripts, styles and images may load from, which limits the damage of injected script.

CSP is the powerful one and the easiest to get wrong, because a strict policy will block inline scripts and third-party tags you forgot about. Deploy it first in report-only mode, read what would have been blocked, and tighten gradually.

JavaScript· Setting basic headers in an Express server; the same values apply in Apache, Nginx or a host config.
import express from "express";
const app = express();

app.use((req, res, next) => {
  res.setHeader("X-Content-Type-Options", "nosniff");
  res.setHeader("Content-Security-Policy", "default-src 'self'; frame-ancestors 'self'");
  res.setHeader("Referrer-Policy", "strict-origin-when-cross-origin");
  next();
});

app.listen(3000);

That example policy is deliberately tight and will break a site that loads analytics or fonts from other domains, so treat it as a starting point and add the sources you actually use. Check results with the Security Headers scanner or the Network panel.

Form spam and input validation

Every form field is an entrance. Validate on the server, not only in the browser, since client-side checks are trivially bypassed. Check type, length and expected format, reject what does not fit, and never build a database query by joining user text into a string; use parameterised queries or your framework's query builder. Escape output when printing user content into a page, so a submitted script tag is displayed as text rather than run.

For spam, a hidden honeypot field that real people never fill in catches many simple bots, a time check rejects forms submitted instantly, and a rate limit per address slows floods. A CAPTCHA service is a heavier option that you can add if those fail. If a contact form sends email, make sure submitted values cannot be placed in mail headers, otherwise spammers can turn the form into a relay. Restrict file uploads by type and size, store them outside the web root where possible, and never trust the filename.

Backups, and proving you can restore one

A backup you have never restored is a hope, not a plan. Back up both the files and the database, on a schedule that matches how often content changes, and store copies away from the server itself, because ransomware or a failed host takes local backups with it. Keep several generations, not just the latest, since an infection may be days old before anyone notices.

Then test. Once a quarter, restore a recent backup to a separate location, a staging subdomain or a local machine, and confirm the pages load, images appear, the admin login works and a test form submission arrives. Time how long it takes and write the steps down, so that in an emergency the person doing it follows a checklist instead of improvising. If the restore fails, you have learned something cheap now instead of something expensive later.

Need this built properly for your business?

CodingMarble is a remote studio in India that builds websites, apps and games on fixed packages with the scope written down before payment. Try the free tools we run, or start a project when you are ready.