Cybersecurity Topics: Threats, Defences and Careers · Course book
Chapter 8: Application Security
Firewalls and network controls protect the roads that data travels on, but most organisations deliberately leave one door wide open: their applications. A shop's website, a school's learning platform and a bank's mobile app must accept input from anyone on the internet, so any flaw in how they handle that input is exposed to the whole world. Application security is the practice of finding, fixing and preventing weaknesses in software, from the first design discussion to the day it is retired. This chapter explains why applications are such a common target, introduces the most widely used list of web application risks, shows how security is built into each stage of software development, describes the main ways of testing applications, and introduces threat modelling as a structured way of thinking like an attacker before any code is written.
Why applications are targeted
Applications sit at the meeting point of two worlds: the public internet and the organisation's most valuable data. A login page, a search box or a file upload form is reachable by anyone, and behind it lie customer records, payments and business logic. Because applications are written by people under deadlines, they contain mistakes, and some mistakes create vulnerabilities: ways for an attacker to make the software do something its designers never intended.
Many application vulnerabilities share a root cause: the program trusts input that it should treat with suspicion. A web page that places a visitor's comment straight into the page may allow that visitor to insert a script that runs in other people's browsers, an attack called cross-site scripting (XSS). A program that builds a database command by pasting in a user's text may allow that user to rewrite the command, an attack called SQL injection, examined in the next chapter. A server that fetches a web address supplied by a user may be tricked into fetching internal resources, the subject of the chapter after that. The common lesson is that all input from outside the program, including form fields, web addresses, cookies, uploaded files and data from other systems, must be checked and handled safely.
The OWASP Top 10
The Open Worldwide Application Security Project (OWASP), a non-profit community, publishes a regularly updated list of the ten most critical web application security risks, based on data contributed by organisations that test thousands of applications. It has become a common reference for developers, testers and auditors. The 2021 edition lists the following categories.
| Rank | Category | What goes wrong |
|---|---|---|
| A01 | Broken access control | Users can view or change data they should not, for example by editing an account number in a web address |
| A02 | Cryptographic failures | Sensitive data is unencrypted, weakly encrypted or protected with poor key handling |
| A03 | Injection | Untrusted input is interpreted as commands, as in SQL injection and cross-site scripting |
| A04 | Insecure design | Security was never considered in the design, so no amount of careful coding can fix it |
| A05 | Security misconfiguration | Default accounts, unnecessary features, detailed error messages or open cloud storage |
| A06 | Vulnerable and outdated components | Libraries and frameworks with known flaws are left unpatched |
| A07 | Identification and authentication failures | Weak login handling, such as allowing unlimited password guesses or poor session management |
| A08 | Software and data integrity failures | Updates or data are accepted without checking that they are genuine and unaltered |
| A09 | Security logging and monitoring failures | Attacks go unnoticed because nothing is recorded or reviewed |
| A10 | Server-side request forgery | The server is tricked into making requests to places the attacker chooses |
Two points stand out. First, the top risk is not an exotic technical attack but broken access control: applications that check whether a user is logged in but not whether that user is allowed to see the particular record requested. Second, several categories, such as insecure design and logging failures, concern process rather than individual lines of code, showing that application security depends on how software is planned and operated, not just on how it is typed.
Building security into development
Fixing a security flaw is cheapest when it is caught early. A design flaw spotted on a whiteboard costs a conversation to fix; the same flaw discovered after release may require rewriting large parts of the system, emergency patches and notifying affected customers. The secure software development life cycle (secure SDLC) therefore adds security activities to every stage of development, an approach often summarised as "shifting left", towards the start of the timeline.
At the requirements stage, teams write down security needs alongside features: which data is sensitive, who may access what, and which laws apply. In design, they model threats and choose safe architectures. During implementation, developers follow secure coding guidelines, use well-tested libraries for tasks such as authentication and encryption rather than writing their own, and review each other's code. Testing includes security tests as well as functional ones. Deployment uses hardened configurations, with debugging features switched off and secrets stored securely rather than in the code. Maintenance means monitoring, updating components when vulnerabilities are announced and responding to reports from users and researchers.
A few coding principles prevent a large share of problems: validate input against what is expected, such as a date or a number in a range, and reject the rest; encode output so that user data displayed on a page is treated as text, not code; use parameterised queries for databases; check authorisation on every request, on the server, not just in the user interface; and fail safely, showing users a generic error message while recording details in a protected log.
Testing applications
Several complementary testing methods find different kinds of weakness. Static application security testing (SAST) analyses source code without running it, looking for dangerous patterns such as user input flowing into a database query; it can run automatically every time code changes. Dynamic application security testing (DAST) tests the running application from the outside, as an attacker would, sending unusual inputs and watching the responses. Software composition analysis lists the third-party libraries an application uses and flags any with known vulnerabilities, which matters because modern applications are often built mostly from other people's code.
The danger of third-party components was shown dramatically in December 2021, when a critical flaw, nicknamed Log4Shell, was disclosed in Log4j, a free logging library used inside an enormous number of Java applications. An attacker could trigger it simply by getting the application to record a specially crafted line of text, for example by typing it into a chat box or a login form. Many organisations did not know which of their systems contained the library, because it was buried several layers deep inside other components. Those that kept an accurate inventory of their software components, sometimes called a software bill of materials, could find and patch affected systems in hours; others spent weeks searching. The episode convinced many teams that knowing what their applications are built from is a basic security requirement.
Automated tools are fast and consistent but miss flaws in business logic, such as a checkout process that lets a customer apply the same discount code a hundred times. Manual penetration testing by skilled, authorised testers finds such issues, and many organisations also run bug bounty or vulnerability disclosure programmes that invite independent researchers to report flaws responsibly. Each method has gaps; together they give a far more complete picture.
Threat modelling with STRIDE
Threat modelling is a structured way of asking, early in design, "what could go wrong?". A team draws a simple diagram of the system, showing users, components, data stores and the flows of data between them, and marks the trust boundaries where data crosses from a less trusted area to a more trusted one, such as from the internet to the web server. They then examine each element for threats.
A widely used checklist, developed at Microsoft, is STRIDE. Spoofing: can someone pretend to be another user or system? Tampering: can data be altered in transit or storage? Repudiation: can someone deny an action because nothing records it? Information disclosure: can data leak to the wrong people? Denial of service: can the system be made unavailable? Elevation of privilege: can a user gain rights they should not have? For a school's homework-submission system, STRIDE might reveal that students could spoof one another by guessing session identifiers, tamper with submission timestamps, or elevate privilege by calling a teacher-only marking function directly. Each threat found becomes a design requirement and, later, a test case.
Check your understanding
- Explain why "trusting input" is a common root cause of application vulnerabilities, and list four sources of input a web application receives.
- Describe a simple example of broken access control in an online banking app.
- Why is fixing a security flaw cheaper at the design stage than after release?
- Compare SAST and DAST, giving one strength of each.
- Apply STRIDE to an online library booking system and identify one threat for each letter.
- Why might an application with no coding mistakes still fall into the "insecure design" category?
This course book is available to read online only at chrysolites.org.