Samer Aoudi
CH2: The Web Application Security Problem

Due to the open nature of the Web, it is both a subject and an object of security breaches and attacks. This chapter outlines the inherent security problem of Web Applications. The chapter introduces Web Application security standards including the top 10 known security flaws and vulnerabilities as defined by OWASP.

Learning Outcomes
Upon completing this chapter, the learner will be able to:
  • Discuss the inherent problem of web applications
  • Identify active organizations in the area of web application security
  • Discuss common web security concepts
  • List the OWASP Top 10 vulnerabilities
Lab Activity: TBA

In this practical activity, you will ...

Coming Soon »
Introduction

The Web is a vast cyberspace that is publically available and [mostly] accessible for all people anytime and from any location. Another important characteristic of the Web is the anonymity it gives for people. When we go online, we become this faceless, nameless person. This anonymity seems to give some people a pass to do things that they wouldn't otherwise.

The openness of the Web and the anonymity it provides, fosters a environment for malicious behavior. As a result, public websites present rich attack surface, but also, some websites are the object (tool) by which many attackers strike. As individuals, we are concerned about our safety and privacy, and as websites owners, we must actively protect the confidentiality, integrity, and availability of our information assets online.

A subject of attack is the target. So when a website is the subject of attack, the attacker would try to do something malicious to the website. An object of attack is the tool utilized in initiating or performing the action of the attack. When a website is the object of the attack, it sends the client malicious code.


Figure 2.1: Web Anonymity

As discussed earlier, people access websites through web browsers. The server is waiting and listening to our requests. Users' personal computers receive web pages along with related artifacts (client-side stuff). This request-response model assumes mutual trust between the participants (client and server). However, quite often, this trust is misused from both parties. An attacker can send malicious content to the server within the HTTP request. And a malicious website can send intrusive content back to us (the client) within the HTTP response.

The Inherent Problem

The inherent problem of the Web is that [web] traffic is flowing in and out between the client and the server. Ports on both sides are open and ready to accept web traffic. Therefore, security tools, like the firewall, may not protect against web attacks since they are configured to let web traffic through. On the server, for instance, ports 80 (HTTP) and 443 (HTTPS) are open otherwise the website is inaccessible (which would defeat its purpose).

Some might think that security measures taken to protect organizational infrastructure is enough to protect the web application against attacks. The reality is, web apps are attacked at the application level. In other words, attackers target the web server posing as legitimate website users.

Also, such measures as using HTTPS and Secure Socket Layer (SSL) to encrypt web traffic, only protects data while its on-the-move between the client and the server (or vice versa) but not while the data is sitting on either sides.

Website security refers to the protection of personal and organizational public-facing websites from cyberattacks. [1]
Implications

Security breaches in web applications may lead to serious implications. An organization's website is its public front and therefore a lot is at stake. Here are some possible implications:

  • Unauthorized access to data (information confidentiality)
  • Unauthorized data change (information integrity)
  • Denial of Service (information availability)
  • Theft of identity or money
  • Website defacement

RECENT INCIDENTS WHID 2019-001: MyPillow and Amerisleep wake up to Magecart card theft nightmare. MyPillow and Amerisleep are both popular mattresses and bedding merchants in the United States. While their websites boast the best deals around for a proper night's sleep, what is lacking is an acknowledgment of two separate security incidents potentially impacting their customers -- incidents which RiskIQ says took place as far back as 2017. [2]
References
[1] Web Security, CISA
[2] Web Hacking Incident Database (WHID)
Ads by Google
Web Application Security Standards

There are few organizations that provide World Wide Web security information, guidelines, and best-practices. To name a few: OWASP, NIST, WASC, etc.

