Practice Exams:

Introduction to web application security and owasp

In the digital age, web applications are integral to everyday operations, from financial services and healthcare to e-commerce and social networking. While their convenience and capabilities are undeniable, they also represent a significant attack surface for cybercriminals. The rapid adoption of modern frameworks, APIs, and third-party integrations has increased the likelihood of security missteps, making structured guidance essential for developers and organizations alike.

To address these concerns, the Open Web Application Security Project, known widely as OWASP, plays a vital role. This global non-profit organization offers free tools, community-driven documentation, and educational resources to improve the security of software. Among its many initiatives, the OWASP Top 10 is the most renowned. It outlines the most critical security risks to web applications, helping organizations prioritize their defense strategies. This list is not theoretical; it is based on real data from various security assessments, breaches, and vulnerability research from across the world.

The OWASP Top 10 serves as both a benchmark and a practical starting point for secure development. In this section, we explore the first three risks on the list: injection, broken authentication, and sensitive data exposure. These vulnerabilities are commonly exploited and can have devastating consequences if left unaddressed.

Understanding injection vulnerabilities

Injection flaws are one of the oldest and most dangerous types of web application vulnerabilities. They occur when untrusted data is sent to an interpreter as part of a command or query. The attacker’s malicious input alters the logic of the execution, causing the system to perform unintended actions.

There are multiple types of injection attacks, including SQL injection, OS command injection, LDAP injection, and NoSQL injection. Each of these targets a specific type of interpreter and can be exploited in different ways, but the core issue remains the same: the failure to treat user input as untrusted.

A common scenario involves a web form used to log into an application. Suppose the backend uses a SQL query like this:

select * from users where username = ‘[user_input]’ and password = ‘[user_input]’;

If an attacker inputs ‘ or ‘1’=’1 for the username and leaves the password blank, the resulting query will be:

select * from users where username = ” or ‘1’=’1′ and password = ”;

Because ‘1’=’1′ is always true, the query returns a valid result, potentially granting the attacker access without valid credentials.

The consequences of injection attacks can include unauthorized data access, data loss, corruption, denial of service, and even full system compromise. Attackers may extract sensitive records, alter or delete data, or issue commands to the underlying operating system.

Preventing injection requires several proactive measures. The most important is the use of parameterized queries or prepared statements, which separate data from executable code. This approach ensures that the input is treated as a value, not a command. Input validation is also critical; applications should enforce strict rules on what constitutes acceptable input. Additionally, escaping special characters and employing a secure application architecture that avoids dynamic query generation can significantly reduce risk.

Limiting the privileges of application accounts at the database level can mitigate the damage even if an injection does occur. Regular code reviews, automated scanning tools, and web application firewalls can help detect and block potential injection attempts during both development and runtime.

Broken authentication and its implications

Authentication is the cornerstone of secure user access. It ensures that users are who they claim to be and grants appropriate access to resources. However, when the authentication process is flawed, it can be exploited to impersonate users or even take full control of an application.

Broken authentication vulnerabilities occur due to poor design or incorrect implementation of identity verification mechanisms. Common causes include the use of default or predictable credentials, lack of brute-force protection, poor session management, weak password requirements, and inadequate multi-factor authentication.

One of the simplest examples is a login form that accepts any password due to incorrect logic. Even more advanced applications can be at risk if session identifiers are not properly protected. Attackers can hijack sessions, bypass login systems, or escalate privileges by exploiting these weaknesses.

Credential stuffing is another prevalent issue. In this attack, previously stolen usernames and passwords are used in automated login attempts. Since many users reuse passwords across multiple platforms, these attacks can be alarmingly effective. Without rate limiting or anomaly detection, applications can become easy targets.

To mitigate broken authentication, several best practices should be adopted. Password policies should enforce complexity, minimum length, and expiration. Authentication mechanisms must not rely solely on single-factor credentials. Implementing multi-factor authentication adds a critical layer of defense by requiring an additional piece of information beyond the password.

