Table Of ContentRok akademicki 2014/2015
Politechnika Warszawska
Wydział Elektroniki i Technik Informacyjnych
Instytut Informatyki
PRACA DYPLOMOWA MAGISTERSKA
Robert Rozmus
Learning Environment For Security of Modern Web
Applications
Opiekun pracy
dr inż. Jacek Wytrębowicz
Ocena: .....................................................
................................................................
Podpis Przewodniczącego
Komisji Egzaminu Dyplomowego
Kierunek: Informatyka
Specjalność: Inżynieria Systemów Informatycznych
Data urodzenia: 25 maja 1990 r.
Data rozpoczęcia studiów: 29 września 2014 r.
Życiorys
Urodziłem się 25 maja 1990 r. w Warszawie. W 2009 r. rozpocząłem studia na Politechnice
Warszawskiej, wydziale Elektroniki i Technik Informacyjnych, na kierunku Inżynieria
Biomedyczna, które ukończyłem w lutym 2013 r. z tytułem inżyniera. W 2011 r. rozpocząłem
na tym samym wydziale studia równoległe na kierunku Informatyka, które ukończyłem w
czerwcu 2014 r. z tytułem inżyniera. W październiku 2014 r. rozpocząłem studia magisterskie
na kierunku Informatyka również na tym samym wydziale. Drugi semestr tych studiów
spędziłem na uczelni University of Southampton w Wielkiej Brytanii w ramach programu
Erasmus+.
.......................................................
Podpis studenta
EGZAMIN DYPLOMOWY
Złożył egzamin dyplomowy w dniu .................................................................................. 2015 r
z wynikiem ..................................................................................................................................
Ogólny wynik studiów: ...............................................................................................................
Dodatkowe wnioski i uwagi Komisji: .........................................................................................
......................................................................................................................................................
......................................................................................................................................................
SUMMARY
This thesis presents security problems of all layers of the TCP/IP model with an emphasis on
the application layer. The thesis describes the vulnerabilities appearing in the modern web
applications. As part of the work an interactive environment (called WebHiob) was created to
teach the web application security in Java. The environment consists of ten lessons presenting
the use of vulnerability, security description of the problem and how to solve it. The lessons
demonstrate the vulnerabilities, which are not shown in any of the three existing environments
(WebGoat, DVWA, HacmeBank). The WebHiob was made out in Java using the Spring MVC
framework and JPA technology. The lessons have been prepared in three view technologies –
Facelets, AngularJS and GWT. Usability has been taken into account whilst designing the
WebHiob, which will make it extremely easy to insert new lessons when required.
Keywords: web application security, interactive learning environment
Środowisko do nauki bezpieczeństwa nowoczesnych aplikacji internetowych
Niniejsza praca przedstawia problemy bezpieczeństwa wszystkich warstw modelu TCP/IP ze
szczególnym naciskiem na warstwę aplikacji. Opisuje podatności pojawiające się w
nowoczesnych aplikacji internetowych. W ramach pracy powstało interaktywne środowisko
(nazwane WebHiob) do nauczania bezpieczeństwa aplikacji internetowych napisanych w
języku Java. Środowisko zawiera dziesięć lekcji przedstawiających wykorzystanie
podatności, opis problemu bezpieczeństwa oraz sposób jego naprawy. Lekcje prezentują
podatności, których nie przedstawiono w żadnym z trzech istniejących środowisk (WebGoat,
DVWA, HacmeBank). WebHiob został wykonany w technologii Java wykorzystując szkielet
Spring MVC oraz specyfikacje JPA. Lekcje przygotowano w trzech technologiach
widokowych – Facelets, AngularJS oraz GWT. Środowisko zaprojektowano w taki sposób,
aby dodawanie kolejnych lekcji w dowolnej technologii widokowej było jak najprostsze.
Słowa kluczowe: bezpieczeństwo aplikacji internetowych, interaktywne środowisko do
nauczania
Składam serdeczne podziękowania Panu
dr. inż. Jackowi Wytrębowiczowi za
poświęcony czas i życzliwą pomoc przy
pisaniu niniejszej pracy
Contents
Acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1. Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2. Aim and scope of the thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3. Organisation of the thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Vulnerabilities of all layers of the TCP/IP model and of the user layer . . . . . 4
2.1. Data transport layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.1. Physical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.2. Data-Link. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.1.3. Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1.4. Transport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2. Application layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.2.1. The most popular vulnerabilities . . . . . . . . . . . . . . . . . . . . . . 13
2.2.2. Other vulnerabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.3. User layer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3. Web application architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.1. Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.1.1. EIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.1.2. Back-end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.1.3. Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.1.4. Middleware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.1.5. Web services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.1.6. Front-end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.2. Authentication and authorization . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3.2.1. Spring Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.2.2. Stateful and stateless authentication. . . . . . . . . . . . . . . . . . . . 48
4. Desired features of learning environment for security of web application . . . 50
4.1. Features important for a user . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.2. Features important for a developer . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.3. Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5. Analysis of existing environments for teaching of web security . . . . . . . . . 54
5.1. WebGoat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
5.2. DVWA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.3. HacmeBank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.4. Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
6. Proposed lessons for the authorial environment . . . . . . . . . . . . . . . . . . 61
6.1. JSONP XSS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
6.2. Spring MVC ModelView injection . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.3. Spring MVC data submission to non-editable fields . . . . . . . . . . . . . . . 68
6.4. JPQL injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.5. EL injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
6.6. Session management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6.6.1. Session Timeout with periodic Ajax request . . . . . . . . . . . . . . . . 74
Contents ii
6.6.2. Automatic redirection to the login page after the session expires. . . . 77
6.7. Authentication and authorization in Rich Internet Application . . . . . . . . . 79
6.7.1. Rich Internet Application security with cookie-based authentication . 79
6.7.2. Rich Internet Application security with token-based authentication . . 82
7. Project of the environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.1. Functional and non-functional requirements . . . . . . . . . . . . . . . . . . . 86
7.2. Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.2.1. Directory structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.2.2. Resolving the view . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.2.3. Used tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
7.3. Adding a new lesson . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.4. Environment testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
7.5. User interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
8. Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
A. User manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
A.1. Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
A.2. Manual . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
B. Contents of included CD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Acronyms
ACAO Access-Control-Allow-Origin.
AJAX Asynchronous JavaScript and XML.
AOP Aspect-Oriented Programming.
API Application Programming Interface.
ARP Address Resolution Protocol.
ASCII American Standard Code for Information Interchange.
CORS Cross Origin Resource Sharing.
CRUD Create, Read, Update and Delete.
CSIS Canadian Security Intelligence Service.
CSRF Cross-Site Request Forgery.
CSS Cascading Style Sheets.
CTO Chief Technology Officer.
CVE Common Vulnerabilities and Exposures.
DAO Data Access Object.
DHCP Dynamic Host Configuration Protocol.
DNS Domain Name System.
DOM Document Object Model.
DoS Denial-of-Service.
DVWA Damn Vulnerable Web App.
ECS Element Construction Set.
EIS Enterprise Information System.
EL Expression Language.
ERP Enterprise resource planning.
FTP File Transfer Protocol.
GUI Graphical User Interface.
GWT Google Web Toolkit.
HSQLDB Hyper SQL Database.
HTML HyperText Markup Language.
Acronyms iv
HTTP Hypertext Transfer Protocol.
ICMP Internet Control Message Protocol.
IDE Integrated Development Environment.
IDS Intrusion Detection System.
IMDB In-Memory Database.
IoC Inversion of Control.
IP Internet Protocol.
IPS Intrusion Prevention Systems.
JAAS Java Authentication and Authorization Service.
JAX-RS Java API for RESTful Web Services.
JAX-WS Java Api for XML Web Services.
JCP Java Community Process.
JDBC Java Database Connectivity.
JEE Java Enterprise Edition.
JMS Java Message Service.
JMX Java Management Extensions.
JPA Java Persistence API.
JPQL Java Persistence Query Language.
JS JavaScript.
JSF JavaServer Faces.
JSON JavaScript Object Notation.
JSONP JSON with padding.
JSP JavaServer Pages.
JSR Java Specification Request.
JUG Java User Group.
JWS JSON Web Signature.
JWT JSON Web Token.
LDAP Lightweight Directory Access Protocol.
MAC Media Access Control.
MBean Managed Bean.
MD5 Message-Digest algorithm 5.
MITM Man-in-the-middle.
MTU Maximum Transmission Unit.
MVC model-view-controller.
NoSQL Not Only SQL.
Acronyms v
ORM Object-relational mapping.
OSI Open Systems Interconnection.
OVAL Open Vulnerability and Assessment Language.
OWASP Open Web Application Security Project.
PDF Portable Document Format.
POJO Plain Old Java Object.
RAD Rapid Application Development.
RAM Random Access Memory.
REST Representational state transfer.
RIA Rich Internet Application.
RPC Remote procedure call.
RSS Rich Site Summary.
SAM Security Account Manager.
SMTP Simple Mail Transfer Protocol.
SOA Service Oriented Architecture.
SOAP Simple Object Access Protocol.
SQL Structured Query Language.
SSL Secure Sockets Layer.
SVN Subversion.
TCP Transmission Control Protocol.
TDD Test-driven development.
TLD Top-level domain.
TTL Time to live.
TXT Text File.
UDP User Datagram Protocol.
UI User interface.
URL Uniform Resource Locator.
USB Universal Serial Bus.
W3C World Wide Web Consortium.
WS-Security Web Services Security.
WWW World Wide Web.
XML Extensible Markup Language.
XSS Cross-Site Scripting.
ZAP Zed Attack Proxy.
1. Introduction
Safety is one of the basic human needs. This word connotes primarily with
the physical security. Nowadays – in this respect, state administrations often
provide sense of security its citizens. From year to year more and more activities
takes place on the Internet, which causes, that the criminality progresses in that
way. AccordingtothereportofCanadianSecurityIntelligenceService(CSIS),cyber
crimecoststheglobaleconomyupto$500billionayear. Ifwecomparethisamount
with $600 billion associated with the drug trafficking, we will see how significant
it is [13]. The question is – if it could be avoided? According to the Open Web
Application Security Project (OWASP) Top Ten document [73], the most popular
attacks in 2013 were different kinds of injections. Many of them could be relatively
easy avoided, therefore as long as people do not start properly studying the web
security, this amount could even increase in the future.
1.1. Motivation
Security of web applications is very important, but it is frequently neglected
by the web developers [133]. There are many books, web pages, information
about web security, examples of attacks and solutions how to prevent them. The
learning process brings greater effects when the information are presented via
computer-based multimedia systems than the traditional classroom lectures [65].
Does it mean that only from books nobody can get extensive knowledge, that books
shouldbereplacedbymultimediasystems? Ofcoursenot. Butifwewanttogetthe
best solution, we should mix these both techniques of studying e.g. start from the
books and then test our new knowledge on something more interactive. Obviously
this proposition is not anything unique, therefore there are several applications
developed to teach about the web vulnerabilities. They include: WebGoat, Damn
Vulnerable Web App (DVWA) and HacmBank. Each one was written in different
programming language (respectively: Java, PHP and C#). Only the former is still
developed, the others are not supported since many years. The basic drawback
of all of these environments is fact, that they do not teach which code is directly
responsible for the vulnerability and how to improve the code to make the attack
impossible. The exceptions include some of the WebGoat’s lessons, however most
Description:widokowych – Facelets, AngularJS oraz GWT. Środowisko .. search all subdirectories of chosen computer to steal sensitive information (files such as