Let us start with some relevant cybersecurity definitions:

  • Threat: A threat is a potential violation of security. The source of a threat can be a person (e.g., hacker, employee), or an incident (e.g., power failure).
  • Impact: The impact of an event (e.g. an attack) is defined as the "consequences for an organization or environment when an attack is realized, or weakness is present." [3]
  • Attack: An attack is "a well-defined set of actions that, if successful, would result in either damage to an asset, or undesirable operation" [3]. Bu definition, and attack may, or may no, be successful.
  • Weakness: A weakness is "a type of mistake in software that, in proper conditions, could contribute to the introduction of vulnerabilities within that software. This term applies to mistakes regardless of whether they occur in implementation, design, or other phases of the SDLC." [4]
  • Vulnerability: A vulnerability is "an occurrence of a weakness (or multiple weaknesses) within software, in which the weakness can be used by a party to cause the software to modify or access unintended data, interrupt proper execution, or perform incorrect actions that were not specifically granted to the party who uses the weakness." [4]
  • Authentication: Authentication is the process of verifying the true identity of an actor by checking his or her credentials such as username and password.
  • Authorization: Authorization is the process of determining whether an actor is allowed to access a resource of perform an action. Authorization typically comes after authentication and is all about Access Control.


Figure 2.2: Authentication

While I will be using the terms Weakness and Vulnerability interchangeably throughout the book, in the next section, I will provide a practical example highlighting the difference.
WASC*

WASC, or the Web Application Security Consortium, is a not-for-profit charitable organization made up of an international group of experts, industry practitioners, and organizational representatives who produce open source and agreed upon best-practice security standards for the World Wide Web [3]. WASC feature articles, guidelines, and projects related Web security.

The Web Application Security Scanner Evaluation Criteria (WASSEC) is a set of guidelines to evaluate web application scanners on their ability to effectively test web applications and identify vulnerabilities. It covers areas such as crawling, parsing, session handling, testing, and reporting [3]. The course covers some of these tools.

The WASC Threat Classification (TC) clarifies and organizes the threats to the security of a web site. The aim of the project is to "develop and promote industry standard terminology for describing these issues" [3]. WASC TC provides a reference to security threats by classifying them as attacks (e.g. a brute force attack on the login page of a website), and weaknesses (e.g. server misconfiguration where the admin left few defaults unchanged).


WASC Attacks [7]
  • Cross-Site Scripting (XSS): is an attack technique that involves echoing attacker-supplied code into a user's browser instance. A browser instance can be a standard web browser client, or a browser object embedded in a software product such as the browser within WinAmp, an RSS reader, or an email client. The code itself is usually written in HTML/JavaScript, but may also extend to VBScript, ActiveX, Java, Flash, or any other browser-supported technology.
  • SQL Injection: is an attack technique used to exploit applications that construct SQL statements from user-supplied input. When successful, the attacker is able to change the logic of SQL statements executed against the database.
  • Buffer Overflow: A Buffer Overflow is a flaw that occurs when more data is written to a block of memory, or buffer, than the buffer is allocated to hold. Exploiting a buffer overflow allows an attacker to modify portions of the target process’ address space.
  • Fingerprinting: The most common methodology for attackers is to first footprint the target's web presence and enumerate as much information as possible. With this information, the attacker may develop an accurate attack scenario, which will effectively exploit a vulnerability in the software type/version being utilized by the target host.
  • Path Traversal: The Path Traversal attack technique allows an attacker access to files, directories, and commands that potentially reside outside the web document root directory. An attacker may manipulate a URL in such a way that the web site will execute or reveal the contents of arbitrary files anywhere on the web server. Any device that exposes an HTTP-based interface is potentially vulnerable to Path Traversal.
  • Denial of Service (DoS): is an attack technique with the intent of preventing a web site from serving normal user activity. DoS attacks, which are easily normally applied to the network layer, are also possible at the application layer. These malicious attacks can succeed by starving a system of critical resources, vulnerability exploit, or abuse of functionality.