Session management also plays a crucial role. Session IDs should be unpredictable, securely stored, and invalidated after logout, timeout, or inactivity. Developers must avoid exposing session identifiers in URLs or logs. Implementing HTTP-only and secure cookies ensures that sessions cannot be stolen through client-side attacks such as cross-site scripting.

Monitoring authentication attempts and maintaining logs is essential for detecting and responding to suspicious activity. Security teams should regularly review login patterns, failed attempts, and session behaviors to identify potential intrusions early.

Ultimately, strong authentication is not just about technology; it’s about strategy and vigilance. Protecting user identities and access mechanisms requires ongoing evaluation and adaptation to evolving attack techniques.

The risk of sensitive data exposure

Every web application handles some form of data, and in many cases, that data is highly sensitive. Whether it’s personal information, financial details, healthcare records, or authentication tokens, unauthorized access or disclosure can lead to severe consequences.

Sensitive data exposure occurs when applications fail to adequately protect critical information. This may involve unencrypted transmissions, poor storage practices, improper access controls, or the use of outdated cryptographic protocols. Attackers can exploit these weaknesses to intercept data, manipulate it, or steal it for malicious use.

Inadequate encryption is one of the most frequent culprits. Applications that transmit data over unencrypted HTTP are vulnerable to man-in-the-middle attacks, where an attacker intercepts and reads the data. Even with HTTPS, using weak cipher suites or expired certificates can compromise the integrity and confidentiality of the communication.

Storing sensitive data without encryption or with poor key management is equally dangerous. If an attacker gains access to the storage medium—whether through an injection, broken access control, or insider threat—they can retrieve and misuse the data. This includes credentials, API keys, tokens, and personally identifiable information.

To address sensitive data exposure, encryption must be used both in transit and at rest. Transport Layer Security (TLS) should be enforced across all data exchanges, and the strongest available cryptographic protocols should be selected. At-rest encryption should be supported by robust key management practices, ensuring that keys are not stored alongside the data they protect.

Applications should avoid storing sensitive data unless absolutely necessary. If certain information is only needed temporarily, it should be discarded as soon as its purpose is fulfilled. Databases should be configured to mask or tokenize sensitive fields, and access controls should be enforced to ensure only authorized users and processes can view or modify this data.

Input fields that collect sensitive information should include warnings and validation mechanisms to ensure data is properly formatted and handled. For example, if a form collects credit card details, it should include input validation, formatting, and compliance checks for standards such as PCI DSS.

Regular data classification helps developers understand what types of information their systems handle and how each should be protected. Automated tools can be used to scan for unencrypted data or misconfigurations in storage systems and application code.

Finally, applications should log access to sensitive data and alert administrators when unusual access patterns are detected. This allows for quick identification of breaches and timely incident response, reducing the risk of large-scale data compromise.

Securing web applications is a multifaceted challenge. As attackers grow more sophisticated, developers and organizations must remain vigilant and proactive. The first three vulnerabilities in the OWASP Top 10—Injection, Broken Authentication, and Sensitive Data Exposure—highlight the importance of secure coding practices, robust authentication systems, and diligent data protection.

These risks are not just technical flaws; they represent potential entry points for attackers seeking to disrupt operations, steal data, or compromise user trust. Addressing them requires a blend of secure design principles, modern tooling, ongoing training, and routine assessments.

Introduction to evolving application threats

As web applications evolve, so do the tactics employed by malicious actors. Secure development is no longer optional but an essential component of software quality. A single overlooked vulnerability can lead to severe consequences, from data breaches and service outages to reputational damage and financial loss.

In the first part of this series, we explored three significant risks from the OWASP Top 10: injection attacks, broken authentication, and sensitive data exposure. These flaws primarily target application inputs, user identity mechanisms, and data protection. This part focuses on the next set of threats that emphasize structural and operational weaknesses in application ecosystems: XML External Entities, Broken Access Control, and Security Misconfiguration.

