Unit I - WEB Application Security
Unit I - WEB Application Security
Web application security (also known as Web AppSec) is the idea of building
websites to function as expected, even when they are under attack.
Web security refers to protecting networks and computer systems from damage to or
the theft of software, hardware, or data.
Taking proper web application security precautions helps reduce the risk of data
theft, compliance penalties, the cost of security fixes, and a ruined reputation.
High-quality web application security — which can be used to protect websites, web
services and web applications — should have four different layers of security: web
application firewall, access control, bot protection, and login protection.
It is done before the authorization While this process is done after the
process. authentication process.
It needs usually the user’s login While it needs the user’s privilege or
details. security levels.
Conclusion
Authentication verifies the identity of a person or device, at the same time as
authorization determines their access rights and permissions within a device.
Together, they make sure that users aren’t only who they claim to be but also have
the permissions to perform certain actions or access certain sources.
Authentication is the act of validating that users are whom they claim to be. This is
the first step in any security process.
In some instances, systems require the successful verification of more than one
factor before granting access. This multi-factor authentication (MFA) requirement is
often deployed to increase security beyond what passwords alone can provide.
What Is Authorization?
Consider a person walking up to a locked door to provide care to a pet while the
family is away on vacation. That person needs:
Authentication, in the form of a key. The lock on the door only grants access
to someone with the correct key in much the same way that a system only
grants access to users who have the correct credentials.
Authorization, in the form of permissions. Once inside, the person has the
authorization to access the kitchen and open the cupboard that holds the pet
food. The person may not have permission to go into the bedroom for a quick
nap.
Authentication and authorization work together in this example. A pet sitter has the
right to enter the house (authentication), and once there, they have access to certain
areas (authorization).
Authentication Authorization
What does it do? Verifies credentials Grants or denies permissions
Through passwords, biometrics, Through settings maintained
How does it work? one-time pins, or apps by security teams
Is it visible to the
user? Yes No
It is changeable by
the user? Partially No
How does data
move? Through ID tokens Through access tokens
Systems implement these concepts in the same way, so it’s crucial that IAM
administrators understand how to utilize both:
Secure Socket Layer (SSL) provides security to the data that is transferred
between web browser and server. SSL encrypts the link between a web server and a
browser which ensures that all data passed between them remain private and free
from attack. In this article, we are going to discuss SSL in detail, its protocols, the
silent features of SSL, and the version of SSL.
What is a Secure Socket Layer?
SSL, or Secure Sockets Layer, is an Internet security protocol that encrypts data to
keep it safe. It was created by Netscape in 1995 to ensure privacy, authentication,
and data integrity in online communications. SSL is the older version of what we now
call TLS (Transport Layer Security).
Websites using SSL/TLS have “HTTPS” in their URL instead of “HTTP.”
How does SSL work?
Encryption: SSL encrypts data transmitted over the web, ensuring privacy. If
someone intercepts the data, they will see only a jumble of characters that is
nearly impossible to decode.
Authentication: SSL starts an authentication process called a handshake
between two devices to confirm their identities, making sure both parties are who
they claim to be.
Data Integrity: SSL digitally signs data to ensure it hasn’t been tampered with,
verifying that the data received is exactly what was sent by the sender.
Why is SSL Important?
Originally, data on the web was transmitted in plaintext, making it easy for anyone
who intercepted the message to read it. For example, if someone logged into their
email account, their username and password would travel across the Internet
unprotected.
SSL was created to solve this problem and protect user privacy. By encrypting data
between a user and a web server, SSL ensures that anyone who intercepts the data
sees only a scrambled mess of characters. This keeps the user’s login credentials
safe, visible only to the email service.
Additionally, SSL helps prevent cyber attacks by:
Authenticating Web Servers: Ensuring that users are connecting to the
legitimate website, not a fake one set up by attackers.
Preventing Data Tampering: Acting like a tamper-proof seal, SSL ensures that
the data sent and received hasn’t been altered during transit.
Secure Socket Layer Protocols
SSL Record Protocol
Handshake Protocol
Change-Cipher Spec Protocol
Alert Protocol
Handshake Protocol
Handshake Protocol is used to establish sessions. This protocol allows the client and
server to authenticate each other by sending a series of messages to each other.
Handshake protocol uses four phases to complete its cycle.
Phase-1: In Phase-1 both Client and Server send hello-packets to each other. In
this IP session, cipher suite and protocol version are exchanged for security
purposes.
Phase-2: Server sends his certificate and Server-key-exchange. The server end
phase-2 by sending the Server-hello-end packet.
Phase-3: In this phase, Client replies to the server by sending his certificate and
Client-exchange-key.
Phase-4: In Phase-4 Change-cipher suite occurs and after this the Handshake
Protocol ends.
Change-Cipher Protocol
This protocol uses the SSL record protocol. Unless Handshake Protocol is
completed, the SSL record Output will be in a pending state. After the handshake
protocol, the Pending state is converted into the current state.
Change-cipher protocol consists of a single message which is 1 byte in length and
can have only one value. This protocol’s purpose is to cause the pending state to be
copied into the current state.
Alert Protocol
This protocol is used to convey SSL-related alerts to the peer entity. Each message
in this protocol contains 2 bytes.
Transport Layer Securities (TLS) are designed to provide security at the transport
layer. TLS was derived from a security protocol called Secure Socket Layer (SSL).
TLS ensures that no third party may eavesdrop or tampers with any message.
There are several benefits of TLS:
Encryption:
TLS/SSL can help to secure transmitted data using encryption.
Interoperability:
TLS/SSL works with most web browsers, including Microsoft Internet Explorer
and on most operating systems and web servers.
Algorithm flexibility:
TLS/SSL provides operations for authentication mechanism, encryption
algorithms and hashing algorithm that are used during the secure session.
Ease of Deployment:
Many applications TLS/SSL temporarily on a windows server 2003 operating
systems.
Ease of Use:
Because we implement TLS/SSL beneath the application layer, most of its
operations are completely invisible to client.
Working of TLS:
The client connect to server (using TCP), the client will be something. The client
sends number of specification:
1. Version of SSL/TLS.
2. which cipher suites, compression method it wants to use.
The server checks what the highest SSL/TLS version is that is supported by them
both, picks a cipher suite from one of the clients option (if it supports one) and
optionally picks a compression method. After this the basic setup is done, the server
provides its certificate. This certificate must be trusted either by the client itself or a
party that the client trusts. Having verified the certificate and being certain this server
really is who he claims to be (and not a man in the middle), a key is exchanged. This
can be a public key, “PreMasterSecret” or simply nothing depending upon cipher
suite.
Both the server and client can now compute the key for symmetric encryption. The
handshake is finished and the two hosts can communicate securely. To close a
connection by finishing. TCP connection both sides will know the connection was
improperly terminated. The connection cannot be compromised by this through,
merely interrupted.
Transport Layer Security (TLS) continues to play a critical role in securing data
transmission over networks, especially on the internet. Let’s delve deeper into its
workings and significance:
Enhanced Security Features:
TLS employs a variety of cryptographic algorithms to provide a secure
communication channel. This includes symmetric encryption algorithms like AES
(Advanced Encryption Standard) and asymmetric algorithms like RSA and Diffie-
Hellman key exchange. Additionally, TLS supports various hash functions for
message integrity, such as SHA-256, ensuring that data remains confidential and
unaltered during transit.
Certificate-Based Authentication:
One of the key components of TLS is its certificate-based authentication mechanism.
When a client connects to a server, the server presents its digital certificate, which
includes its public key and other identifying information. The client verifies the
authenticity of the certificate using trusted root certificates stored locally or provided
by a trusted authority, thereby establishing the server’s identity.
Forward Secrecy:
TLS supports forward secrecy, a crucial security feature that ensures that even if an
attacker compromises the server’s private key in the future, they cannot decrypt past
communications. This is achieved by generating ephemeral session keys for each
session, which are not stored and thus cannot be compromised retroactively.
TLS Handshake Protocol:
The TLS handshake protocol is a crucial phase in establishing a secure connection
between the client and the server. It involves multiple steps, including negotiating the
TLS version, cipher suite, and exchanging cryptographic parameters. The
handshake concludes with the exchange of key material used to derive session keys
for encrypting and decrypting data.
Perfect Forward Secrecy (PFS):
Perfect Forward Secrecy is an advanced feature supported by TLS that ensures the
confidentiality of past sessions even if the long-term secret keys are compromised.
With PFS, each session key is derived independently, providing an additional layer
of security against potential key compromise.
TLS Deployment Best Practices:
To ensure the effectiveness of TLS, it’s essential to follow best practices in its
deployment. This includes regularly updating TLS configurations to support the latest
cryptographic standards and protocols, disabling deprecated algorithms and cipher
suites, and keeping certificates up-to-date with strong key lengths.
Continual Evolution:
TLS standards continue to evolve to address emerging security threats and
vulnerabilities. Ongoing efforts by standards bodies, such as the Internet
Engineering Task Force (IETF), ensure that TLS remains robust and resilient against
evolving attack vectors.
Conclusion:
In an increasingly interconnected world where data privacy and security are
paramount, Transport Layer Security (TLS) serves as a foundational technology for
securing communication over networks. By providing encryption, authentication, and
integrity protection, TLS enables secure data transmission, safeguarding sensitive
information from unauthorized access and tampering. As cyber threats evolve, TLS
will continue to evolve, adapting to new challenges and reinforcing the security
posture of digital communications.
Session management should also control the lifespan of the session, enforcing
session timeouts and ensuring proper user logout to limit the window of opportunity
for any potential misuse. The session ID should not disclose any sensitive
information and should be protected during transit (e.g., by using secure cookies with
the HttpOnly and Secure flags set).
There are many techniques web application developers use in order to reduce the
effectiveness of security attacks. It is imperative to upkeep good session
management practices when developing a web application. Below are some
effective techniques to ensure session management is secure and robust.
Usage of Secure Session Identifiers: All tokens issued by the web
application should be generated using a secure, cryptographic random
generator to prevent the tokens being guessed by a would be attacker.
Implement HTTPS: Interactions between the client and server should be
secured using HTTPS. This will mitigate the chances of the tokens being
intercepted during transit.
Usage of Cookie Attributes: Tokens issued by the application should be
properly configured with the ‘HttpOnly’ and ‘Secure’ cookie attributes. These
flags secure the cookies from being accessible via client-side scripts (Such as
JavaScript), or transmitted over an insecure connection. It is also advisable to
use the ‘SameSite’ attribute where appropriate.
Session Lifecycle: Tokens should have effective timeouts and expirations
policies. This includes both absolute timeouts (E.g. a definitive expiration
since login) and inactivity timeouts (E.g. an inactivity timeout, such as 30
minutes of the user making no requests to the server)
Refresh Session Identifiers: In the event of a change of privilege to a user
account, or logout . The session identifier should be refreshed.
Validated Sessions on every request: Each request should be checked to
ensure that is contains a valid session identifier, this is especially important on
requests which modify or access any user data.
Securely Store Session Data: If session data is stored server-side, ensure
this is protected from unauthorised access or tampering.
Limit Session Data Exposure: The amount of sensitive data store in the
session should be limited. If possible, keep critical data server-side and only
send identifiers or tokens client-side.
Implement Logout Functionality: Users should always be provided with the
ability to logout and terminuate a session. The logout function should
terminate the session both client/server-side.
Monitoring & Logging: Sessions should be monitored in real-time,
anomalies or potential breaches should be investigated.
Further guidance and security advice can be found on the Session Management
Cheat Sheet provided by OWASP.
Key Characteristics:
Session Cookie: A piece of data sent from a website and stored on the
user’s computer by the user’s web browser while the user is browsing.
Cookies can be used to manage sessions.
Cross-Site Request Forgery (CSRF): An attack that forces an end user to
execute unwanted actions on a web application in which they’re currently
authenticated, often involving the misuse of session tokens.
HTTPS: A protocol for secure communication over a computer network which
is widely used on the Internet. It encrypts the session data during
transmission.
Cross-Site Scripting (XSS): A type of security vulnerability typically found in
web applications that allows attackers to inject client-side scripts into web
pages viewed by other users, potentially compromising session tokens if not
properly managed.
Session Token: A unique piece of data, often a random string. The token is
usually generated by a web-server and sent over to the user’s device.
Session Hijacking: A type of session attack in which an attacker takes
control of a user’s session.
https://sencode.co.uk/glossary/session-management/
Input Validation
Input validation is the process of verifying the integrity of data that is received by an
application or system. This includes checking that the data is in the correct format,
within the expected range of values, and free from any malicious code or characters.
Cyberattacks are dangerous attacks that take place on the computer systems of
individuals/ organizations by unauthorized individuals known as cyber attackers or
hackers. Cyberattackers aim to take advantage of computer system vulnerabilities to
get into the computer network and access the secured user/ organization data.
Cyberattacks are very important to be detected at the early stage so that preventive
steps are taken. Knowledge and awareness of cyber crimes help in mitigating the
cyberattack efficiently.
Input Validation Attack:
Input Validation Attack is a dangerous cybersecurity attack.
The unsafe data that is entered as a part of this attack is malicious enough to
cause greater harm to the system’s vulnerability.
They manually entered the suspicious data, and broke the secure system
environment created as a part of the connection.
Mechanism of Input Validation Attack:
The mechanism of the Input Validation Attack is governed by the fact, that harmful
inputs are injected into the computer systems where validated input is required.
Unknowingly web applications can also contribute to input validation attacks however
most commonly, there is manual feeding of data to hamper the system performance.
Types of Input Validation Attack:
There are 4 different types of Input Validation Attacks. They are listed as follows :
1. Buffer Overflow Input Validation: Buffer Overflow is a type of Input Validation
Attack that makes the computer system unresponsive by overloading it with a huge
chunk of information. The huge chunks result in successive memory consumption
and occupy a great part of computer memory.
2. Canonical Ideation Input Validation Attack: Canonical Ideation is a type of
Input Validation Attack is caused as a result of changing the file path that had secure
access to secure information. Thereby making the secure and sensitive information
accessible to unauthorized users to view, make changes, and even steal private
sensitive information as and when required.
3. XSS Attack: XSS Attacks are cross-site scripting attacks where a suspicious link
is placed alongside the valid legitimate URLs. The user is unable to detect or
distinguish between the legitimate and malicious user link and unknowingly becomes
a victim of the XSS Input Validation attack.
4. SQL Injection Attack: SQL Injection is another type of Input Validation Attack,
involving the phenomenon where the public URL is tampered with by the injection of
SQL code in the Public URL. The hacker injects the code with the purpose to allow
actions such as copying of confidential user data, manipulating sensitive information,
and purposely deleting significant important information.
Prevention from Input Validation Attacks:
Input Validation Attacks can be prevented by the following:
Monitoring the input length and having a maximum limit set for input.
Make use of filters to validate inputs that are given to the computer systems as
input.
Specify the data type that is allowed for the fields, thereby restricting unwanted
data to be entered as input.