WASC Weaknesses [7]
  • Server Misconfiguration: attacks exploit configuration weaknesses found in web servers and application servers. Many servers come with unnecessary default and sample files, including applications, configuration files, scripts, and web pages. They may also have unnecessary services enabled, such as content management and remote administration functionality. Debugging functions may be enabled or administrative functions may be accessible to anonymous users. These features may provide a means for a hacker to bypass authentication methods and gain access to sensitive information, perhaps with elevated privileges.
  • Directory Indexing: Automatic directory listing/indexing is a web server function that lists all of the files within a requested directory if the normal base file (index.html / home.html / default.htm / default.asp / default.aspx / index.php) is not present.
  • Insufficient Authentication: occurs when a web site permits an attacker to access sensitive content or functionality without having to properly authenticate. Web-based administration tools are a good example of web sites providing access to sensitive functionality. Depending on the specific online resource, these web applications should not be directly accessible without requiring the user to properly verify their identity.
  • Insufficient Authorization: results when an application does not perform adequate authorization checks to ensure that the user is performing a function or accessing data in a manner consistent with the security policy. Authorization procedures should enforce what a user, service or application is permitted to do. When a user is authenticated to a web site, it does not necessarily mean that the user should have full access to all content and functionality.
  • Improper Input Handling: is one of the most common weaknesses identified across applications today. Poorly handled input is a leading cause behind critical vulnerabilities that exist in systems and applications. Generally, the term input handing is used to describe functions like validation, sanitization, filtering, encoding and/or decoding of input data.
  • Improper Output Handling: Output handling refers to how an application generates outgoing data. If an application has improper output handling, the output data may be consumed leading to vulnerabilities and actions never intended by the application developer. In many cases, this unintended interpretation is classified as one or more forms of critical application vulnerabilities.

The *WASC website and projects seem to be halted. On the day of this publication, all their projects are outdated with no recent contributions. WASC, nonetheless, provide good web security resources and remains to be a good reference on the matter.
NIST

The National Institute of Standards and Technology (NIST) was founded in 1901 and is now part of the U.S. Department of Commerce. The Information Technology Laboratory (ITL) is one of NIST’s six research laboratories that focuses on IT measurements, testing, and standards, and is a globally recognized and trusted source of high-quality, independent, and unbiased research and data. [5]

NIST provides information and guidelines in the form of online publications. In the are of Web Security, publication SP 800-44 provides guidelines on Securing Public Web Servers, and pubblication SP 800-95 is a guide to Secure Web Services.

OWASP

OWASP, or the Open Web Application Security Project, is a "worldwide not-for-profit charitable organization focused on improving the security of software." Their mission is "to make software security visible, so that individuals and organizations worldwide can make informed decisions about true software security risks" [6] OWASP feature many resources, guidelines, and projects related to Web security. The most relevant to this course is the OWASP Top 10 project.

"The OWASP Top Ten is a powerful awareness document for web application security. The OWASP Top Ten represents a broad consensus about what the most critical web application security flaws are" [6] Security flaws discussed in this course are based on the OWASP Top 10 project.

References
[3] WASC
[4] CWE-MITRE
[5] NIST
[6] OWASP
[7] WASC Threat Classification
OWASP Top Ten Project

"The OWASP Top 10 is a standard awareness document for developers and web application security. It represents a broad consensus about the most critical security risks to web applications" [8].

The OWASP Top 10 Project presents a ranked list of common vulnerabilities based on severity. This ranking is not organization-specific. In the Risk Management lifecycle, Risk Assessment is the phase when we try to identify and rate threats, vulnerabilities, and risk. In other words, Risk Assessment should include vulnerability assessment. Typically, we would take vulnerability data, map it to likely threats, evaluate the severity for our environment, and articulate our own risk. For example, a very highly ranked vulnerability (e.g. Broken Access Control) might not pose a big risk for a specific organization if they have effective controls in place.


Figure 2.3: OWASP TOP 10
The OWASP Top Vulnerabilities are mapped to Common Weakness Enumerations (CWEs).

Common Weakness Enumerations

CWE™ is a list of software and hardware weakness types. It serves as a common language and as a baseline for weakness identification, mitigation, and prevention efforts. Each weakness has a webpage that provides detailed information including description, scope, impact, likelihood and examples. An example of a CWE weakness:

CWE-200: Exposure of Sensitive Information to an Unauthorized Actor

ID: CWE-200
Description: The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
Alternate Terms: Information Disclosure; Information Leak
Scope: Confidentiality
Likelihood Of Exploit: High
Observed Example: CVE-2005-1205 Telnet protocol allows servers to obtain sensitive environment information from clients.

As mentioned in the previous section, a vulnerability is an occurrence of a weakness. That is why within each CWE, there is a section for these "occurrences" (i.e., related CVEs).
Common Vulnerabilities and Exposures

Common Vulnerabilities and Exposures (CVE) is a public online directory that lists and defines cybersecurity vulnerabilities. There is one CVE record for each vulnerability in the catalog. The Current website is https://cve.mitre.org but a new website is underway and will be available soon (https://www.cve.org/). An example of a CVE, which is an observed example of CWE-200, is CVE-2005-1205:

CVE-2005-1205

ID: CVE-2005-1205
Descrption: The Telnet client for Microsoft Windows XP, Windows Server 2003, and Windows Services for UNIX allows remote attackers to read sensitive environment variables via the NEW-ENVIRON option with a SEND ENV_USERVAR command.

The Top 10 Web Security Vulnerabilities

The OWASP Top 10 is not a static list. The project started in 2003 and since then there have been multiple lists, the most recent of which is the 2021 with the previous edition being the 2017. The OWASP Top Ten is developed in a hybrid manner based on data (eight of ten risks) and survey (two of ten risks). In 2017 organizations contributed data that covered over 114k applications. In 2021 the contribution more than doubled. While Data is from organizations, the Survey is from individuals. This approach allows individuals in the community identify important risks that may not be in the data from organizations.

In the 2021 Top 10 list below, you will see a reference to the 2017 list in terms of presence and position:

A01:2021-Broken Access Control moves up from the fifth position; 94% of applications were tested for some form of broken access control. The 34 Common Weakness Enumerations (CWEs) mapped to Broken Access Control had more occurrences in applications than any other category.

A02:2021-Cryptographic Failures shifts up one position to #2, previously known as Sensitive Data Exposure, which was broad symptom rather than a root cause. The renewed focus here is on failures related to cryptography which often leads to sensitive data exposure or system compromise.

A03:2021-Injection slides down to the third position. 94% of the applications were tested for some form of injection, and the 33 CWEs mapped into this category have the second most occurrences in applications. Cross-site Scripting is now part of this category in this edition.

A04:2021-Insecure Design is a new category for 2021, with a focus on risks related to design flaws. If we genuinely want to “move left” as an industry, it calls for more use of threat modeling, secure design patterns and principles, and reference architectures.

A05:2021-Security Misconfiguration moves up from #6 in the previous edition; 90% of applications were tested for some form of misconfiguration. With more shifts into highly configurable software, it’s not surprising to see this category move up. The former category for XML External Entities (XXE) is now part of this category.

A06:2021-Vulnerable and Outdated Components was previously titled Using Components with Known Vulnerabilities and is #2 in the Top 10 community survey, but also had enough data to make the Top 10 via data analysis. This category moves up from #9 in 2017 and is a known issue that we struggle to test and assess risk. It is the only category not to have any Common Vulnerability and Exposures (CVEs) mapped to the included CWEs, so a default exploit and impact weights of 5.0 are factored into their scores.

A07:2021-Identification and Authentication Failures was previously Broken Authentication and is sliding down from the second position, and now includes CWEs that are more related to identification failures. This category is still an integral part of the Top 10, but the increased availability of standardized frameworks seems to be helping.

A08:2021-Software and Data Integrity Failures is a new category for 2021, focusing on making assumptions related to software updates, critical data, and CI/CD pipelines without verifying integrity. One of the highest weighted impacts from Common Vulnerability and Exposures/Common Vulnerability Scoring System (CVE/CVSS) data mapped to the 10 CWEs in this category. Insecure Deserialization from 2017 is now a part of this larger category.