Each of these vulnerabilities highlights a different facet of modern application architecture and deployment. Understanding their nature and mitigating them effectively is essential to building robust and secure web environments.

Xml external entities

XML is a widely used format for data transmission, particularly in older systems and enterprise-level integrations. XML-based protocols are often implemented in everything from financial platforms to APIs. When not configured securely, XML parsers can become a vector for dangerous attacks.

An XML External Entity (XXE) attack occurs when an application processes user-supplied XML containing references to external entities. These entities can be used to retrieve files from the server, conduct internal network scans, or execute denial-of-service attacks.

A basic XXE attack might involve XML input such as:

php-template

CopyEdit

<!DOCTYPE foo [<!ENTITY xxe SYSTEM “file:///etc/passwd”> ]>

<user>

  <name>&xxe;</name>

</user>

 

If the parser is improperly configured, it will replace the entity reference with the contents of the referenced file, potentially exposing sensitive system data.

The underlying cause of XXE is the default behavior of many XML parsers to resolve entities automatically unless explicitly disabled. Older libraries and platforms, especially those used in legacy systems, are particularly vulnerable.

Preventing XXE begins with disabling support for external entities and DTDs (Document Type Definitions) in XML parsers. Developers should avoid relying on features that require DTDs and should use secure configurations when parsing XML input. When possible, XML parsing should be replaced with safer data formats like JSON.

In cases where XML must be used, input validation should ensure that only expected data structures are allowed. Schema validation can help identify unusual or malicious content before processing. Additionally, dependency analysis tools can detect outdated XML libraries that may not support secure configurations.

Patch management is also critical. Keeping XML processing libraries and frameworks up to date ensures access to the latest security enhancements and fixes for known issues.

Another effective control is deploying web application firewalls and intrusion detection systems that can recognize and block suspicious XML payloads. These tools can act as an extra layer of defense for applications exposed to the public internet.

XXE is often overlooked due to its reliance on less-common data formats, but in enterprise environments, it remains a serious threat. Any application that parses XML—especially from untrusted sources—must be scrutinized for exposure to this risk.

Broken access control

Access control is the system that determines who can do what in an application. It defines the boundaries between public and private content, user and admin privileges, and authorized and unauthorized actions. When access control is broken, these boundaries collapse, allowing attackers to perform actions they should not be able to.

Broken access control is one of the most common and dangerous vulnerabilities found in modern web applications. Unlike authentication, which verifies a user’s identity, access control governs what that user can access or modify after login.

There are several ways broken access control can manifest. One of the most common is horizontal privilege escalation, where a user gains access to another user’s resources. Another is vertical privilege escalation, where a regular user performs administrative actions.

If the application does not verify whether the user has admin rights, any logged-in user might be able to perform this action simply by guessing or modifying URLs.

Other common signs of broken access control include the ability to modify client-side parameters to gain privileges, missing access controls on API endpoints, or predictable object references that allow ID enumeration.

The key to preventing broken access control lies in designing and enforcing comprehensive access policies. All access control decisions should be made server-side. Client-side checks, such as hiding buttons or menu items, are easily bypassed and offer no real protection.

Each function or resource in an application must verify whether the current user has permission to perform the requested action. This includes not only web interfaces but also APIs, background services, and data layers.

Implementing role-based access control (RBAC) or attribute-based access control (ABAC) ensures that permissions are centrally defined and enforced consistently. Developers should avoid hardcoding access decisions throughout the application codebase, as this increases the chance of oversight.

Sensitive functions and administrative actions should be separated from regular user functionality and protected using secure authentication and session validation.

Another important measure is to deny access by default. Only explicitly authorized actions and resources should be accessible to users. This approach reduces the risk of inadvertently exposing sensitive functionality.

Audit logs and monitoring systems can also help detect access control violations. Unusual patterns, such as frequent attempts to access restricted resources, can indicate potential abuse.

Penetration testing and secure code reviews are effective for identifying broken access control vulnerabilities before they are exploited. These methods allow developers and security teams to test assumptions about user permissions and validate the strength of access boundaries.

Security misconfiguration

Security misconfiguration is a broad but critical issue that affects nearly every layer of an application’s architecture. It occurs when systems, applications, or frameworks are deployed with insecure default settings, unnecessary features, or incomplete configurations.

Misconfigurations can happen anywhere—in web servers, databases, cloud platforms, APIs, or even within application code. Some typical examples include:

  • Default accounts or passwords left enabled

  • Directory listings enabled on a web server

  • Error messages revealing internal system details

  • Unused services running in production

  • Improper permissions on files or resources

  • Outdated software components with known vulnerabilities

These weaknesses can be exploited to gain unauthorized access, collect system information, or escalate privileges. The consequences vary but can range from data leakage to full system compromise.

Preventing security misconfiguration requires a disciplined and standardized approach to system deployment and maintenance. The first step is to establish secure configuration baselines for all environments. These templates should disable unnecessary features, remove default credentials, and enforce strict access controls.

Infrastructure as code (IaC) can help maintain consistency across environments by scripting the provisioning and configuration of systems. Configuration files and deployment scripts can be version-controlled, reviewed, and audited, reducing the likelihood of human error.

Automated tools should be used to scan systems for known misconfigurations. These tools can identify open ports, unpatched services, and other indicators of exposure. Cloud providers and application platforms often offer built-in security assessments and compliance checks.

Logging and alerting are essential for detecting configuration drift and unauthorized changes. Security teams should be notified when unexpected settings are introduced or when critical configurations are altered.

All software dependencies must be reviewed and updated regularly. Components should be sourced from trusted repositories, and unnecessary packages should be removed from production environments.

Developers and system administrators must collaborate to harden every layer of the stack. This includes secure headers in web servers, appropriate file and directory permissions, disabling debug modes in production, and proper session timeout settings.

One often overlooked aspect of security misconfiguration is insufficient segregation between environments. For example, development or staging systems might share credentials or network access with production. These shared paths create a risk of lateral movement in the event of a breach.

Proper segmentation and isolation of development, testing, and production environments reduce this risk and prevent attacks from spreading across systems.

Security misconfiguration is often the result of inattention or misunderstanding, but its impact can be profound. A well-configured system is not just more secure—it is more stable, predictable, and easier to maintain.

 Unified security strategy

A unified security strategy is the foundation for defending modern web applications against the wide range of threats outlined in the OWASP Top 10. Rather than treating security as a series of isolated fixes or reactive patches, a unified approach integrates protection into every layer of the software development lifecycle. This means embedding security from the initial design phase, enforcing secure coding practices during development, conducting thorough testing and vulnerability assessments before deployment, and maintaining continuous monitoring and incident response capabilities in production.

 A cohesive strategy aligns development, operations, and security teams under shared objectives, supported by policies, automation, and education. By fostering collaboration across departments, using secure frameworks and components, and embracing practices like DevSecOps, organizations can build resilient systems that are prepared to withstand both common and emerging threats. A unified security strategy ensures not only compliance but long-term confidence in the security and reliability of the applications that power modern digital services.

Introduction to the final layer of application risks

Securing modern web applications involves more than just protecting data and managing user authentication. The dynamic nature of web environments demands vigilance across client-side behaviors, data serialization processes, third-party dependencies, and operational awareness. While earlier sections covered structural vulnerabilities and logic-based flaws, this final segment explores threats that exploit execution flows, component integrity, and visibility gaps.

The last four items in the OWASP Top 10 encapsulate a diverse mix of attack surfaces. Cross-site scripting targets the user interface and trust in client-side content. Insecure deserialization compromises the inner workings of application logic. The use of outdated or vulnerable components opens the door to inherited weaknesses. And the absence of proper logging and monitoring leaves organizations blind to active threats. Together, they complete the picture of what a secure application must account for in its design and operations.

Cross-site scripting

Cross-site scripting, commonly known as XSS, is a vulnerability that allows attackers to inject malicious scripts into web pages viewed by other users. These scripts typically run in the context of the victim’s browser and can be used to steal session tokens, deface websites, redirect users, or conduct other attacks on behalf of the victim.

XSS attacks exploit the trust a user has in a particular application. When an application includes untrusted data in its output without proper sanitization or escaping, an attacker can insert executable code that the browser will interpret as legitimate.

There are three main types of XSS attacks:

  • Stored XSS: The script is permanently stored on the target server, such as in a database or comment field. When a user retrieves the stored content, the malicious script executes.

  • Reflected XSS: The script is reflected off the web server, usually via a URL or query parameter. It is delivered as part of the response without being saved.

  • DOM-based XSS: The vulnerability exists in client-side code rather than the server. The browser executes a malicious script based on how JavaScript processes the document object model.

To prevent XSS, applications must properly encode or escape user input before inserting it into the HTML output. Context-aware escaping is essential; output in HTML, attributes, JavaScript, or URLs must all be handled differently.

Another effective control is the implementation of a content security policy (CSP). This browser feature allows a server to define which scripts are allowed to run, blocking inline and unauthorized code execution. While not foolproof, CSP can significantly reduce the impact of XSS.

Input validation should be used to enforce the expected format and length of user input, but it should not be the sole defense. Encoding and sanitization are still required to neutralize any potentially malicious payloads.

Applications should also avoid dynamic HTML construction using string concatenation. Frameworks that support automatic encoding and templating systems reduce the likelihood of errors and make secure development easier.

Cross-site scripting is one of the most prevalent web vulnerabilities and affects nearly all types of applications. By taking a proactive and layered approach to defense, developers can safeguard users from these client-side attacks.

Insecure deserialization

Serialization is the process of converting an object into a format that can be stored or transmitted, such as a byte stream or JSON string. Deserialization is the reverse process—reconstructing the object from this format. Many programming environments use serialization to pass data between components, store session states, or cache complex objects.

Insecure deserialization occurs when untrusted data is used to reconstitute objects without proper validation or controls. This can allow attackers to manipulate serialized input to change application behavior, inject malicious data, or execute arbitrary code.

An example of insecure deserialization might involve an application that stores session data as a serialized object in a cookie. If the object structure is not validated, an attacker could modify the contents and submit a malicious version. When deserialized on the server, the object could execute unexpected methods or escalate privileges.

Deserialization vulnerabilities are especially dangerous because they often enable remote code execution—the ability for an attacker to run arbitrary commands on the server. Even without code execution, attackers may exploit deserialization to alter application logic, bypass authentication, or tamper with internal data structures.

To mitigate insecure deserialization, developers should never trust serialized data from untrusted sources. If deserialization is necessary, inputs should be tightly validated against a known schema or structure. Use of type constraints, class whitelisting, and deserialization frameworks that enforce object boundaries can limit potential damage.

Applications should avoid exposing internal serialization formats through cookies or client-side storage. Sensitive objects should not be passed over the network unless encoded securely and protected against tampering.

Logging deserialization activity, especially when it fails or behaves unexpectedly, can reveal early signs of attack attempts. Code paths that handle deserialized data should be hardened and isolated from critical functions, and sensitive objects should include integrity checks such as digital signatures.

Finally, development teams should review their use of serialization and look for alternative approaches. Stateless authentication, secure token formats like JWT, and encrypted data transport mechanisms can often replace risky serialization practices.

Using components with known vulnerabilities

Modern web development relies heavily on third-party components, frameworks, and libraries. These dependencies accelerate development, improve functionality, and standardize processes. However, they also introduce risk. If a component has a known vulnerability and is included in an application, attackers can exploit it—often regardless of the quality of the surrounding code.

This risk is not hypothetical. Some of the most serious breaches in recent years have resulted from vulnerabilities in widely used libraries and software packages. Even popular and well-maintained dependencies can contain flaws, and unless they are updated regularly, applications remain exposed.

Developers often lack visibility into the full list of dependencies included in their projects. Transitive dependencies—packages included by other packages—can introduce vulnerabilities silently. Attackers can also exploit abandoned or compromised packages to distribute malicious updates.

To reduce this risk, it is essential to maintain an up-to-date inventory of all components used in an application, including direct and indirect dependencies. Software composition analysis (SCA) tools can automate this process, identifying known issues and licensing concerns.

Dependencies should be acquired from trusted sources and verified through signatures or checksums when possible. Unused or outdated components should be removed to reduce the attack surface. Developers should avoid copying and pasting code from the internet without understanding its origin and behavior.

Many package managers allow developers to lock versions or receive alerts when security issues are discovered. Regular dependency updates and vulnerability scanning should be integrated into the build and deployment pipeline to ensure timely remediation.

For critical applications, runtime protection such as sandboxing or input filtering can help defend against vulnerabilities in underlying components. Where patching is not possible, virtual patching at the firewall or proxy level can reduce immediate risk while a long-term solution is implemented.

Awareness and management of third-party risk is a shared responsibility. Developers, security teams, and operations staff must collaborate to ensure that the convenience of external components does not compromise application security.

Insufficient logging and monitoring

Security incidents often go undetected for long periods, not because they are sophisticated, but because applications fail to log and monitor relevant events. Without visibility into what’s happening in an application, it becomes impossible to detect or respond to attacks in a timely manner.

Insufficient logging and monitoring leave applications vulnerable to silent breaches, undetected misuse, and delayed incident response. An attacker may probe a system, exploit vulnerabilities, and exfiltrate data over an extended period without triggering any alerts.

Common deficiencies include lack of authentication logs, missing access attempts, improper error handling, and the absence of alerts for unusual behavior. Logs that do exist may be stored insecurely, lack timestamps, or fail to record user context, making investigation difficult.

Comprehensive logging is the foundation of effective monitoring. Applications should log security-relevant events, including logins, failed login attempts, privilege changes, data access, configuration modifications, and error messages. Logs must be timestamped, structured, and protected from tampering.

Monitoring systems should be configured to process these logs and generate alerts based on predefined rules or anomaly detection. For example, multiple failed login attempts from a single IP address, or access to administrative features outside of business hours, may indicate suspicious activity.

Centralized log aggregation using tools like SIEM platforms enables correlation across systems and faster incident response. Retaining logs for a sufficient period supports forensic analysis in the event of a breach.

To improve monitoring, organizations should conduct regular threat modeling and identify the most critical parts of the application. These high-risk areas should receive extra scrutiny in logging and alerting design.

Security teams should also test alert mechanisms through simulated incidents and ensure that responders know how to act when threats are detected. Well-documented escalation procedures and incident response plans ensure that organizations can react effectively under pressure.

Insufficient logging and monitoring not only hinder defense but also increase liability. Many compliance standards require audit trails and incident detection capabilities. Addressing this risk is essential for both security and regulatory reasons.

Conclusion

The final segment of the OWASP Top 10 sheds light on subtle yet critical weaknesses that often go unnoticed. Cross-site scripting exploits the user’s trust in web content. Insecure deserialization compromises internal application logic. Vulnerable components introduce third-party risk. And without proper logging and monitoring, any of these attacks may proceed undetected.

Together with the other vulnerabilities discussed earlier in this series, these risks form a comprehensive view of the threats facing modern web applications. No single fix or policy can eliminate all risks. Security must be embedded at every stage of the software development lifecycle, from design and coding to testing, deployment, and operations.

Developers must write secure code, architects must build defensible systems, and security professionals must monitor, test, and update continuously. Security is not an event—it is a process of continuous improvement, adaptation, and learning.

The OWASP Top 10 is more than a checklist. It is a framework for understanding the common pitfalls in application development and a guide for building resilient systems. Organizations that take these risks seriously and invest in strong security practices will be better prepared to face the challenges of today’s threat landscape and those of tomorrow.