lecture7
lecture7
(040613601)
2
Contents
HTTP Overview
Cookies
Secure Transmission
HTTPS
SSL/TSL
3
HTTP - Hyper Text Transfer Protocol
is an application-level protocol.
Standard for transferring documents on the World Wide Web
The protocol is:
Connectionless
Media-independent
Stateless
Mostly all text
HTTP is a request /response protocol – that is, a user agent (typically
a web browser on a PC) sends a request, and a remote server sends
a response to that request.
A server response consists of:
A status line, including the protocol version number, and a
success / error code, and
A MIME-like message, containing server information, content
meta-information (headers), and content.
The content will typically be written in HTML. 4
HTTP (2)
Status code : 5 classes defined by the standard:
1xx informational response – the request was received, continuing process
100 Continue : status code in response before sending the body.
2xx successful – the request was successfully received, understood, and
accepted
200 OK : Standard response for successful HTTP requests.
3xx redirection – further action needs to be taken in order to complete the
request
301 Moved Permanently : This and all future requests should be directed
to the given URI.
4xx client error – the request contains bad syntax or cannot be fulfilled
403 Forbidden
404 Not found
5xx server error – the server failed to fulfil an apparently valid request
500 Internal Server Error
5
HTTP (3)
HTTP is stateless
The HTTP protocol does not require the server to maintain any protocol
state.
The server does not keep any information to enable consecutive
requests from a single user agent to be linked.
Hence HTTP does not support ‘sessions’
e.g. as might be required to support e-commerce.
HTTP Cookies are a simple means of enabling browser sessions with a
server.
The Cookie is then resubmitted with the
next request to the same server
Definition
“Web security is a set of procedure, practices, and technologies for
protecting web servers, web users, and their surrounding organizations.
Security protects the user against unexpected behavior”
[Garfinkel and Spafford 1997]
9
Code is Part of Security Perimeter
Security “perimeter” has huge
Application Layer
Legacy Systems
Human Resrcs
Web Services
Directories
Databases
Billing
Custom Developed
Application Code
APPLICATION
ATTACK
App Server
Network Layer
Web Server
Hardened OS
Firewall
Firewall
11
Why web servers are compromised?
Unnecessary default, back up, or sample files
Installing the server with default settings
Security conflicts with business ease-of-use case
Improper files and directory permissions
Misconfigurations in web server, operating systems, and networks
Default accounts with their default or no passwords
Lack of proper security policy, procedures, and maintenance
Bugs in server software, OS, and web applications
Security flaws in the server software, OS and applications.
Misconfigured SSL certificates and encryption settings
Improper authentication with external systems
User of self-signed certificates and default certification
Administrative or debugging functions that are enabled or accessible
Unnecessary services enabled, including content management and
remote administration. 12
Web Security - Threats
Threats:
Revealing private information on server
Intercept of client information (client card fraud and abuse)
Content hijacking (mimics of well known sites) and defacement
Hostile content (recursive window pop ups)
Cookies reveal where users have been, how many times ads
have been displayed (user profiling), allow impersonation
13
Web Security - Vulnerabilities
https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf
14
Web Security - Vulnerabilities
https://owasp.org/www-project-top-ten/
15
Web Security - Vulnerabilities
OWASP (Open Web Application Security Project) top 10
vulnerabilities 2023
1. Broken Access Control
2. Cryptographic Failures
3. Injection
4. Insecure Design
5. Security Misconfiguration
6. Vulnerable and Outdated Components
7. Identification and Authentication Failures
8. Software and Data Integrity Failures
9. Security Logging and Monitoring Failures
10. Server-Side Request Forgery
16
OWASP – Top 10 Vulnerabilities
Broken Access Control - include any issue that allows an attacker to bypass
access controls or that fails to implement the principle of least privilege.
For example, a web application might allow a user to access another
user’s account by modifying the provided URL.
Cryptographic Failures - include a failure to use encryption at all,
misconfigurations of cryptographic algorithms, and insecure key
management.
This vulnerability can expose sensitive data such as passwords,
business records, credit card information, email addresses, patient
health records, or other personal user data.
Injection - failure to properly sanitize user input before processing it.
Using a safe API and positive server-side input validation can help in
preventing Injections.
Insecure Design - this vulnerability describes failures in design that
undermine the security of the system
17
OWASP – Top 10 Vulnerabilities (2)
Security Misconfiguration - Unnecessary features enabled or installed,
outdated software, etc can also cause Security Misconfiguration.
This threat can impact any layer of the application stack, cloud or
network, leaving important information to expose.
Vulnerable and Outdated Components - If the components used in the
development of a website or application is outdated or is vulnerable itself,
it can compromise the whole application.
For example, an application may import a third-party library that has its
own dependencies that could contain known exploitable vulnerabilities.
Identification and Authentication Failures - Identification and authentication
failures occur when an application relies upon weak authentication
processes or fails to properly validate authentication information
For example, an application that lacks multi-factor authentication
(MFA) might be vulnerable to a credential stuffing attack in which an
attacker automatically tries username and password combinations from
a list of weak, common, default, or compromised credentials
18
OWASP – Top 10 Vulnerabilities (3)
Software and Data Integrity Failures - It is to verify the installed packages
on your system and make sure that the data is from a reliable source and
has not been altered at any stage.
This vulnerability class includes relying on third-party code from
untrusted sources or repositories.
Security Logging and Monitoring Failures - vital to the maintenance of a
secure infrastructure. Viewing the logs regularly can be helpful in acting fast
in case any potentially dangerous activity is noticed.
Server-Side Request Forgery - SSRF vulnerabilities can exist when a web
application does not properly validate a URL provided by a user when
fetching a remote resource located at that URL.
An attacker exploiting the vulnerability can use the vulnerable web
application to send a request crafted by the attacker to the indicated
URL
19
OWASP – Top 10 Vulnerabilities (4)
Typical exploitation of a server-side request forgery vulnerability
1. The attacker sends a forged request to a web server
that is vulnerable to SSRF and resides on the same
internal network as the target server.
2. The vulnerable web server sends the attacker-controlled
request to the victim’s server, bypassing the firewall.
3. The victim’s server responds to the web server
with the requested data. Web server makes
a request on
4. If the specific SSRF vulnerability permits it, behalf of the user
data is sent back to the attacker.
Direct request is
blocked by firewall
X
https://owasp.org/www-community/attacks/Server_Side_Request_Forgery 20
Cross-Site Request Forgery (XSRF)
forces a logged-on victim’s browser to send a forged HTTP request,
including the victim’s session cookie and any other automatically included
authentication information, to a vulnerable web application.
This allows the attacker to force the victim’s browser to generate requests
the vulnerable application thinks are legitimate requests from the victim.
cookie is sent to the site each time the browser accesses the site.
cookie is used as an authentication token.
Attacker: what if I force your browser to make my request to the secure
site with your cookie?
Forces user to send unauthorized requests by interacting with a
malicious website.
Can force someone to transfer money, change status on social
networking site, buy stock, or any other action on a vulnerable
website an attacker would like to exploit.
XSRF impacts: Malicious site can’t read bank info, but can request bank
to do things benefit attackers – such as transfer money to them!
21
Cross-Site Request Forgery (XSRF)
1. You log in https://www.bank.com. Do some bank stuff. But you have not
logged off yet.
2. You open another page www.attacker.com. This page has an evil form:
3. Your browser executes this form. The result is that the evilform is
submitted with a password-change request to bank.com’s “good” form:
www.bank.com/update_profile with a <input type="password"
id="password"> field.
4. You noticed nothing because nothing is displayed.
22
Cross-Site Request Forgery (XSRF)
Normal Interaction
XSRF Attack
23
Cross-Site Request Forgery (XSRF)
Cookie Authentication is NOT Enough
• Users logs into bank.com, forgets to sign off
• Session cookie remains in browser state
• User then visits a malicious website containing
<form name=BillPayForm
action=http://bank.com/BillPay.php>
<input name=recipient value=badguy> …
<script> document.BillPayForm.submit(); </script>
• Browser sends cookie, payment request fulfilled
4
2 Server victim
User victim
Attack server
24
Web Security Problems
Securing the web server
Securing the web client
Securing information that travels between the web server and the user
Securing the application
Input validation Session mgmt Authentication
Authorization Config mgmt Error handling
Secure storage Auditing/logging
Web server App server DB server
firewall
firewall
Message displayed
during defacement of
a UK National Health
Services website in
2018. Source: BBC.
27
Web Server Security
Discover
Examine the environment
Identify open ports eg. nmap
Discover types/versions of apps running, Banner grabbing,
Extensions (.jhtml, .jsp, etc.) and directory structures
Generate and examine errors
Submit ridiculous input to provoke errors (fuzzing)
Database errors, stack traces very helpful
Find info left behind (source code, comments, hidden fields)
Target
Login mechanism - Input fields
Session management - Infrastructure
28
Web Server Attack Consequences
29
Web Server Risk Mitigation
Regular security audits and penetration testing
Strong passwords and multi-factor authentication
Regular software updates and patches
Intrusion detection and prevention systems (IDPS)
Web application firewalls (WAF)
Proper server configuration and hardening
30
Web Application Firewall (WAF)
Inspection: WAFs meticulously examine every HTTP request and
response, looking for malicious patterns or suspicious activity.
Filtering: Based on predefined rules and security policies, the WAF
filters out harmful traffic, such as:
SQL Injection: Prevents attackers from injecting malicious SQL
commands into your database.
Cross-Site Scripting (XSS): Blocks attempts to inject malicious
scripts into your website.
Cross-Site Request Forgery (CSRF): Stops unauthorized
commands from being executed on behalf of authenticated users.
Denial-of-Service (DoS) attacks: Protects your website from being
overwhelmed by excessive traffic.
Blocking: When a WAF detects a malicious request, it blocks it
immediately, preventing it from reaching your web application.
Logging and Reporting: WAFs keep detailed logs of all traffic, including
blocked attacks, which can be valuable for security analysis and
incident response. 31
Web Client Security
A web browser is a large software with many features
Each feature is a potential security hole
Web Client Security Problems
Downloaded files
may contain viruses and trojan horses
Helper applications and plug-ins
may run programs on your machine
Javascript
has security model
ActiveX, etc.
many security problems
Cookies
Allow sites to track usage
Browser bugs
many reported
many still remain
http://www.cert.org/tech_tips/securing_browser/#how_to_secure 32
Browser Attack
Browser – software connects to a particular web address, fetches and
displays content from that address, and transmits data from a user to
that address.
Browsers connect users to outside networks, but few users can
monitor the actual data transmitted
Browser Attack Types
Man-in-the-browser
Keystroke logger
Page-in-the-middle
Program download substitution
33
Browser Attack (2)
Man-in-the-browser -Trojan horse that intercepts data passing through the
browser
Ex Trojan horse called SilentBanker.
This code linked to a victim’s browser as an add-on or browser helper
object; it listed itself as a plug-in to display video.
When it detected the user going to a banking URL, it would intercept
keystrokes and even modify them so that money transfers would go to
attackers’ accounts.
34
Browser Attack (3)
Keystroke logger (or key logger)
Hardware or software that records all keystrokes
May be a small dongle plugged into a USB port or can masquerade as
a keyboard
May also be installed as malware
Not limited to browsers
Page-in-the-middle
User is directed to a different page than believed or intended
Similar effect to a man-in-the-browser, where attacker can intercept
and modify user input
Program download substitution
Attacker creates a page with seemingly innocuous and desirable
programs for download
Instead of, or in addition to, the intended functionality, the user installs
malware
This is a very common technique for spyware 35
Securing Data Transfer
Secure Socket Layer (SSL)
Encrypts data transferred between browser and server
Identifies server
(optionally identifies user - rarely used)
Does not secure data once on the server (or client)
secure HTTP: Protocol for securely transmitting individual messages
over the Web. A modified version of the standard HTTP protocol.
SSL and S-HTTP use techniques such as encryption, digital
signatures, and:
allow browsers and servers to authenticate each other
allow controlled access to Web site
ensure data exchanged between browser and server is secure and
reliable.
36
Overview of SSL
TCP provides a reliable end-to-end service
SSL consists of two sublayers:
SSL Record Protocol (where all the action takes place)
SSL Management: (Handshake/Cipher Change/ Alert Protocols)
SSL Change
SSL Cipher Spec SSL Alert
HTTP, other
Handshake Protocol Protocol
apps
Protocol
TCP
37
SSL Characteristics
Operates at the TCP/IP transport layer
Encrypts (decrypts) input from application (transport) layer
Any program using TCP can be modified to use SSL connections
SSL connection uses a dedicated TCP/IP socket
(e.g. port 443 for https or port 465 for ssmtp)
SSL is flexible in choice of which symmetric encryption, message
digest, and authentication algorithms can be used
When SSL client makes contact with SSL server they try to pick
strongest encryption methods they have in common.
SSL provides built in data compression
compress first then encrypt
38
SSL Characteristics (2)
When SSL connection established browser-to-server and server-to-
browser communications are encrypted.
This includes:
URL of requested document
Contents of the document
Contents of browser forms
Cookies sent from browser to server
Cookies sent from server to browser
Contents of HTTP header
But NOT particular browser to particular server
socket addresses not encrypted
can use proxy server for privacy
39
SSL Preliminaries
An SSL Session is an association between a client and a server
created by the Handshake Protocol
There are a set of security parameters associated with each
session
Session Identifier
Peer Certificate: X.509v3 certificate of the peer
Compression: Optional algorithm used to compress data
Cipher Specs: Encryption Algorithm (3DES, AES, etc.) and
hash algorithm (MD5, SHA-1)
Master Secret: 48-byte secret shared between client and
server
An SSL Connection is a peer-to-peer relationship, and is transient.
There may be many connections associated with one session.
The same security parameters may apply to many connections.
40
SSL Record Protocol
The SSL Record Protocol uses the keys derived from the Handshake
Protocol to securely deliver data
Two functions:
Confidentiality and Message Integrity
Data
Compression Shrunk
MAC Shrunk
Encrypt Encrypted
Header Encrypted
41
SSL Record Protocol (2)
SSL Record protocol allows protocols above SSL to be secured
Example: HTTP delivers packets that are fragmented and
securely delivered
SSL does not handle retransmissions… it does not have to! TCP
provides that functionality
Messages are broken into blocks of at most 16384 bytes
The compression is optional and, due to message size/type, it might
not even be desirable to use!
Encryption may be stream or block mode. This is negotiated through
the Handshake protocol
If block encryption, padding is necessary in order to fill out a block
length
Padding is a sequence of padding bytes (random junk will do)
followed by 1 byte that describes length of the pad (up to 255).
42
SSL Handshake Protocol
Basically, the Handshake protocol is used before any application data
is transmitted.
It is used to allow the server and client to authenticate each other
To negotiate on an encryption and MAC algorithm
Establish keys to be used
The Handshake Protocol consists of messages consisting of three
fields:
Type (1 byte): Indicates type of the message. There are 10 types.
Length (3 bytes)
Content: The payload exchanged in each message
43
SSL Handshake Protocol 2
Client A Server G Round 1: Create the Connection between
the Client A and Server G, and figure out
what each entity can do!
Round 4: Wrap-up
Client tells Server to change cipher (via the
Change Cipher Protocol).
Server responds with its own changed
cipher message
Finished Message are hashes for
verification
10.A G : {ChangeCipher}
11.A G : hash MS || rG || hash (Messages1to9 || Client || MS || rA )
12.G A : {CipherChanged}
13.G A : hash MS || rG || hash (Messages1to9 || Server || MS || rA )
47
SSL
Handshake
Summary
48