A09:2021-Security Logging and Monitoring Failures was previously Insufficient Logging & Monitoring and is added from the industry survey (#3), moving up from #10 previously. This category is expanded to include more types of failures, is challenging to test for, and isn’t well represented in the CVE/CVSS data. However, failures in this category can directly impact visibility, incident alerting, and forensics.

A10:2021-Server-Side Request Forgery is added from the Top 10 community survey (#1). The data shows a relatively low incidence rate with above average testing coverage, along with above-average ratings for Exploit and Impact potential. This category represents the scenario where the security community members are telling us this is important, even though it’s not illustrated in the data at this time.

Other OWASP Projects

The OWASP Foundation gives aspiring open source projects a platform to improve the security of software. Project relevant to our course:

Web Security Testing Guide

The Web Security Testing Guide (WSTG) Project is a comprehensive guide to testing the security of web applications and web services. Created by the collaborative efforts of cybersecurity professionals and dedicated volunteers, the WSTG provides a framework of best practices used by penetration testers and organizations all over the world.

OWASP Juice Shop

The OWASP Juice Shop is a sophisticated and intentionally insecure web application. Juice Shop includes vulnerabilities from the entire OWASP Top 10 along with many other security flaws found in real-world applications.

OWASP ZAP

The OWASP Zed Attack Proxy (ZAP) is a free, open-source penetration testing tool being maintained under the umbrella of the Open Web Application Security Project (OWASP). ZAP is designed specifically for testing web applications and is both flexible and extensible.

In the upcoming chapters, the OWASP top ten vulnerabilities will be discussed in details. I want to note, however, that I will necessarily be covering these vulnerabilities in their ranked order. Instead, I will cover them in a logical order of relevance and book progress. I will combine related vulnerabilities within a single chapter when applicable.
References
[8] OWASP Top 10
[9] Web Security Testing Guide (WSTG)
[10] Zed Attack Proxy (ZAP)
[11] Juice Shop
Chapter 2 Summary
  • The openness of the Web and the anonymity it provides, fosters a environment for malicious behavior, making it both an object and a subject of attacks.
  • The inherent problem of the Web is that [web] traffic is flowing in and out between the client and the server. Web apps are attacked at the application level where attackers target the web server posing as legitimate website users.
  • Security breaches in web applications may lead to serious implications including serious impact on Confidentiality, Integrity, and Availability.
  • There are few organizations that provide World Wide Web security information, guidelines, and best-practices (e.g., OWASP, NIST, WASC, etc.)
  • WASC, or the Web Application Security Consortium, produce open source and agreed upon best-practice security standards for the World Wide Web. Their contributions include: The Web Application Security Scanner Evaluation Criteria (WASSEC) and the WASC Threat Classification (TC).
  • The National Institute of Standards and Technology (NIST) include the Information Technology Laboratory (ITL) that focuses on IT measurements, testing, and standards, and is a globally recognized and trusted source of high-quality, independent, and unbiased research and data.
  • OWASP, or the Open Web Application Security Project, is an organization focused on improving the security of software. OWASP feature many resources, guidelines, and projects related to Web security. The most relevant to this course is the OWASP Top 10 project.
  • The OWASP Top Ten is a powerful awareness document for web application security. The OWASP Top Ten represents a broad consensus about what the most critical web application security flaws are.
  • Other OWASP projects relevant to this course, include: Web Security Testing Guide; OWASP Juice Shop; OWASP ZAP.
Chapter 2 Revision Questions
  • What is a threat? Give examples.
  • What is the difference between a Weakness and a Vulnerabbility?
  • What is the difference between Authentication and Authorization?
  • Name three organizations that provide Web Security standards and guidelines.
  • Explain one WASC Attack
  • Explain one WASC Weakness
  • What is the OWASP Top 10 project?
  • List four Vulnerabilities from the OWASP Top 10 2021
Ads by Google
               
© Samer Aoudi 2005-2024