Web application security: the main threats and how to defend against them
Web application security is a set of measures that keep outsiders from reading other people's data, acting on behalf of another user or taking the service down. The main threats have long been known: injections into database queries, XSS, access control bypass, leaked secrets, weak passwords and outdated dependencies. Protection is built into the architecture and into every change: input validation, server-side permission checks, secrets kept outside the code, an action log. After launch, security is maintained through updates, monitoring and regular audits.
Open the software development page
Why security is built in from day one
A vulnerability rarely looks like a hole in a wall. More often it is a small thing: a form field the server accepts without checking, a document link that can be guessed, a payment service key accidentally pushed to the repository. On their own such details go unnoticed, yet any one of them can expose customer data or money to strangers.
Adding security right before handover is almost impossible: by then the decisions about data storage, roles and sign-in have already been made and baked into the code. That is why protection requirements are set at the design stage and checked with every change — the same way the team checks that the product works at all.
The main threats to a web application
Typical web application vulnerabilities have long been described by the industry — for example, in the open OWASP Top 10 list. In practice the most common ones are:
- Injections — user data ends up in a database query or a server command as part of the code. This can be used to read or delete other people's records.
- XSS, cross-site scripting — a foreign script is embedded in a page, runs in other users' browsers and steals their sessions or data.
- Request forgery — an attacker's site makes a signed-in user's browser perform an action in your service without their knowledge.
- Access control bypass — a user changes the order number in the address or request and sees someone else's order because the server did not check whose it is.
- Leaks — exposed backups, logs with personal data, secrets and keys in the code or repository.
- Weak passwords and brute force — sign-in does not limit attempts, and passwords are stored unsafely.
- Outdated dependencies and misconfiguration — libraries with known vulnerabilities, debug mode on a production server, unnecessary open ports.
How to defend against injections and XSS
Against injections a simple rule works: data never becomes code. Database queries are built with parameters instead of being glued together from strings, and every incoming field is validated on the server — type, length, format, allowed values. Browser-side validation is convenient for the user but does not count as protection: a request can be sent bypassing the interface.
Against XSS, data is escaped when it is output to the page, and the browser receives a strict content security policy (CSP) stating which scripts, styles and addresses it may load. Even if a mistake slips through somewhere, such a policy will not let a foreign script run. Against request forgery, protective tokens and correct cookie settings are used.
Passwords, sign-in and sessions
Passwords are stored only as a strong hash — never in plain text and never with reversible encryption — so that even if the database leaks they are hard to recover. Sign-in attempts are limited, suspicious activity is logged, and where money and sensitive data are involved a second verification step is added.
Sessions get a lifetime, and users can end sessions on other devices. Password recovery should not reveal whether an account exists and should not allow the account to be hijacked. Sign-in options are covered in detail in the guide to customer portal development.
Access rights: checked on the server, not in the interface
The most common mistake in business applications is permissions enforced only by hiding buttons. If the server does not verify on every request who sent it and what that person is allowed to do, data can be obtained bypassing the interface. A reliable scheme looks like this:
- each role has the minimum rights needed for its work;
- permissions are checked on the server for every action, including file downloads;
- documents are served after a permission check, not via a guessable link;
- actions of administrators and managers are logged: who changed what and when;
- access for departed employees and contractors is revoked immediately.
Data, secrets and money
The less unnecessary personal data an application collects, the less harm a possible leak can do and the easier it is to meet data protection requirements in different countries. Data travels only over encrypted connections, backups are stored separately and tested to confirm they can actually be restored. How to choose storage and where to keep personal data is covered in the guide to web application databases.
Keys for external services, database passwords and tokens are kept outside the code and outside the repository. Amounts, discounts and decisions that affect money are calculated on the server: the browser is shown the result but its calculations are not trusted.
Updates, monitoring and audits
An application that is not updated becomes vulnerable by itself over time: bugs are found in libraries and platforms change their requirements. So dependencies are updated regularly and discovered vulnerabilities are fixed by priority. Alerts about failures and unusual activity help the team learn about a problem before customers do — see the guide to software support and SLA.
A security audit is an outside view: a review of the code, dependencies, server settings and access rights. It is worth doing before launch, after major changes and when taking over a project from another team. Some checks are built into automated tests so that a fixed vulnerability does not return — more in the guide to software testing.
A pre-launch security checklist
Before going to production it helps to go through a short list. It does not replace an audit, but it catches the most common and most expensive slips:
- every incoming field is validated on the server, and database queries are built with parameters;
- data is escaped on output, and the browser has a strict content security policy;
- passwords are stored as a strong hash, sign-in attempts are limited, and roles with access to money have a second verification step;
- permissions are checked on the server for every action, and direct links to files and documents do not open without a check;
- secrets and keys are kept outside the code and the repository, and test keys have not ended up in production;
- debug mode is off on the production server, and error messages do not reveal how the system is built;
- all connections use an encrypted protocol, and unnecessary ports and service pages are closed;
- dependencies are updated and known vulnerabilities are fixed;
- administrator actions are logged, and alerts for failures and suspicious activity are set up;
- backups are created automatically, and restoring from them has actually been tested.
Each item is worth turning into a repeatable check: some into automated tests, some into steps of the release process. Then the list is checked not once before launch but with every update, and protection does not weaken over time.
It is also worth agreeing on who is responsible for security after launch: who receives the alerts, who decides how urgent a discovered vulnerability is and how quickly a fix is released. Without this, even a well-protected product loses its protection over time: dependencies go out of date, staff keep unnecessary permissions and nobody reads the warnings in the logs. The procedure for responding to failures and vulnerabilities is conveniently recorded in the support agreement together with the other working rules.
How JEEKSSHIRE 24 approaches security
For us security is a requirement for every change, not a separate stage before handover: validation of every incoming field, role-based permissions, an administrator action log, secrets kept outside the code, a strict content security policy in the browser and money calculated on the server. Every release ships only after the build, linter and tests have passed. Our own products follow the same rules: Wallet has an order execution queue with statuses, isolated payment routes and amounts calculated on the server.
We build web applications and mobile apps with these requirements from day one, and we take other teams' projects into support and further development, starting with an audit of the code and infrastructure. All services are on the custom software development page.
Frequently asked questions
What are the most common threats to a web application?
Injections into database queries, XSS, access control bypass, leaks of secrets and data, weak passwords and outdated dependencies with known vulnerabilities.
Is browser-side validation enough?
No. It is convenient for the user, but a request can be sent bypassing the interface. Every field must be validated on the server.
How should user passwords be stored?
Only as a strong hash that cannot be decrypted. In addition, sign-in attempts are limited and a second verification step is added where money is involved.
When should a security audit be done?
Before launch, after major changes and when taking over a project from another team. Regular checks are built into automated tests and the release process.
Where should keys and passwords for external services be kept?
Outside the code and the repository — in the server environment settings or in a separate secrets store with restricted access.